18#include "dune/common/config.h"
19#include "dune/common/fmatrix.hh"
20#include "dune/grid/config.h"
26#include "linalg/determinant.hh"
32 namespace Elastomechanics
76 double shear()
const {
return mu; }
79 double bulk()
const {
return lambda + 2*mu/3; }
82 double young()
const {
return mu*(3*lambda+2*mu)/(lambda+mu); }
85 double lame()
const {
return lambda; }
88 double poisson()
const {
return lambda/2/(lambda+mu); }
102 static std::map<std::string,ElasticModulus>
const&
materials();
122 namespace ElastoDetails
125 constexpr int dim(
int n) {
return (
sqrti(1+8*n)-1)/2; }
150 template <
class Scalar,
int n>
162 template <
class Scalar,
int n>
172 template <
int d,
class Scalar>
175 return s - (
trace(s)/d) * unitMatrix<Scalar,d>();
187 template <
int dim,
class Scalar>
219 double d0()
const {
return f; }
220 double d1(
double dx)
const {
return df*dx; }
221 double d2(
double dx1,
double dx2)
const {
return ddf*dx1*dx2; }
246 template <
int dim,
class Scalar=
double>
278 template <
class Scalar,
int dim,
bool byValue=true>
325 std::conditional_t<byValue,Tensor,Tensor const&> du;
339 template <
class Scalar,
int dim,
bool byValue=true>
357 [[gnu::deprecated(
"create a new LinearizedGreenLagrangeTensor if needed")]]
383 std::conditional_t<byValue,Tensor,Tensor const&> du;
396 template <
class Scalar,
int dim,
bool byValue=true>
409 for(
int i=0; i < dim; ++i)
421 for(
int i=0; i < dim; ++i)
446 std::conditional_t<byValue,InputTensor,InputTensor const&> du;
459 template <
class Scalar,
int dim,
bool byValue=true>
519 for(
int i=0; i < dim+1; i++)
520 for(
int j=0; j < dim; j++)
521 dext[i][j] = d[i][j];
523 dext[0][dim] = -dext[dim][0];
524 dext[1][dim] = -dext[dim][1];
528 std::conditional_t<byValue,InputTensor,InputTensor const&> du;
550 template <
int dim,
class Scalar=
double>
574 return E + z.
d0()*(E +
static_cast<Scalar
>(0.5)*unitMatrix<Scalar,dim>());
583 return dE + z.
d1(det.d1(2*dE))*(E +
static_cast<Scalar
>(0.5)*unitMatrix<Scalar,dim>()) + z.
d0()*dE;
592 return z.
d2(det.d1(2*dE1,2*dE2))*(E +
static_cast<Scalar
>(0.5)*unitMatrix<Scalar,dim>()) + z.
d1(det.d1(2*dE1))*dE2 + z.
d1(det.d1(2*dE2))*dE1;
619 template <
class Displacement,
class StrainTensor>
623 using Space =
typename Displacement::Space;
642 return StrainTensor(u.derivative(evaluator)).d0();
646 Displacement
const& u;
653 template <
class Displacement>
663 template <
class Displacement>
677 template <
class Real,
int dim>
684 namespace Elasto_Details {
686 template <
class Real,
int n>
689 template <
class Function>
696 template <
class Cell,
class QuadraturePo
int,
class Evaluator>
697 void operator()(
Cell const&, QuadraturePoint
const&, Evaluator
const& eval) {
698 auto yx = y.derivative(eval);
699 auto dyx = dy.derivative(eval);
703 std::cerr <<
"#### AIEEE: given determinant nonpositive: " << tmp <<
" !\n";
706 while (step>0 &&
determinant(I+yx+step*dyx)<epsilon*tmp)
707 step = 0.7*step - 1e-4;
709 for (
int i=1; i<10; ++i)
711 std::cerr <<
"##### Aieee: at step " << step <<
" * " << i <<
"/10 we have " <<
determinant(I+yx+i*step/10*dyx) <<
" < " << epsilon*tmp <<
"\n";
714 template <
class Evaluator>
715 int order(Evaluator
const& eval)
const {
return y.order(eval); }
718 double epsilon, step, mindet;
733 template <
class Function>
737 Elasto_Details::Limiter<Function> g(y,dy,epsilon);
739 std::cout <<
"minimal determinant: " << g.mindet <<
"\n";
747 using namespace Elastomechanics;
Function is the interface for evaluatable functions .
static int const components
A class for computing determinants and their derivatives.
Scalar d2(Matrix const &dA1, Matrix const &dA2) const
DetIpm1(Matrix const &A_)
Scalar d1(Matrix const &dA) const
Material parameters for isotropic linearly elastic materials.
double poisson() const
Returns Poisson's ratio .
ElasticModulus(double lambda_, double mu_)
Constructor expects first and second Lame parameters .
double shear() const
Returns the shear modulus , also known as Lame's second parameter .
static std::map< std::string, ElasticModulus > const & materials()
A map from known material names to elastic moduli.
ElasticModulus(std::string const &name)
Constructs elastic modulus by material lookup.
double bulk() const
Returns the bulk modulus .
ElasticModulus()
Default constructor uses (pretty useless "unit square" material).
double lame() const
Returns the first Lame parameter .
double young() const
Returns the Young's modulus .
static ElasticModulus const & material(std::string const &name)
Returns the material parameters of the given materials.
ElasticModulus & setYoungPoisson(double E, double nu)
Define material properties in terms of Young's modulus and Poisson's ratio .
Full (right) Green-Lagrange strain tensor for displacements from dim-1 to dim.
Dune::FieldMatrix< Scalar, dim+1, dim+1 > OutputTensor
OutputTensor d0() const
The linearized Green-Lagrange strain tensor .
Dune::FieldMatrix< Scalar, dim+1, dim > InputTensor
ExtendedGreenLagrangeTensor(InputTensor const &du_)
Constructor.
ExtendedGreenLagrangeTensor()
Default constructor. This initializes the displacement derivative to 0, i.e. to the reference configu...
OutputTensor d2(InputTensor const &dv, InputTensor const &dw) const
The second derivative of the linearized Green-Lagrange strain tensor in direction dv,...
OutputTensor d1(InputTensor const &dv) const
The first derivative of the linearized Green-Lagrange strain tensor in direction dv.
Full (right) Green-Lagrange strain tensor, the workhorse of hyperelasticity.
Tensor d1(Tensor const &dv) const
The first derivative of the linearized Green-Lagrange strain tensor in direction dv.
Tensor d2(Tensor const &dv, Tensor const &dw) const
The second derivative of the linearized Green-Lagrange strain tensor in direction dv,...
Tensor d0() const
The linearized Green-Lagrange strain tensor .
GreenLagrangeTensor(Tensor const &du_)
Constructor.
GreenLagrangeTensor()
Default constructor. This initializes the displacement derivative to 0, i.e. to the reference configu...
Dune::FieldMatrix< Scalar, dim, dim > Tensor
void setDisplacementDerivative(Tensor const &du_)
Isochoric part of the full (right) Green-Lagrange strain tensor, used in compressible hyperelasticity...
IsochoricGreenLagrangeTensor(Tensor const &E_)
Constructor.
DetIpm1< dim, Scalar > const & determinant() const
The shifted determinant of the original Green Lagrange strain tensor.
Dune::FieldMatrix< Scalar, dim, dim > Tensor
IsochoricGreenLagrangeTensor()
Default constructor. This initializes the strain tensor to 0, i.e. to the reference configuration.
Tensor d0() const
The isochoric linearized Green-Lagrange strain tensor .
Tensor d2(Tensor const &dE1, Tensor const &dE2) const
The second derivative of the linearized Green-Lagrange strain tensor in direction dv,...
Tensor d1(Tensor const &dE) const
The first derivative of the linearized Green-Lagrange strain tensor in direction de.
Linearized (right) Green-Lagrange strain tensor, the workhorse of linear elastomechanics.
Tensor d2(Tensor const &, Tensor const &) const
The second derivative of the linearized Green-Lagrange strain tensor in direction dv,...
LinearizedGreenLagrangeTensor()
Default constructor. This initializes the displacement derivative to 0, i.e. to the reference configu...
Dune::FieldMatrix< Scalar, dim, dim > Tensor
The type of displacement derivatives.
void setDisplacementDerivative(Tensor const &du_)
Tensor d0() const
The linearized Green-Lagrange strain tensor .
LinearizedGreenLagrangeTensor(Tensor const &du_)
Constructor.
Tensor d1(Tensor const &dv) const
The first derivative of the linearized Green-Lagrange strain tensor in direction dv.
Numerically stable evaluation of .
double d1(double dx) const
Pstable(double p_, double x_)
Constructor.
double d2(double dx1, double dx2) const
A class for shifted invariants of a tensor.
Invariants d1(Tensor const &dA) const
ShiftedInvariants(Tensor const &A_)
DetIpm1< dim, Scalar > det
Invariants d2(Tensor const &dA1, Tensor const &dA2) const
A function view that provides on the fly computed strain tensors of displacemnts.
typename StrainTensor::Tensor ValueType
Space const & space() const
ValueType value(typename Space::Evaluator const &evaluator) const
typename Displacement::Space Space
StrainView(Displacement const &u_)
Constructor.
Full (right) Green-Lagrange strain tensor for displacements from dim-1 to dim.
Dune::FieldMatrix< Scalar, dim+1, dim > InputTensor
OutputTensor d1(InputTensor const &dv) const
The first derivative of the linearized Green-Lagrange strain tensor in direction dv.
OutputTensor d0() const
The linearized Green-Lagrange strain tensor .
Dune::FieldMatrix< Scalar, dim, dim > OutputTensor
OutputTensor d2(InputTensor const &dv, InputTensor const &dw) const
The second derivative of the linearized Green-Lagrange strain tensor in direction dv,...
SurfaceGreenLagrangeTensor()
Default constructor. This initializes the displacement derivative to 0, i.e. to the reference configu...
SurfaceGreenLagrangeTensor(InputTensor const &du_)
Constructor.
A class for representing tensors of arbitrary static rank and extents.
This file contains various utility functions that augment the basic functionality of Dune.
Dune::FieldMatrix< Scalar, d, d > deviatoricPart(Dune::FieldMatrix< Scalar, d, d > const &s)
The deviatoric part of a tensor.
Dune::FieldVector< Scalar, n *(n+1)/2 > pack(Dune::FieldMatrix< Scalar, n, n > const &e, Scalar s=2.0)
Returns the Voigt vector representation of a symmetric matrix (with or without doubled off-diagonal e...
Dune::FieldMatrix< Scalar, ElastoDetails::dim(n), ElastoDetails::dim(n)> unpack(Dune::FieldVector< Scalar, n > const &c, Scalar s=2.0)
Returns the symmetric matrix representation of a Voigt vector with or without doubled off-diagonal en...
void forEachQP(Functor &g, Space const &space)
Loops over the whole domain occupied by the grid and calls the functor g for each integration point w...
typename GridView::template Codim< 0 >::Entity Cell
The type of cells (entities of codimension 0) in the grid view.
T trace(Dune::FieldMatrix< T, n, n > const &A)
Matrix trace .
Dune::FieldVector< T, n > max(Dune::FieldVector< T, n > x, Dune::FieldVector< T, n > const &y)
Componentwise maximum.
Dune::FieldMatrix< T, n, n > unitMatrix()
Returns the identity matrix of size n .
T determinant(Dune::FieldMatrix< T, n, n > const &A)
Matrix determinant .
Dune::FieldVector< T, n > min(Dune::FieldVector< T, n > x, Dune::FieldVector< T, n > const &y)
Componentwise minimum.
std::array< Dune::FieldVector< Real, dim >, dim > principalDirections(Dune::FieldMatrix< Real, dim, dim > const &A)
Computes the dim principal directions of the symmetric positive definite tensor A.
auto makeGreenLagrangeStrainView(Displacement const &u)
A convenience function for creating function views for full Green-Lagrange strain tensors.
double orientationPreservingStepsize(Function const &y, Function const &dy, double epsilon)
Computes the maximal orientation preserving stepsize.
auto makeLinearizedGreenLagrangeStrainView(Displacement const &u)
A convenience function for creating function views for linearized Green-Lagrange strain tensors.
constexpr int sqrti(int n)
Computes floor(sqrt(n)) for integers n at compile time.
double yieldStrength(std::string const &name)
Yield strengths of several materials in Pa.
Functionalities for integration of FunctionSpaceElement s or FunctionViews.