From d3d666b17434af1edd8a61d1a7883e7d44ebc12c Mon Sep 17 00:00:00 2001 From: Jonathan Youett <youett@math.fu-berlin.de> Date: Wed, 10 Oct 2018 10:49:08 +0200 Subject: [PATCH] Store assemblers by value --- .../materials/mooneyrivlinmaterial.hh | 16 +++++------ .../materials/neohookeanmaterial.hh | 27 +++++++------------ 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/dune/elasticity/materials/mooneyrivlinmaterial.hh b/dune/elasticity/materials/mooneyrivlinmaterial.hh index ce60e5e..beeeeb6 100644 --- a/dune/elasticity/materials/mooneyrivlinmaterial.hh +++ b/dune/elasticity/materials/mooneyrivlinmaterial.hh @@ -190,14 +190,14 @@ public: //! Return the local assembler of the first derivative of the strain energy typename Base::LocalLinearization& firstDerivative(std::shared_ptr<GridFunction> displace) { - localLinearization_->setConfiguration(displace); - return *localLinearization_; + localLinearisation_.setConfiguration(displace); + return localLinearisation_; } //! Return the local assembler of the second derivative of the strain energy typename Base::LocalHessian& secondDerivative(std::shared_ptr<GridFunction> displace) { - localHessian_->setConfiguration(displace); - return *localHessian_; + localHessian_.setConfiguration(displace); + return localHessian_; } private: @@ -245,15 +245,15 @@ private: //! Construct the local assembler members void constructAssemblers() { - localLinearization_ = std::make_shared<MonRivLinearization>(a_, b_, c_, d_, e_, k_); - localHessian_ = std::make_shared<MonRivHessian>(a_, b_, c_, d_, e_, k_); + localLinearisation_ = MonRivLinearisation(a_, b_, c_, d_, e_, k_); + localHessian_ = MonRivHessian(a_, b_, c_, d_, e_, k_); } //! First derivative of the strain energy - std::shared_ptr<MonRivLinearization> localLinearization_; + MonRivLinearisation localLinearisation_; //! Second derivative of the strain energy - std::shared_ptr<MonRivHessian> localHessian_; + MonRivHessian localHessian_; //! Elasticity modulus field_type E_; diff --git a/dune/elasticity/materials/neohookeanmaterial.hh b/dune/elasticity/materials/neohookeanmaterial.hh index f29c90b..c6acac5 100644 --- a/dune/elasticity/materials/neohookeanmaterial.hh +++ b/dune/elasticity/materials/neohookeanmaterial.hh @@ -67,25 +67,19 @@ public: NeoHookeanMaterial() = default; template <class BasisT> - NeoHookeanMaterial(BasisT&& basis, ReturnType E, ReturnType nu) : - Base(std::forward<BasisT>(basis)) + NeoHookeanMaterial(BasisT&& basis, field_type E, field_type nu) { - lambda_ = E*nu / ((1+nu)*(1-2*nu)); - mu_ = E / (2*(1+nu)); - - localLinearization_ = std::make_shared<NeoLinearization>(lambda_,mu_); - localHessian_ = std::make_shared<NeoHessian>(lambda_,mu_); + setup(std::forward<BasisT>(basis), E, nu); } template <class BasisT> void setup(BasisT&& basis, field_type E, field_type nu) { - lambda_ = E*nu / ((1+nu)*(1-2*nu)); mu_ = E / (2*(1+nu)); - localLinearization_ = std::make_shared<NeoLinearization>(lambda_,mu_); - localHessian_ = std::make_shared<NeoHessian>(lambda_,mu_); + localLinearization_ = NeoLinearisation{lambda_, mu_}; + localHessian_ = NeoHessian{lambda_, mu_}; this->setBasis(std::forward<BasisT>(basis)); } @@ -212,23 +206,22 @@ public: //! Return the local assembler of the first derivative of the strain energy typename Base::LocalLinearization& firstDerivative(std::shared_ptr<GridFunction> displace) { - localLinearization_->setConfiguration(displace); - return *localLinearization_; + localLinearization_.setConfiguration(displace); + return localLinearization_; } //! Return the local assembler of the second derivative of the strain energy typename Base::LocalHessian& secondDerivative(std::shared_ptr<GridFunction> displace) { - localHessian_->setConfiguration(displace); - return *localHessian_; + localHessian_.setConfiguration(displace); + return localHessian_; } private: //! First derivative of the strain energy - std::shared_ptr<NeoLinearization> localLinearization_; - + NeoLinearisation localLinearization_; //! Second derivative of the strain energy - std::shared_ptr<NeoHessian> localHessian_; + NeoHessian localHessian_; //! First Lame constant field_type lambda_; -- GitLab