From 4241680a45b755fdb50ee4ed47f0863a241fe1b5 Mon Sep 17 00:00:00 2001
From: Jonathan Youett <youett@math.fu-berlin.de>
Date: Wed, 5 Dec 2018 14:18:41 +0100
Subject: [PATCH] Minor cleanup

---
 dune/contact/common/staticmgcontactproblem.cc | 13 +++++--------
 dune/contact/common/staticmgcontactproblem.hh |  2 +-
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/dune/contact/common/staticmgcontactproblem.cc b/dune/contact/common/staticmgcontactproblem.cc
index 8eaf819b..67724021 100644
--- a/dune/contact/common/staticmgcontactproblem.cc
+++ b/dune/contact/common/staticmgcontactproblem.cc
@@ -1,7 +1,6 @@
 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 // vi: set ts=4 sw=2 et sts=2:
 
-#include <memory>
 
 #include <dune/fufem/assemblers/functionalassembler.hh>
 #include <dune/fufem/assemblers/operatorassembler.hh>
@@ -17,15 +16,15 @@ typename VectorType::field_type StaticMgContactProblem<VectorType,MaterialType>:
   deformGrids(iterates);
 
   // The infeasibility is the maximal nonlinear constraint violation
-  field_type infeasibility(0);
+  field_type infeasibility{0.0};
 
   for (int i=0; i<contactAssembler_->nCouplings(); i++) {
-    auto* coupling = dynamic_cast<ContactCoupling*>(contactAssembler_->getContactCouplings()[i].get());
+    auto coupling = std::dynamic_pointer_cast<ContactCoupling>(contactAssembler_->getContactCouplings()[i]);
     // rebuild coupling and evaluate obstacles
     auto obstacles = coupling->assembleObstacles(true);
 
-    for (size_t j=0; j<obstacles.size(); j++)
-      infeasibility = std::max(infeasibility, -obstacles[j]);
+    for (const auto& obstacle : obstacles)
+      infeasibility = std::max(infeasibility, -obstacle);
   }
 
   return infeasibility;
@@ -59,7 +58,7 @@ template <class VectorType, class MaterialType>
 void StaticMgContactProblem<VectorType,MaterialType>::assembleQP(const std::vector<VectorType>& iterates)
 {
   // assemble linear and quadratic terms
-  for (size_t i=0;i<iterates.size();i++) {
+  for (size_t i=0 ; i < iterates.size(); i++) {
 
     auto& material = (*this->materials_)[i];
     const auto& basis = material.basis();
@@ -90,8 +89,6 @@ void StaticMgContactProblem<VectorType,MaterialType>::assembleQP(const std::vect
 
   // assemble the linearisations
   contactAssembler_->assembleLinearisations();
-
-  // assemble the local coordinate systems and obstacles
   contactAssembler_->assembleClpReflections();
   contactAssembler_->assembleObstacle();
 
diff --git a/dune/contact/common/staticmgcontactproblem.hh b/dune/contact/common/staticmgcontactproblem.hh
index 2c295dea..1ef46bad 100644
--- a/dune/contact/common/staticmgcontactproblem.hh
+++ b/dune/contact/common/staticmgcontactproblem.hh
@@ -78,7 +78,7 @@ public:
   const std::vector<VectorType>& rhs() const {return rhs_;}
 
   //! Return the nonlinear constraints
-  const std::vector<BoxConstraint<field_type, dim> >& constraints() const
+  const auto& constraints() const
   {
     return contactAssembler_->totalObstacles_;
   }
-- 
GitLab