#ifndef DUNE_ELASTICITY_MATERIALS_LOCALINTEGRALENERGY_HH #define DUNE_ELASTICITY_MATERIALS_LOCALINTEGRALENERGY_HH #include #include #include #include #include namespace Dune::Elasticity { template class LocalIntegralEnergy : public Elasticity::LocalEnergy>> { // grid types using DT = typename GridView::Grid::ctype; using Entity = typename GridView::template Codim<0>::Entity; // some other sizes enum {gridDim=GridView::dimension}; enum {dim=GridView::dimension}; public: /** \brief Constructor with a local energy density */ LocalIntegralEnergy(const std::shared_ptr>& ld) : localDensity_(ld) {} /** \brief Virtual destructor */ virtual ~LocalIntegralEnergy() {} /** \brief Assemble the energy for a single element */ field_type energy (const Entity& e, const LocalFiniteElement& localFiniteElement, const std::vector >& localConfiguration) const; protected: const std::shared_ptr> localDensity_ = nullptr; }; template field_type LocalIntegralEnergy:: energy(const Entity& element, const LocalFiniteElement& localFiniteElement, const std::vector >& localConfiguration) const { assert(element.type() == localFiniteElement.type()); field_type energy = 0; // store gradients of shape functions and base functions std::vector > referenceGradients(localFiniteElement.size()); std::vector > gradients(localFiniteElement.size()); int quadOrder = (element.type().isSimplex()) ? localFiniteElement.localBasis().order() : localFiniteElement.localBasis().order() * gridDim; const auto& quad = Dune::QuadratureRules::rule(element.type(), quadOrder); for (const auto& qp : quad) { const DT integrationElement = element.geometry().integrationElement(qp.position()); const auto jacobianInverseTransposed = element.geometry().jacobianInverseTransposed(qp.position()); // Global position auto x = element.geometry().global(qp.position()); // Get gradients of shape functions localFiniteElement.localBasis().evaluateJacobian(qp.position(), referenceGradients); // compute gradients of base functions for (size_t i=0; i deformationGradient(0); for (size_t i=0; i