From 4a12d2bc79822c093fea6ed8f0c65814458c3e93 Mon Sep 17 00:00:00 2001 From: Elias Pipping <elias.pipping@fu-berlin.de> Date: Sun, 13 Nov 2011 22:31:27 +0100 Subject: [PATCH] Rely on RVO; Allows to construct just once object --- dune/tectonic/globallaursennonlinearity.hh | 4 ++-- dune/tectonic/globalnonlinearity.hh | 2 +- dune/tectonic/myblockproblem.hh | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/dune/tectonic/globallaursennonlinearity.hh b/dune/tectonic/globallaursennonlinearity.hh index 539abedb..b1d84544 100644 --- a/dune/tectonic/globallaursennonlinearity.hh +++ b/dune/tectonic/globallaursennonlinearity.hh @@ -34,11 +34,11 @@ class GlobalLaursenNonlinearity sigma_n [id + mu id] = sigma_n (1 + mu) id */ - virtual void restriction(int i, OuterFunctionType &f) const { + OuterFunctionType restriction(int i) const { double coefficient = nodalIntegrals[i][0]; coefficient *= normalStress[i]; coefficient *= 1 + coefficientOfFriction[i]; - f = OuterFunctionType(coefficient); + return OuterFunctionType(coefficient); } private: diff --git a/dune/tectonic/globalnonlinearity.hh b/dune/tectonic/globalnonlinearity.hh index a72c2bb2..8ed3bb38 100644 --- a/dune/tectonic/globalnonlinearity.hh +++ b/dune/tectonic/globalnonlinearity.hh @@ -11,7 +11,7 @@ template <int dim, class OuterFunctionType> class GlobalNonlinearity { /* Return a restriction of the outer function to the i'th node. If */ - virtual void restriction(int i, OuterFunctionType &f) const = 0; + virtual OuterFunctionType restriction(int i) const = 0; }; } #endif diff --git a/dune/tectonic/myblockproblem.hh b/dune/tectonic/myblockproblem.hh index 243fdd8e..cb285c01 100644 --- a/dune/tectonic/myblockproblem.hh +++ b/dune/tectonic/myblockproblem.hh @@ -114,8 +114,7 @@ class MyBlockProblem<MyConvexProblemTypeTEMPLATE>::IterateObject { } assert(localA != NULL); - FunctionType f; - problem.phi.restriction(m, f); + auto const f = problem.phi.restriction(m); Dune::LocalNonlinearity<block_size> const phi(f); Dune::SampleFunctional<block_size> localJ(*localA, localb, phi, ignore_component); -- GitLab