From d1b0e1ed22fc68dda67c755a4cd2cd96a664ae6c Mon Sep 17 00:00:00 2001 From: Oliver Sander <oliver.sander@tu-dresden.de> Date: Sun, 23 Jun 2019 22:07:37 +0200 Subject: [PATCH] Introduce LocalFirstOrderModel, make RodLocalStiffness inherit from it LocalFirstOrderModel will be an abstract base class for models that implement an energy and a first (not no second) derivative. A LocalGeodesicFEStiffness 'is a' LocalFirstOrderModel, which 'is a' LocalEnergy. --- dune/gfe/localfirstordermodel.hh | 30 ++++++++++++++++++++++++++++++ dune/gfe/rodassembler.hh | 12 +++++++++--- dune/gfe/rodlocalstiffness.hh | 4 ++-- 3 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 dune/gfe/localfirstordermodel.hh diff --git a/dune/gfe/localfirstordermodel.hh b/dune/gfe/localfirstordermodel.hh new file mode 100644 index 00000000..a098c5ba --- /dev/null +++ b/dune/gfe/localfirstordermodel.hh @@ -0,0 +1,30 @@ +#ifndef DUNE_GFE_LOCALFIRSTORDERMODEL_HH +#define DUNE_GFE_LOCALFIRSTORDERMODEL_HH + +#include <dune/gfe/localenergy.hh> + +namespace Dune { + +namespace GFE { + +template<class Basis, class TargetSpace> +class LocalFirstOrderModel +: public Dune::GFE::LocalEnergy<Basis,TargetSpace> +{ +public: + + /** \brief Assemble the element gradient of the energy functional + + The default implementation in this class uses a finite difference approximation */ + virtual void assembleGradient(const typename Basis::LocalView& localView, + const std::vector<TargetSpace>& solution, + std::vector<typename TargetSpace::TangentVector>& gradient) const = 0; + +}; + +} // namespace GFE + +} // namespace Dune + +#endif // DUNE_GFE_LOCALFIRSTORDERMODEL_HH + diff --git a/dune/gfe/rodassembler.hh b/dune/gfe/rodassembler.hh index ffc5d222..cf93563f 100644 --- a/dune/gfe/rodassembler.hh +++ b/dune/gfe/rodassembler.hh @@ -8,6 +8,7 @@ #include <dune/fufem/boundarypatch.hh> +#include <dune/gfe/localgeodesicfefdstiffness.hh> #include "rigidbodymotion.hh" #include "rodlocalstiffness.hh" #include "geodesicfeassembler.hh" @@ -41,8 +42,11 @@ public: //! ??? RodAssembler(const Basis& basis, RodLocalStiffness<GridView,double>* localStiffness) - : GeodesicFEAssembler<Basis, RigidBodyMotion<double,3> >(basis,localStiffness) + : GeodesicFEAssembler<Basis, RigidBodyMotion<double,3> >(basis,nullptr) + , rodEnergy_(localStiffness) { + this->localStiffness_ = new LocalGeodesicFEFDStiffness<Basis,RigidBodyMotion<double,3>, double>(localStiffness); + std::vector<RigidBodyMotion<double,3> > referenceConfiguration(basis.size()); for (const auto vertex : Dune::vertices(basis.gridView())) @@ -55,11 +59,12 @@ public: referenceConfiguration[idx].q = Rotation<double,3>::identity(); } - dynamic_cast<RodLocalStiffness<GridView, double>* >(this->localStiffness_)->setReferenceConfiguration(referenceConfiguration); + rodEnergy_->setReferenceConfiguration(referenceConfiguration); } std::vector<RigidBodyMotion<double,3> > getRefConfig() - { return dynamic_cast<RodLocalStiffness<GridView, double>* >(this->localStiffness_)->referenceConfiguration_; + { + return rodEnergy_->referenceConfiguration_; } virtual void assembleGradient(const std::vector<RigidBodyMotion<double,3> >& sol, @@ -78,6 +83,7 @@ public: Dune::FieldVector<double,6> getResultantForce(const BoundaryPatch<PatchGridView>& boundary, const std::vector<RigidBodyMotion<double,3> >& sol) const; + RodLocalStiffness<GridView,double>* rodEnergy_; }; // end class diff --git a/dune/gfe/rodlocalstiffness.hh b/dune/gfe/rodlocalstiffness.hh index 508e18f0..5157a30e 100644 --- a/dune/gfe/rodlocalstiffness.hh +++ b/dune/gfe/rodlocalstiffness.hh @@ -9,12 +9,12 @@ #include <dune/functions/functionspacebases/lagrangebasis.hh> -#include "localgeodesicfestiffness.hh" +#include <dune/gfe/localfirstordermodel.hh> #include "rigidbodymotion.hh" template<class GridView, class RT> class RodLocalStiffness - : public LocalGeodesicFEStiffness<Dune::Functions::LagrangeBasis<GridView,1>, RigidBodyMotion<RT,3> > +: public Dune::GFE::LocalFirstOrderModel<Dune::Functions::LagrangeBasis<GridView,1>, RigidBodyMotion<RT,3> > { typedef RigidBodyMotion<RT,3> TargetSpace; typedef Dune::Functions::LagrangeBasis<GridView,1> Basis; -- GitLab