funcy  1.6.0
mooney_rivlin.h
1 #pragma once
2 
3 #include <funcy/examples/volumetric_penalty_functions.h>
4 #include <funcy/funcy.h>
5 
6 #include <iostream>
7 #include <string>
8 
15 namespace funcy
16 {
23  template < linalg::Matrix Mat, int n = linalg::dim< Mat >() >
24  auto incompressible_mooney_rivlin( double c0, double c1, const Mat& F )
25  {
26  using namespace linalg;
27  auto S = LeftCauchyGreenStrainTensor( F );
28  auto f = ( c0 * ( i1( F ) - n ) + c1 * ( i2( F ) - n ) );
29  return finalize( f( S ) );
30  }
31 
38  template < class InflationPenalty, class CompressionPenalty, linalg::Matrix Mat,
39  int n = linalg::dim< Mat >() >
40  auto compressible_mooney_rivlin( double c0, double c1, double d0, double d1, const Mat& F )
41  {
42  using namespace linalg;
43  auto S = LeftCauchyGreenStrainTensor( F );
44  auto f = ( c0 * ( i1( F ) - n ) + c1 * ( i2( F ) - n ) );
45  return finalize( f( S ) +
46  volumetric_penalty< InflationPenalty, CompressionPenalty >( d0, d1, F ) );
47  }
48 
63  template < linalg::Matrix Mat, class InflationPenalty, class CompressionPenalty >
64  auto create_mooney_rivlin_from_lame_constants( double lambda, double mu )
65  {
66  auto I = 1.;
67  auto g = finalize( CompressionPenalty( I )( Identity< double >( 1. ) ) );
68 
69  auto rho = g.d1( I ) / ( -g.d2( I, I ) + g.d1( I ) );
70  auto d = ( lambda + 2.0 * mu ) / ( g.d2( I, I ) - g.d1( I ) );
71  auto c = ( 0.5 * rho - 0.25 ) * mu + 0.25 * rho * lambda;
72  if ( c > 0.25 * mu )
73  c = ( rho - 0.75 ) * mu + 0.5 * rho * lambda;
74  auto b = -mu + rho * ( lambda + 2. * mu ) - 2. * c;
75  auto a = b + mu;
76  auto alpha = 0.5 * a - b;
77  auto beta = 0.5 * b;
78 
79  if ( a < 0 || b < 0 || c < 0 )
80  {
81  std::cout << "In the generation of Mooney-Rivlin material model from Lame constants."
82  << std::endl;
83  std::cout << "Computed parameters: " << alpha << ", " << beta << ", " << c << ", " << d
84  << std::endl;
85  std::cout << "Material law is not polyconvex! -> Terminating." << std::endl;
86  exit( 1 );
87  }
88 
89  return compressible_mooney_rivlin< InflationPenalty, CompressionPenalty >(
90  alpha, beta, c, d, linalg::unit_matrix< Mat >() );
91  }
92 
107  template < linalg::Matrix Mat, class InflationPenalty, class CompressionPenalty >
109  {
110  double lambda = E * nu / ( ( 1 + nu ) * ( 1 - 2 * nu ) );
111  double mu = E / ( 2 * ( 1 + nu ) );
112  return create_mooney_rivlin_from_lame_constants< Mat, InflationPenalty,
113  CompressionPenalty >( lambda, mu );
114  }
115 } // namespace funcy
auto incompressible_mooney_rivlin(double c0, double c1, const Mat &F)
Generate an "incompressible" Mooney-Rivlin material law , where is the first and the second princip...
Definition: mooney_rivlin.h:24
concept Matrix
Matrix concept.
Definition: concepts.h:77
auto compressible_mooney_rivlin(double c0, double c1, double d0, double d1, const Mat &F)
Generate a compressible Mooney-Rivlin material law , where is the first and the second principal ma...
Definition: mooney_rivlin.h:40
Main namespace of the funcy library.
Identity mapping .
Definition: identity.h:12
auto create_mooney_rivlin_from_material_constants(double E, double nu)
Generate a compressible Mooney-Rivlin material law , where is the first and the second principal ma...
Definition: mooney_rivlin.h:108
auto finalize(F &&f) requires(static_check
Finish function definition.
Definition: finalize.h:248
auto i2(M &&A)
Convenient generation of second principal invariant for .
Definition: principal_invariants.h:166
auto i1(Arg &&x)
Generate first principal invariant.
Definition: principal_invariants.h:155
auto create_mooney_rivlin_from_lame_constants(double lambda, double mu)
Generate a compressible Mooney-Rivlin material law , where is the first and the second principal ma...
Definition: mooney_rivlin.h:64