openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
mechanic_integrators.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // openCARP is an open cardiac electrophysiology simulator.
3 //
4 // Copyright (C) 2020 openCARP project
5 //
6 // This program is licensed under the openCARP Academic Public License (APL)
7 // v1.0: You can use and redistribute it and/or modify it in non-commercial
8 // academic environments under the terms of APL as published by the openCARP
9 // project v1.0, or (at your option) any later version. Commercial use requires
10 // a commercial license (info@opencarp.org).
11 //
12 // This program is distributed without any warranty; see the openCARP APL for
13 // more details.
14 //
15 // You should have received a copy of the openCARP APL along with this program
16 // and can find it online: http://www.opencarp.org/license
17 // ----------------------------------------------------------------------------
18 
27 #ifndef _MECH_INTEGRATORS_H
28 #define _MECH_INTEGRATORS_H
29 
30 #include "SF_base.h"
31 #include "basics.h"
32 #include "fem_types.h"
33 #include "sf_interface.h"
34 #include "constitutive_model_library.h"
35 #include "constitutive_model.h"
36 #include "mechanics.h"
37 
38 namespace opencarp {
39 
41 #define EP_MAX_IPOINTS 128
43 #define EP_MAX_LPOINTS 8
44 
45 class mech_stiffness_integrator : public SF::matrix_integrator<mesh_int_t,mesh_real_t>
46 {
47  MaterialType & material;
48 
49  SF::dmat<double> cond;
50  SF::dmat<double> shape;
51  SF::dmat<double> gshape;
52  double J[9];
53  double F[9];
54  double cauchy_stress[6];
56 
57  int p_order = 1;
58 
60  double w [EP_MAX_IPOINTS];
61 
62  public:
63  mech_stiffness_integrator(MaterialType & inp_mat) : material(inp_mat)
64  {}
66  void dpn(mesh_int_t & row_dpn, mesh_int_t & col_dpn);
67 };
68 
73 class mech_internal_forces_integrator : public SF::vector_integrator<mesh_int_t, mesh_real_t>
74 {
75  MaterialType & material;
76 
77  SF::dmat<double> shape;
78  SF::dmat<double> gshape;
79  double J[9];
80  double F[9];
81  double iF[9];
82  double S_PK1[9];
83  double S_PK1_xyz[9];
85 
86  int p_order = 1;
87 
89  double w[EP_MAX_IPOINTS];
90 
91  public:
92  mech_internal_forces_integrator(MaterialType & inp_mat) : material(inp_mat)
93  {}
94  void operator() (const SF::element_view<mesh_int_t, mesh_real_t> & elem, double * buff);
95  void dpn(mesh_int_t & dpn);
96 };
97 
98 
99 class mech_mass_integrator : public SF::matrix_integrator<mesh_int_t,mesh_real_t>
100 {
101  SF::dmat<double> shape;
102  double J[9];
103  SF::Point lpts[EP_MAX_LPOINTS];
104 
105  int p_order = 1;
106 
107  SF::Point ipts[EP_MAX_IPOINTS];
108  double w [EP_MAX_IPOINTS];
109 
111  void dpn(mesh_int_t & row_dpn, mesh_int_t & col_dpn);
112 };
113 
115 void calc_deformation_gradient(const SF::element_view<mesh_int_t, mesh_real_t> & elem, int ipt, double * F, double * iF, double & detF, int index = -1, double eps = 0.0);
116 
117 
118 inline void calc_left_cauchy_green(double * F, double * b)
119 {
121  b[0] = F[0]*F[0] + F[3]*F[3] + F[6]*F[6];
122  b[1] = F[0]*F[1] + F[3]*F[4] + F[6]*F[7];
123  b[2] = F[0]*F[2] + F[3]*F[5] + F[6]*F[8];
124  b[3] = b[1];
125  b[4] = F[1]*F[1] + F[4]*F[4] + F[7]*F[7];
126  b[5] = F[1]*F[2] + F[4]*F[5] + F[7]*F[8];
127  b[6] = b[2];
128  b[7] = b[5];
129  b[8] = F[2]*F[2] + F[5]*F[5] + F[8]*F[8];
130 };
131 
132 inline void calc_right_cauchy_green(double * F, double * C)
133 {
135  C[0] = F[0]*F[0] + F[1]*F[1] + F[2]*F[2];
136  C[1] = F[0]*F[3] + F[1]*F[4] + F[2]*F[5];
137  C[2] = F[0]*F[6] + F[1]*F[7] + F[2]*F[8];
138  C[3] = C[1];
139  C[4] = F[3]*F[3] + F[4]*F[4] + F[5]*F[5];
140  C[5] = F[3]*F[6] + F[4]*F[7] + F[5]*F[8];
141  C[6] = C[2];
142  C[7] = C[5];
143  C[8] = F[6]*F[6] + F[7]*F[7] + F[8]*F[8];
144 };
145 
146 inline void calc_green_strain(double * F, double * E_Green) // Right now still with 9 entries, just for testing purposes
147 {
149  E_Green[0] = 0.5 * (F[0]*F[0] + F[1]*F[1] + F[2]*F[2] - 1);
150  E_Green[1] = 0.5 * (F[0]*F[3] + F[1]*F[4] + F[2]*F[5]);
151  E_Green[2] = 0.5 * (F[0]*F[6] + F[1]*F[7] + F[2]*F[8]);
152  E_Green[3] = E_Green[1];
153  E_Green[4] = 0.5 * (F[3]*F[3] + F[4]*F[4] + F[5]*F[5] - 1);
154  E_Green[5] = 0.5 * (F[3]*F[6] + F[4]*F[7] + F[5]*F[8]);
155  E_Green[6] = E_Green[2];
156  E_Green[7] = E_Green[5];
157  E_Green[8] = 0.5 * (F[6]*F[6] + F[7]*F[7] + F[8]*F[8] - 1);
158 };
159 
160 inline void calc_green_strain_voigt(double * F, double * E_Green) // 6 entries: Voigt notation E = {E_11, E_22, E_33, 2*E12, 2*E13, 2*E23};
161 {
162  E_Green[0] = 0.5 * (F[0]*F[0] + F[1]*F[1] + F[2]*F[2] - 1);
163  E_Green[1] = 0.5 * (F[3]*F[3] + F[4]*F[4] + F[5]*F[5] - 1);
164  E_Green[2] = 0.5 * (F[6]*F[6] + F[7]*F[7] + F[8]*F[8] - 1);
165  E_Green[3] = F[0]*F[3] + F[1]*F[4] + F[2]*F[5];
166  E_Green[4] = F[0]*F[6] + F[1]*F[7] + F[2]*F[8];
167  E_Green[5] = F[3]*F[6] + F[4]*F[7] + F[5]*F[8];
168 };
169 
170 inline Basic_constitutive_model * constitutive_model_setup(mechMat_t type, double * parameter_list)
171 {
172  Basic_constitutive_model * constitutive_model;
173  switch (type) {
174  case NEOHOOKE:
175  constitutive_model = new Neo_Hooke();
176  constitutive_model->set_parameters(parameter_list);
177  break;
178  case GUCCIONE:
179  constitutive_model = new Guccione();
180  constitutive_model->set_parameters(parameter_list);
181  break;
182  default:
183  break;
184  }
185  return constitutive_model;
186 }
187 } // namespace opencarp
188 
189 #endif
The base header file.
int mesh_int_t
Definition: SF_container.h:46
Basic utility structs and functions, mostly IO related.
Comfort class. Provides getter functions to access the mesh member variables more comfortably.
Definition: SF_fem_utils.h:705
Abstract matrix integration base class.
Definition: SF_fem_utils.h:968
Abstract vector integration base class.
Definition: SF_fem_utils.h:986
Used to integrate the internal nodel forces per element.
void operator()(const SF::element_view< mesh_int_t, mesh_real_t > &elem, double *buff)
Calculate internal force vector for a given element at each node.
mech_internal_forces_integrator(MaterialType &inp_mat)
void dpn(mesh_int_t &dpn)
return (by reference) the row and column dimensions
void dpn(mesh_int_t &row_dpn, mesh_int_t &col_dpn)
ACHTUNG: HIER AENDERUNG VON MIR.
void operator()(const SF::element_view< mesh_int_t, mesh_real_t > &elem, SF::dmat< double > &buff)
compute the element matrix for a given element.
void operator()(const SF::element_view< mesh_int_t, mesh_real_t > &elem, SF::dmat< double > &buff)
Calculate mech stiffness matrix for a given element at each node.
mech_stiffness_integrator(MaterialType &inp_mat)
void dpn(mesh_int_t &row_dpn, mesh_int_t &col_dpn)
ACHTUNG: HIER AENDERUNG VON MIR.
Structs and types for (electric) FEM.
#define EP_MAX_LPOINTS
maximum supported number of points in a local element
#define EP_MAX_IPOINTS
maximum supported number of integration points
Tissue level mechanics, main Mechanics physics class.
void calc_green_strain(double *F, double *E_Green)
Basic_constitutive_model * constitutive_model_setup(mechMat_t type, double *parameter_list)
void calc_left_cauchy_green(double *F, double *b)
void calc_right_cauchy_green(double *F, double *C)
mechMat_t
mechanical material models to choose from
Definition: fem_types.h:50
@ NEOHOOKE
Definition: fem_types.h:51
@ GUCCIONE
Definition: fem_types.h:51
void calc_deformation_gradient(const SF::element_view< mesh_int_t, mesh_real_t > &elem, int ipt, double *F, double *iF, double &detF, int index, double eps)
Calculate deformation gradient at a given integration point.
void calc_green_strain_voigt(double *F, double *E_Green)
Interface to SlimFem.
Point and vector struct.
Definition: SF_container.h:66
description of materal properties in a mesh
Definition: fem_types.h:155