KASKADE 7 development version
elasto.hh
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the library KASKADE 7 */
4/* https://www.zib.de/research/projects/kaskade7-finite-element-toolbox */
5/* */
6/* Copyright (C) 2012-2023 Zuse Institute Berlin */
7/* */
8/* KASKADE 7 is distributed under the terms of the ZIB Academic License. */
9/* see $KASKADE/academic.txt */
10/* */
11/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12
13#ifndef ELASTO_HH
14#define ELASTO_HH
15
16#include <cassert>
17
18#include "dune/common/config.h"
19#include "dune/common/fmatrix.hh"
20#include "dune/grid/config.h"
21
23#include "fem/fixdune.hh"
24#include "fem/integration.hh"
25
26#include "linalg/determinant.hh"
27
28#include "utilities/power.hh"
29
30namespace Kaskade
31{
32 namespace Elastomechanics
33 {
46 // ---------------------------------------------------------------------------------------------------------
47
53 {
54 public:
56 ElasticModulus(): lambda(1), mu(1) {}
57
59 ElasticModulus(double lambda_, double mu_): lambda(lambda_), mu(mu_) {}
60
64 ElasticModulus(std::string const& name)
66 {}
67
73 ElasticModulus& setYoungPoisson(double E, double nu);
74
76 double shear() const { return mu; }
77
79 double bulk() const { return lambda + 2*mu/3; }
80
82 double young() const { return mu*(3*lambda+2*mu)/(lambda+mu); }
83
85 double lame() const { return lambda; }
86
88 double poisson() const { return lambda/2/(lambda+mu); }
89
95 static ElasticModulus const& material(std::string const& name);
96
102 static std::map<std::string,ElasticModulus> const& materials();
103
104 private:
105 double lambda, mu;
106 };
107
114 double yieldStrength(std::string const& name);
115
116
117 // ---------------------------------------------------------------------------------------------------------
118
122 namespace ElastoDetails
123 {
124 // Computes the dimension of a matrix from the length of its Voigt representation vector.
125 constexpr int dim(int n) { return (sqrti(1+8*n)-1)/2; }
126 }
131 // ---------------------------------------------------------------------------------------------------------
132
150 template <class Scalar, int n>
151 Dune::FieldVector<Scalar,n*(n+1)/2> pack(Dune::FieldMatrix<Scalar,n,n> const& e, Scalar s=2.0);
152
162 template <class Scalar, int n>
163 Dune::FieldMatrix<Scalar,ElastoDetails::dim(n),ElastoDetails::dim(n)> unpack(Dune::FieldVector<Scalar,n> const& c, Scalar s=2.0);
164
172 template <int d, class Scalar>
174 {
175 return s - (trace(s)/d) * unitMatrix<Scalar,d>();
176 }
177
178 // --------------------------------------------------------------------------------------------
179
187 template <int dim, class Scalar>
189 {
190 public:
192
193 DetIpm1(Matrix const& A_): A(A_) {}
194
195 Scalar d0() const;
196 Scalar d1(Matrix const& dA) const;
197 Scalar d2(Matrix const& dA1, Matrix const& dA2) const;
198 private:
199 Matrix A;
200 };
201
211 {
212 public:
218 Pstable(double p_, double x_);
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; }
222 private:
223 double f, df, ddf;
224 };
225
226 // --------------------------------------------------------------------------------------------
227
246 template <int dim, class Scalar=double>
248 {
249 public:
252
253 ShiftedInvariants(Tensor const& A_): A(A_), det(A) {}
254 Invariants d0() const;
255 Invariants d1(Tensor const& dA) const;
256 Invariants d2(Tensor const& dA1, Tensor const& dA2) const;
257
258 public:
261 };
262
263 // --------------------------------------------------------------------------------------------
264
278 template <class Scalar, int dim, bool byValue=true>
280 {
281 public:
286
291 explicit LinearizedGreenLagrangeTensor(Tensor const& du_): du(du_) {}
292
298
299
301 {
302 du = du_;
303 }
304
308 Tensor d0() const { return static_cast<Scalar>(0.5)*(du+transpose(du)); }
309
315 Tensor d1(Tensor const& dv) const { return static_cast<Scalar>(0.5)*(dv+transpose(dv)); }
316
322 Tensor d2(Tensor const&, Tensor const&) const { return Tensor(0.0); }
323
324 private:
325 std::conditional_t<byValue,Tensor,Tensor const&> du;
326 };
327
339 template <class Scalar, int dim, bool byValue=true>
341 {
342 public:
344
349 GreenLagrangeTensor(Tensor const& du_): du(du_) {}
350
356
357 [[gnu::deprecated("create a new LinearizedGreenLagrangeTensor if needed")]]
359 {
360 du = du_;
361 }
362
366 Tensor d0() const { return static_cast<Scalar>(0.5)*(du+transpose(du)+transpose(du)*du); }
367
373 Tensor d1(Tensor const& dv) const { return static_cast<Scalar>(0.5)*(dv+transpose(dv)+transpose(dv)*du + transpose(du)*dv); }
374
380 Tensor d2(Tensor const& dv, Tensor const& dw) const { return static_cast<Scalar>(0.5)*(transpose(dv)*dw + transpose(dw)*dv); }
381
382 private:
383 std::conditional_t<byValue,Tensor,Tensor const&> du;
384 };
385
386
396 template <class Scalar, int dim, bool byValue=true>
398 {
399 public:
402
407 SurfaceGreenLagrangeTensor(InputTensor const& du_): du(du_), dI(0)
408 {
409 for(int i=0; i < dim; ++i)
410 dI[i][i] = 1;
411// std::cout << "dI=" << dI << "\n";
412// std::cout << "transpose(dI)=" << transpose(dI) << "\n";
413 }
414
420 {
421 for(int i=0; i < dim; ++i)
422 dI[i][i] = 1;
423 }
424
425
429 OutputTensor d0() const { return static_cast<Scalar>(0.5)*(transpose(dI)*du+transpose(du)*dI+transpose(du)*du); }
430
436 OutputTensor d1(InputTensor const& dv) const { return static_cast<Scalar>(0.5)*(transpose(dI)*dv+transpose(dv)*dI+transpose(dv)*du + transpose(du)*dv); }
437
443 OutputTensor d2(InputTensor const& dv, InputTensor const& dw) const { return static_cast<Scalar>(0.5)*(transpose(dv)*dw + transpose(dw)*dv); }
444
445 private:
446 std::conditional_t<byValue,InputTensor,InputTensor const&> du;
447 InputTensor dI;
448 };
449
459 template <class Scalar, int dim, bool byValue=true>
461 {
462 public:
465
470 ExtendedGreenLagrangeTensor(InputTensor const& du_): du(du_), duext(extend(du_))
471 {
472 }
473
478 ExtendedGreenLagrangeTensor(): du(0), duext(0)
479 {
480 }
481
482
487 {
488 return static_cast<Scalar>(0.5)*(duext+transpose(duext)+transpose(duext)*duext);
489 }
490
496 OutputTensor d1(InputTensor const& dv) const
497 {
498 OutputTensor dvext = extend(dv);
499 return static_cast<Scalar>(0.5)*(dvext+transpose(dvext)+transpose(dvext)*duext + transpose(duext)*dvext);
500 }
501
507 OutputTensor d2(InputTensor const& dv, InputTensor const& dw) const
508 {
509 OutputTensor dvext = extend(dv);
510 OutputTensor dwext = extend(dw);
511 return static_cast<Scalar>(0.5)*(transpose(dvext)*dwext + transpose(dwext)*dvext);
512 }
513
514 private:
515
516 OutputTensor extend(InputTensor const& d) const
517 {
518 OutputTensor dext(0);
519 for(int i=0; i < dim+1; i++)
520 for(int j=0; j < dim; j++)
521 dext[i][j] = d[i][j];
522
523 dext[0][dim] = -dext[dim][0];
524 dext[1][dim] = -dext[dim][1];
525 return dext;
526 }
527
528 std::conditional_t<byValue,InputTensor,InputTensor const&> du;
529 OutputTensor duext;
530 };
531
532
550 template <int dim, class Scalar=double>
552 {
553 public:
555
560 IsochoricGreenLagrangeTensor(Tensor const& E_): E(E_), det(2*E), z(-1.0/dim,det.d0())
561 {
562 }
563
568 IsochoricGreenLagrangeTensor(): E(0), z(0.0,0.0) {}
569
573 Tensor d0() const {
574 return E + z.d0()*(E + static_cast<Scalar>(0.5)*unitMatrix<Scalar,dim>());
575 }
576
581 Tensor d1(Tensor const& dE) const
582 {
583 return dE + z.d1(det.d1(2*dE))*(E + static_cast<Scalar>(0.5)*unitMatrix<Scalar,dim>()) + z.d0()*dE;
584 }
585
590 Tensor d2(Tensor const& dE1, Tensor const& dE2) const
591 {
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;
593 }
594
599 {
600 return det;
601 }
602
603 private:
604 Tensor E;
606 Pstable z;
607 };
608
609 // --------------------------------------------------------------------------------------------
610
611
619 template <class Displacement, class StrainTensor>
621 {
622 public:
623 using Space = typename Displacement::Space;
624 using ValueType = typename StrainTensor::Tensor;
625
626
632 StrainView(Displacement const& u_)
633 : u(u_) {}
634
635 Space const& space() const
636 {
637 return u.space();
638 }
639
640 ValueType value(typename Space::Evaluator const& evaluator) const
641 {
642 return StrainTensor(u.derivative(evaluator)).d0();
643 }
644
645 private:
646 Displacement const& u;
647 };
648
653 template <class Displacement>
654 auto makeLinearizedGreenLagrangeStrainView(Displacement const& u)
655 {
657 }
658
663 template <class Displacement>
664 auto makeGreenLagrangeStrainView(Displacement const& u)
665 {
667 }
668
669 // ---------------------------------------------------------------------------------------------------------
670
677 template <class Real, int dim>
678 std::array<Dune::FieldVector<Real,dim>,dim> principalDirections(Dune::FieldMatrix<Real,dim,dim> const& A);
679
680 // ---------------------------------------------------------------------------------------------------------
681
682
684 namespace Elasto_Details {
685
686 template <class Real, int n>
687 Real maxOrientationPreservingStepsize(Dune::FieldMatrix<Real,n,n> const& A, Dune::FieldMatrix<Real,n,n> const& dA, Real eps);
688
689 template <class Function>
690 struct Limiter {
691 static int const dim = Function::components;
692
693 Limiter(Function const& y_, Function const& dy_, double epsilon_)
694 : y(y_), dy(dy_), epsilon(epsilon_), step(1), I(unitMatrix<typename Function::Scalar,dim>()) { mindet = std::numeric_limits<double>::max(); }
695
696 template <class Cell, class QuadraturePoint, class Evaluator>
697 void operator()(Cell const&, QuadraturePoint const&, Evaluator const& eval) {
698 auto yx = y.derivative(eval);
699 auto dyx = dy.derivative(eval);
700 auto tmp = determinant(I+yx);
701
702 if (tmp <= 0)
703 std::cerr << "#### AIEEE: given determinant nonpositive: " << tmp << " !\n";
704
705 mindet = std::min(mindet,tmp);
706 while (step>0 && determinant(I+yx+step*dyx)<epsilon*tmp)
707 step = 0.7*step - 1e-4;
708
709 for (int i=1; i<10; ++i)
710 if (determinant(I+yx+i*step/10*dyx)<epsilon*tmp)
711 std::cerr << "##### Aieee: at step " << step << " * " << i << "/10 we have " << determinant(I+yx+i*step/10*dyx) << " < " << epsilon*tmp << "\n";
712 }
713
714 template <class Evaluator>
715 int order(Evaluator const& eval) const { return y.order(eval); }
716
717 Function const& y, dy;
718 double epsilon, step, mindet;
720 };
721
722 }
724
733 template <class Function>
734 double orientationPreservingStepsize(Function const& y, Function const& dy, double epsilon)
735 {
736
737 Elasto_Details::Limiter<Function> g(y,dy,epsilon);
738 forEachQP(g,y.space());
739 std::cout << "minimal determinant: " << g.mindet << "\n";
740 return std::max(g.step,0.0);
741 }
742
743 // ---------------------------------------------------------------------------------------------------------
744 }
745
746 // TODO: remove this backwards compatibility hack as soon as all users switched over
747 using namespace Elastomechanics;
748
749}
750
751
752
753
754#endif
Function is the interface for evaluatable functions .
Definition: concepts.hh:324
static int const components
Definition: concepts.hh:335
A class for computing determinants and their derivatives.
Definition: elasto.hh:189
Scalar d2(Matrix const &dA1, Matrix const &dA2) const
DetIpm1(Matrix const &A_)
Definition: elasto.hh:193
Scalar d1(Matrix const &dA) const
Material parameters for isotropic linearly elastic materials.
Definition: elasto.hh:53
double poisson() const
Returns Poisson's ratio .
Definition: elasto.hh:88
ElasticModulus(double lambda_, double mu_)
Constructor expects first and second Lame parameters .
Definition: elasto.hh:59
double shear() const
Returns the shear modulus , also known as Lame's second parameter .
Definition: elasto.hh:76
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.
Definition: elasto.hh:64
double bulk() const
Returns the bulk modulus .
Definition: elasto.hh:79
ElasticModulus()
Default constructor uses (pretty useless "unit square" material).
Definition: elasto.hh:56
double lame() const
Returns the first Lame parameter .
Definition: elasto.hh:85
double young() const
Returns the Young's modulus .
Definition: elasto.hh:82
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.
Definition: elasto.hh:461
Dune::FieldMatrix< Scalar, dim+1, dim+1 > OutputTensor
Definition: elasto.hh:464
OutputTensor d0() const
The linearized Green-Lagrange strain tensor .
Definition: elasto.hh:486
Dune::FieldMatrix< Scalar, dim+1, dim > InputTensor
Definition: elasto.hh:463
ExtendedGreenLagrangeTensor(InputTensor const &du_)
Constructor.
Definition: elasto.hh:470
ExtendedGreenLagrangeTensor()
Default constructor. This initializes the displacement derivative to 0, i.e. to the reference configu...
Definition: elasto.hh:478
OutputTensor d2(InputTensor const &dv, InputTensor const &dw) const
The second derivative of the linearized Green-Lagrange strain tensor in direction dv,...
Definition: elasto.hh:507
OutputTensor d1(InputTensor const &dv) const
The first derivative of the linearized Green-Lagrange strain tensor in direction dv.
Definition: elasto.hh:496
Full (right) Green-Lagrange strain tensor, the workhorse of hyperelasticity.
Definition: elasto.hh:341
Tensor d1(Tensor const &dv) const
The first derivative of the linearized Green-Lagrange strain tensor in direction dv.
Definition: elasto.hh:373
Tensor d2(Tensor const &dv, Tensor const &dw) const
The second derivative of the linearized Green-Lagrange strain tensor in direction dv,...
Definition: elasto.hh:380
Tensor d0() const
The linearized Green-Lagrange strain tensor .
Definition: elasto.hh:366
GreenLagrangeTensor(Tensor const &du_)
Constructor.
Definition: elasto.hh:349
GreenLagrangeTensor()
Default constructor. This initializes the displacement derivative to 0, i.e. to the reference configu...
Definition: elasto.hh:355
Dune::FieldMatrix< Scalar, dim, dim > Tensor
Definition: elasto.hh:343
void setDisplacementDerivative(Tensor const &du_)
Definition: elasto.hh:358
Isochoric part of the full (right) Green-Lagrange strain tensor, used in compressible hyperelasticity...
Definition: elasto.hh:552
IsochoricGreenLagrangeTensor(Tensor const &E_)
Constructor.
Definition: elasto.hh:560
DetIpm1< dim, Scalar > const & determinant() const
The shifted determinant of the original Green Lagrange strain tensor.
Definition: elasto.hh:598
Dune::FieldMatrix< Scalar, dim, dim > Tensor
Definition: elasto.hh:554
IsochoricGreenLagrangeTensor()
Default constructor. This initializes the strain tensor to 0, i.e. to the reference configuration.
Definition: elasto.hh:568
Tensor d0() const
The isochoric linearized Green-Lagrange strain tensor .
Definition: elasto.hh:573
Tensor d2(Tensor const &dE1, Tensor const &dE2) const
The second derivative of the linearized Green-Lagrange strain tensor in direction dv,...
Definition: elasto.hh:590
Tensor d1(Tensor const &dE) const
The first derivative of the linearized Green-Lagrange strain tensor in direction de.
Definition: elasto.hh:581
Linearized (right) Green-Lagrange strain tensor, the workhorse of linear elastomechanics.
Definition: elasto.hh:280
Tensor d2(Tensor const &, Tensor const &) const
The second derivative of the linearized Green-Lagrange strain tensor in direction dv,...
Definition: elasto.hh:322
LinearizedGreenLagrangeTensor()
Default constructor. This initializes the displacement derivative to 0, i.e. to the reference configu...
Definition: elasto.hh:297
Dune::FieldMatrix< Scalar, dim, dim > Tensor
The type of displacement derivatives.
Definition: elasto.hh:285
Tensor d0() const
The linearized Green-Lagrange strain tensor .
Definition: elasto.hh:308
LinearizedGreenLagrangeTensor(Tensor const &du_)
Constructor.
Definition: elasto.hh:291
Tensor d1(Tensor const &dv) const
The first derivative of the linearized Green-Lagrange strain tensor in direction dv.
Definition: elasto.hh:315
Numerically stable evaluation of .
Definition: elasto.hh:211
double d1(double dx) const
Definition: elasto.hh:220
Pstable(double p_, double x_)
Constructor.
double d2(double dx1, double dx2) const
Definition: elasto.hh:221
A class for shifted invariants of a tensor.
Definition: elasto.hh:248
Invariants d1(Tensor const &dA) const
Invariants d2(Tensor const &dA1, Tensor const &dA2) const
A function view that provides on the fly computed strain tensors of displacemnts.
Definition: elasto.hh:621
typename StrainTensor::Tensor ValueType
Definition: elasto.hh:624
Space const & space() const
Definition: elasto.hh:635
ValueType value(typename Space::Evaluator const &evaluator) const
Definition: elasto.hh:640
typename Displacement::Space Space
Definition: elasto.hh:623
StrainView(Displacement const &u_)
Constructor.
Definition: elasto.hh:632
Full (right) Green-Lagrange strain tensor for displacements from dim-1 to dim.
Definition: elasto.hh:398
Dune::FieldMatrix< Scalar, dim+1, dim > InputTensor
Definition: elasto.hh:400
OutputTensor d1(InputTensor const &dv) const
The first derivative of the linearized Green-Lagrange strain tensor in direction dv.
Definition: elasto.hh:436
OutputTensor d0() const
The linearized Green-Lagrange strain tensor .
Definition: elasto.hh:429
Dune::FieldMatrix< Scalar, dim, dim > OutputTensor
Definition: elasto.hh:401
OutputTensor d2(InputTensor const &dv, InputTensor const &dw) const
The second derivative of the linearized Green-Lagrange strain tensor in direction dv,...
Definition: elasto.hh:443
SurfaceGreenLagrangeTensor()
Default constructor. This initializes the displacement derivative to 0, i.e. to the reference configu...
Definition: elasto.hh:419
SurfaceGreenLagrangeTensor(InputTensor const &du_)
Constructor.
Definition: elasto.hh:407
A class for representing tensors of arbitrary static rank and extents.
Definition: tensor.hh:86
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.
Definition: elasto.hh:173
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...
Definition: integration.hh:100
typename GridView::template Codim< 0 >::Entity Cell
The type of cells (entities of codimension 0) in the grid view.
Definition: gridBasics.hh:35
T trace(Dune::FieldMatrix< T, n, n > const &A)
Matrix trace .
Definition: fixdune.hh:515
Dune::FieldVector< T, n > max(Dune::FieldVector< T, n > x, Dune::FieldVector< T, n > const &y)
Componentwise maximum.
Definition: fixdune.hh:110
Dune::FieldMatrix< T, n, n > unitMatrix()
Returns the identity matrix of size n .
Definition: fixdune.hh:555
T determinant(Dune::FieldMatrix< T, n, n > const &A)
Matrix determinant .
Definition: fixdune.hh:531
Dune::FieldVector< T, n > min(Dune::FieldVector< T, n > x, Dune::FieldVector< T, n > const &y)
Componentwise minimum.
Definition: fixdune.hh:122
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.
Definition: elasto.hh:664
double orientationPreservingStepsize(Function const &y, Function const &dy, double epsilon)
Computes the maximal orientation preserving stepsize.
Definition: elasto.hh:734
auto makeLinearizedGreenLagrangeStrainView(Displacement const &u)
A convenience function for creating function views for linearized Green-Lagrange strain tensors.
Definition: elasto.hh:654
constexpr int sqrti(int n)
Computes floor(sqrt(n)) for integers n at compile time.
Definition: power.hh:88
double yieldStrength(std::string const &name)
Yield strengths of several materials in Pa.
Functionalities for integration of FunctionSpaceElement s or FunctionViews.
T transpose(T x)