Skip to content
Snippets Groups Projects
Commit 1ce42282 authored by Lisa Julia Nebel's avatar Lisa Julia Nebel
Browse files

Add a StressFreeStateGridFunction to nonplanarcosseratshellenergy

The StressFreeStateGridFunction is the actual parametrization from the grid to the
nonplanar Cosserat shell in stress-free state.
The geometries of the StressFreeStateGridFunction will then be used for all calculations
instead of the linear geometries of the piecewise linear grid.
parent 01dfd15f
No related branches found
No related tags found
1 merge request!72Cosserat-Continuum-Nonplanar
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include <dune/fufem/boundarypatch.hh> #include <dune/fufem/boundarypatch.hh>
#include <dune/functions/gridfunctions/discreteglobalbasisfunction.hh>
#include <dune/gfe/localenergy.hh> #include <dune/gfe/localenergy.hh>
#include <dune/gfe/localgeodesicfefunction.hh> #include <dune/gfe/localgeodesicfefunction.hh>
#include <dune/gfe/rigidbodymotion.hh> #include <dune/gfe/rigidbodymotion.hh>
...@@ -21,7 +23,15 @@ ...@@ -21,7 +23,15 @@
#include <dune/localfunctions/lagrange/lfecache.hh> #include <dune/localfunctions/lagrange/lfecache.hh>
#endif #endif
template<class Basis, int dim, class field_type=double> /** \brief Assembles the cosserat energy for a single element.
*
* \tparam Basis Type of the Basis used for assembling
* \tparam dim Dimension of the Targetspace, 3
* \tparam field_type The coordinate type of the TargetSpace
* \tparam StressFreeStateGridFunction Type of the GridFunction representing the Cosserat shell in a stress free state
*/
template<class Basis, int dim, class field_type=double, class StressFreeStateGridFunction =
Dune::Functions::DiscreteGlobalBasisFunction<Basis,std::vector<Dune::FieldVector<double, Basis::GridView::dimensionworld>> > >
class NonplanarCosseratShellEnergy class NonplanarCosseratShellEnergy
: public Dune::GFE::LocalEnergy<Basis,RigidBodyMotion<field_type,dim> > : public Dune::GFE::LocalEnergy<Basis,RigidBodyMotion<field_type,dim> >
{ {
...@@ -40,13 +50,16 @@ class NonplanarCosseratShellEnergy ...@@ -40,13 +50,16 @@ class NonplanarCosseratShellEnergy
public: public:
/** \brief Constructor with a set of material parameters /** \brief Constructor with a set of material parameters
* \param parameters The material parameters * \param parameters The material parameters
* \param stressFreeStateGridFunction Pointer to a parametrization representing the Cosserat shell in a stress-free state
*/ */
NonplanarCosseratShellEnergy(const Dune::ParameterTree& parameters, NonplanarCosseratShellEnergy(const Dune::ParameterTree& parameters,
const StressFreeStateGridFunction* stressFreeStateGridFunction,
const BoundaryPatch<GridView>* neumannBoundary, const BoundaryPatch<GridView>* neumannBoundary,
const std::function<Dune::FieldVector<double,3>(Dune::FieldVector<double,dimworld>)> neumannFunction, const std::function<Dune::FieldVector<double,3>(Dune::FieldVector<double,dimworld>)> neumannFunction,
const std::function<Dune::FieldVector<double,3>(Dune::FieldVector<double,dimworld>)> volumeLoad) const std::function<Dune::FieldVector<double,3>(Dune::FieldVector<double,dimworld>)> volumeLoad)
: neumannBoundary_(neumannBoundary), : stressFreeStateGridFunction_(stressFreeStateGridFunction),
neumannBoundary_(neumannBoundary),
neumannFunction_(neumannFunction), neumannFunction_(neumannFunction),
volumeLoad_(volumeLoad) volumeLoad_(volumeLoad)
{ {
...@@ -111,6 +124,9 @@ public: ...@@ -111,6 +124,9 @@ public:
/** \brief Curvature parameters */ /** \brief Curvature parameters */
double b1_, b2_, b3_; double b1_, b2_, b3_;
/** \brief The geometry used for assembling */
const StressFreeStateGridFunction* stressFreeStateGridFunction_;
/** \brief The Neumann boundary */ /** \brief The Neumann boundary */
const BoundaryPatch<GridView>* neumannBoundary_; const BoundaryPatch<GridView>* neumannBoundary_;
...@@ -121,15 +137,34 @@ public: ...@@ -121,15 +137,34 @@ public:
const std::function<Dune::FieldVector<double,3>(Dune::FieldVector<double,dimworld>)> volumeLoad_; const std::function<Dune::FieldVector<double,3>(Dune::FieldVector<double,dimworld>)> volumeLoad_;
}; };
template <class Basis, int dim, class field_type> template <class Basis, int dim, class field_type, class StressFreeStateGridFunction>
typename NonplanarCosseratShellEnergy<Basis,dim,field_type>::RT typename NonplanarCosseratShellEnergy<Basis, dim, field_type, StressFreeStateGridFunction>::RT
NonplanarCosseratShellEnergy<Basis,dim,field_type>:: NonplanarCosseratShellEnergy<Basis,dim,field_type, StressFreeStateGridFunction>::
energy(const typename Basis::LocalView& localView, energy(const typename Basis::LocalView& localView,
const std::vector<RigidBodyMotion<field_type,dim> >& localSolution) const const std::vector<RigidBodyMotion<field_type,dim> >& localSolution) const
{ {
// The element geometry // The element geometry
auto element = localView.element(); auto element = localView.element();
#if HAVE_DUNE_CURVEDGEOMETRY
// Construct a curved geometry of this element of the Cosserat shell in stress-free state
// When using element.geometry(), then the curvatures on the element are zero, when using a curved geometry, they are not
// If a parametrization representing the Cosserat shell in a stress-free state is given,
// this is used for the curved geometry approximation.
// The variable local holds the local coordinates in the reference element
// and localGeometry.global maps them to the world coordinates
Dune::CurvedGeometry<DT, gridDim, dimworld, Dune::CurvedGeometryTraits<DT, Dune::LagrangeLFECache<DT,DT,gridDim>>> geometry(referenceElement(element),
[this,element](const auto& local) {
if (not stressFreeStateGridFunction_) {
return element.geometry().global(local);
}
auto localGridFunction = localFunction(*stressFreeStateGridFunction_);
localGridFunction.bind(element);
return localGridFunction(local);
}, 2); /*order*/
#else
auto geometry = element.geometry(); auto geometry = element.geometry();
#endif
// The set of shape functions on this element // The set of shape functions on this element
const auto& localFiniteElement = localView.tree().finiteElement(); const auto& localFiniteElement = localView.tree().finiteElement();
...@@ -215,17 +250,8 @@ energy(const typename Basis::LocalView& localView, ...@@ -215,17 +250,8 @@ energy(const typename Basis::LocalView& localView,
c += aScalar * eps[alpha][beta] * Dune::GFE::dyadicProduct(aContravariant[alpha], aContravariant[beta]); c += aScalar * eps[alpha][beta] * Dune::GFE::dyadicProduct(aContravariant[alpha], aContravariant[beta]);
#if HAVE_DUNE_CURVEDGEOMETRY #if HAVE_DUNE_CURVEDGEOMETRY
// Construct a curved geometry to evaluate the derivative of the normal field on each quadrature point // Second fundamental form: The derivative of the normal field, on each quadrature point
// The variable local holds the local coordinates in the reference element auto normalDerivative = geometry.normalGradient(quad[pt].position());
// and localGeometry.global maps them to the world coordinates
// we want to take the derivative of the normal field on the element in world coordinates
Dune::CurvedGeometry<DT, gridDim, dimworld, Dune::CurvedGeometryTraits<DT, Dune::LagrangeLFECache<DT,DT,gridDim>>> curvedGeometry(referenceElement(element),
[localGeometry=element.geometry()](const auto& local) {
return localGeometry.global(local);
}, 1); //order = 1
// Second fundamental form: The derivative of the normal field
auto normalDerivative = curvedGeometry.normalGradient(quad[pt].position());
#else #else
//In case dune-curvedgeometry is not installed, the normal derivative is set to zero. //In case dune-curvedgeometry is not installed, the normal derivative is set to zero.
Dune::FieldMatrix<double,3,3> normalDerivative(0); Dune::FieldMatrix<double,3,3> normalDerivative(0);
......
...@@ -424,6 +424,7 @@ int main (int argc, char *argv[]) try ...@@ -424,6 +424,7 @@ int main (int argc, char *argv[]) try
else else
{ {
localCosseratEnergy = std::make_shared<NonplanarCosseratShellEnergy<FEBasis,3,adouble> >(materialParameters, localCosseratEnergy = std::make_shared<NonplanarCosseratShellEnergy<FEBasis,3,adouble> >(materialParameters,
nullptr,
&neumannBoundary, &neumannBoundary,
neumannFunction, neumannFunction,
volumeLoad); volumeLoad);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment