Trilinos based (stochastic) FEM solvers
compressible_Mooney_Transverse_Isotropic.hpp
Go to the documentation of this file.
1 /*
2 Brian Staber (brian.staber@gmail.com)
3 */
4 
5 #ifndef COMPRESSIBLE_MOONEY_TRANSVERSE_ISOTROPIC_HPP
6 #define COMPRESSIBLE_MOONEY_TRANSVERSE_ISOTROPIC_HPP
7 
8 #include "tensor_calculus.hpp"
10 
12 {
13 public:
14 
15  double topcoord;
16  double mu1, mu2, mu3, mu4, mu5, mu;
17  double trm, beta3, beta4, beta5;
20  std::vector<int> phase;
21 
22  tiMooney(Epetra_Comm & comm, Teuchos::ParameterList & Parameters){
23 
24  std::string mesh_file = Teuchos::getParameter<std::string>(Parameters.sublist("Mesh"), "mesh_file");
25  Mesh = new mesh(comm, mesh_file, 1.0);
26  Comm = Mesh->Comm;
27 
28  StandardMap = new Epetra_Map(-1,3*Mesh->n_local_nodes_without_ghosts,&Mesh->local_dof_without_ghosts[0],0,*Comm);
29  OverlapMap = new Epetra_Map(-1,3*Mesh->n_local_nodes,&Mesh->local_dof[0],0,*Comm);
30  ImportToOverlapMap = new Epetra_Import(*OverlapMap,*StandardMap);
31 
33 
34  findtop();
36  for (unsigned int e=0; e<Mesh->n_cells/32; ++e){
37  for (unsigned int j=0; j<32; ++j){
38  phase.push_back(j);
39  }
40  }
41  }
42 
44  }
45 
46  void set_parameters(Epetra_SerialDenseVector & x){
47  mu1 = x(0);
48  mu2 = x(1);
49  mu3 = x(2);
50  mu4 = x(3);
51  mu5 = x(4);
52  beta3 = -0.5;
53  beta4 = x(5);
54  beta5 = x(6);
55  mu = 2.0*mu1 + 4.0*mu2 + 2.0*mu3;
56  trm = mu4 + 2.0*mu5;
57  ptrmbeta4 = std::pow(trm,beta4);
58  ptrmbeta5 = std::pow(trm,beta5);
59  }
60 
61  void set_plyagl(double & Plyagl){
62  plyagl = Plyagl;
63  }
64 
65  void findtop(){
66  topcoord = 0.0;
67  if (Comm->MyPID()==0){
68  for (unsigned int n=0; n<Mesh->n_nodes; ++n){
69  if (Mesh->nodes_coord[3*n+1]>topcoord){
70  topcoord = Mesh->nodes_coord[3*n+1];
71  }
72  }
73  }
74  Comm->Broadcast(&topcoord,1,0);
75  Comm->Barrier();
76  }
77 
78  void get_matrix_and_rhs(Epetra_Vector & x, Epetra_FECrsMatrix & K, Epetra_FEVector & F){
80  }
81 
83  n_bc_dof = 0;
84  double y;
85  unsigned int node;
86  for (unsigned int i=0; i<Mesh->n_local_nodes_without_ghosts; ++i){
87  node = Mesh->local_nodes[i];
88  y = Mesh->nodes_coord[3*node+1];
89  if(y==0.0){
90  n_bc_dof+=3;
91  }
92  if(y==topcoord){
93  n_bc_dof+=3;
94  }
95  }
96 
97  int indbc = 0;
98  dof_on_boundary = new int [n_bc_dof];
99  for (unsigned int inode=0; inode<Mesh->n_local_nodes_without_ghosts; ++inode){
100  node = Mesh->local_nodes[inode];
101  y = Mesh->nodes_coord[3*node+1];
102  if (y==0.0){
103  dof_on_boundary[indbc+0] = 3*inode+0;
104  dof_on_boundary[indbc+1] = 3*inode+1;
105  dof_on_boundary[indbc+2] = 3*inode+2;
106  indbc+=3;
107  }
108  if (y==topcoord){
109  dof_on_boundary[indbc+0] = 3*inode+0;
110  dof_on_boundary[indbc+1] = 3*inode+1;
111  dof_on_boundary[indbc+2] = 3*inode+2;
112  indbc+=3;
113  }
114  }
115  }
116 
117  void apply_dirichlet_conditions(Epetra_FECrsMatrix & K, Epetra_FEVector & F, double & displacement){
118  Epetra_MultiVector v(*StandardMap,true);
119  v.PutScalar(0.0);
120 
121  int node;
122  double y;
123  for (unsigned int inode=0; inode<Mesh->n_local_nodes_without_ghosts; ++inode){
124  node = Mesh->local_nodes[inode];
125  y = Mesh->nodes_coord[3*node+1];
126  if (y==topcoord){
127  v[0][StandardMap->LID(3*node+1)] = displacement;
128  }
129  }
130 
131  Epetra_MultiVector rhs_dir(*StandardMap,true);
132  K.Apply(v,rhs_dir);
133  F.Update(-1.0,rhs_dir,1.0);
134 
135  for (unsigned int inode=0; inode<Mesh->n_local_nodes_without_ghosts; ++inode){
136  node = Mesh->local_nodes[inode];
137  y = Mesh->nodes_coord[3*node+1];
138  if (y==0.0){
139  F[0][StandardMap->LID(3*node+0)] = v[0][StandardMap->LID(3*node+0)];
140  F[0][StandardMap->LID(3*node+1)] = v[0][StandardMap->LID(3*node+1)];
141  F[0][StandardMap->LID(3*node+2)] = v[0][StandardMap->LID(3*node+2)];
142  }
143  if (y==topcoord){
144  F[0][StandardMap->LID(3*node+0)] = v[0][StandardMap->LID(3*node+0)];
145  F[0][StandardMap->LID(3*node+1)] = v[0][StandardMap->LID(3*node+1)];
146  F[0][StandardMap->LID(3*node+2)] = v[0][StandardMap->LID(3*node+2)];
147  }
148  }
149  ML_Epetra::Apply_OAZToMatrix(dof_on_boundary,n_bc_dof,K);
150  }
151 
152  void get_material_parameters(unsigned int & e_lid, unsigned int & gp){
153  int e_gid = Mesh->local_cells[e_lid];
154  if (phase[e_gid] % 2){
155  cos_plyagl = std::cos(plyagl);
156  sin_plyagl = std::sin(plyagl);
157  }
158  else{
159  cos_plyagl = std::cos(plyagl);
160  sin_plyagl = -std::sin(plyagl);
161  }
162  }
163 
164  void get_constitutive_tensors(Epetra_SerialDenseMatrix & deformation_gradient, Epetra_SerialDenseVector & piola_stress, Epetra_SerialDenseMatrix & tangent_piola){
165 
166  double det = deformation_gradient(0,0)*deformation_gradient(1,1)*deformation_gradient(2,2)-deformation_gradient(0,0)*deformation_gradient(1,2)*deformation_gradient(2,1)-deformation_gradient(0,1)*deformation_gradient(1,0)*deformation_gradient(2,2)+deformation_gradient(0,1)*deformation_gradient(1,2)*deformation_gradient(2,0)+deformation_gradient(0,2)*deformation_gradient(1,0)*deformation_gradient(2,1)-deformation_gradient(0,2)*deformation_gradient(1,1)*deformation_gradient(2,0);
167 
168  Epetra_SerialDenseMatrix C(3,3);
169  Epetra_SerialDenseMatrix CC(3,3);
170  Epetra_SerialDenseMatrix ddJ5(6,6);
171  Epetra_SerialDenseVector LML(6);
172  Epetra_SerialDenseVector eye(6);
173  Epetra_SerialDenseVector dJ5(6);
174  Epetra_SerialDenseVector M(6);
175  Epetra_SerialDenseVector L(6);
176  Epetra_SerialDenseVector c(6);
177 
178  C.Multiply('T','N',1.0,deformation_gradient,deformation_gradient,0.0);
179  CC.Multiply('N','N',1.0,C,C,0.0);
180 
181  c(0) = C(0,0); c(1) = C(1,1); c(2) = C(2,2); c(3) = C(1,2); c(4) = C(0,2); c(5) = C(0,1);
182 
183  L(0) = (1.0/(det*det))*(C(1,1)*C(2,2)-C(1,2)*C(2,1));
184  L(1) = (1.0/(det*det))*(C(0,0)*C(2,2)-C(0,2)*C(2,0));
185  L(2) = (1.0/(det*det))*(C(0,0)*C(1,1)-C(0,1)*C(1,0));
186  L(3) = (1.0/(det*det))*(C(0,2)*C(1,0)-C(0,0)*C(1,2));
187  L(4) = (1.0/(det*det))*(C(0,1)*C(1,2)-C(0,2)*C(1,1));
188  L(5) = (1.0/(det*det))*(C(0,2)*C(2,1)-C(0,1)*C(2,2));
189 
190  M(0) = mu4*sin_plyagl*sin_plyagl+mu5*cos_plyagl*cos_plyagl;
191  M(1) = mu4*cos_plyagl*cos_plyagl+mu5*sin_plyagl*sin_plyagl;
192  M(2) = mu5;
193  M(3) = 0.0;
194  M(4) = 0.0;
195  M(5) = (mu4-mu5)*cos_plyagl*sin_plyagl;
196 
197  LML(0) = M(0)*L(0)*L(0)+2.0*M(4)*L(0)*L(4)+2.0*M(5)*L(0)*L(5)+M(2)*L(4)*L(4)+2.0*M(3)*L(4)*L(5)+M(1)*L(5)*L(5);
198  LML(1) = M(1)*L(1)*L(1)+2.0*M(4)*L(1)*L(3)+2.0*M(5)*L(1)*L(5)+M(2)*L(3)*L(3)+2.0*M(4)*L(3)*L(5)+M(0)*L(5)*L(5);
199  LML(2) = M(2)*L(2)*L(2)+2.0*M(3)*L(2)*L(3)+2.0*M(4)*L(2)*L(4)+M(1)*L(3)*L(3)+2.0*M(5)*L(3)*L(4)+M(0)*L(4)*L(4);
200  LML(3) = L(2)*(L(1)*M(3)+L(3)*M(2)+L(5)*M(4))+L(3)*(L(1)*M(1)+L(3)*M(3)+L(5)*M(5))+L(4)*(L(5)*M(0)+L(1)*M(5)+L(3)*M(4));
201  LML(4) = L(2)*(L(0)*M(4)+L(4)*M(2)+L(5)*M(3))+L(3)*(L(0)*M(5)+L(5)*M(1)+L(4)*M(3))+L(4)*(L(0)*M(0)+L(4)*M(4)+L(5)*M(5));
202  LML(5) = L(1)*(L(0)*M(5)+L(5)*M(1)+L(4)*M(3))+L(3)*(L(0)*M(4)+L(4)*M(2)+L(5)*M(3))+L(5)*(L(0)*M(0)+L(4)*M(4)+L(5)*M(5));
203 
204  eye(0) = 1.0; eye(1) = 1.0; eye(2) = 1.0; eye(3) = 0.0; eye(4) = 0.0; eye(5) = 0.0;
205 
206  double I1 = C(0,0) + C(1,1) + C(2,2);
207  double II1 = C(0,0)*C(0,0) + C(1,1)*C(1,1) + C(2,2)*C(2,2) + 2.0*C(1,2)*C(1,2) + 2.0*C(0,2)*C(0,2) + 2.0*C(0,1)*C(0,1);
208  double I2 = (1.0/2.0)*(I1*I1-II1);
209  double I3 = det*det;
210  double I4 = C(0,0)*M(0) + C(1,1)*M(1) + C(2,2)*M(2) + 2.0*C(0,1)*M(5) + 2.0*C(0,2)*M(4) + 2.0*C(1,2)*M(3);
211  double I5 = CC(0,0)*M(0) + CC(1,1)*M(1) + CC(2,2)*M(2) + 2.0*CC(0,1)*M(5) + 2.0*CC(0,2)*M(4) + 2.0*CC(1,2)*M(3);
212  double J5 = I5 - I1*I4 + I2*trm;
213  double pI3 = std::pow(I3,-beta3);
214  double pI4 = std::pow(I4, beta4);
215  double pJ5 = std::pow(J5, beta5);
216 
217  for (unsigned int i=0; i<6; ++i){
218  dJ5(i) = J5*L(i) - I3*LML(i);
219  piola_stress(i) = 2.0*mu1*eye(i) + 2.0*mu2*(I1*eye(i)-c(i)) + (2.0*mu3*det*det-mu)*L(i)
220  + (2.0/ptrmbeta4)*pI4*M(i) + (2.0/ptrmbeta5)*pJ5*dJ5(i) - 2.0*trm*pI3*L(i);
221  }
222 
223  tensor_product(4.0*mu2,eye,eye,tangent_piola,0.0);
224  sym_tensor_product(-4.0*mu2,eye,eye,tangent_piola,1.0);
225 
226  tensor_product(4.0*mu3*det*det,L,L,tangent_piola,1.0);
227 
228  sym_tensor_product(-4.0*mu3*det*det+2.0*mu,L,L,tangent_piola,1.0);
229 
230  tensor_product(J5,L,L,ddJ5,0.0);
231  sym_tensor_product(-J5,L,L,ddJ5,1.0);
232 
233  tensor_product(-I3,L,LML,ddJ5,1.0);
234  tensor_product(-I3,LML,L,ddJ5,1.0);
235 
236  sym_tensor_product(I3,L,LML,ddJ5,1.0);
237  sym_tensor_product(I3,LML,L,ddJ5,1.0);
238 
239  tensor_product(4.0*beta4*pI4/(I4*ptrmbeta4),M,M,tangent_piola,1.0);
240  tensor_product(4.0*beta5*pJ5/(J5*ptrmbeta5),dJ5,dJ5,tangent_piola,1.0);
241 
242  tensor_product(4.0*trm*beta3*pI3,L,L,tangent_piola,1.0);
243  sym_tensor_product(4.0*trm*pI3,L,L,tangent_piola,1.0);
244 
245  ddJ5.Scale(4.0*pJ5/ptrmbeta5);
246  tangent_piola += ddJ5;
247  }
248 
249  Epetra_SerialDenseVector get_neumannBc(Epetra_SerialDenseMatrix & matrix_X, Epetra_SerialDenseMatrix & xg, unsigned int & gp){
250  Epetra_SerialDenseVector h(3);
251  std::cout << "**Err: Not using that method in this example!\n";
252  return h;
253  }
254 
255  Epetra_SerialDenseVector get_forcing(double & x1, double & x2, double & x3, unsigned int & e_lid, unsigned int & gp){
256  Epetra_SerialDenseVector f(3);
257  std::cout << "**Err: Not using that method in this example!\n";
258  return f;
259  }
260 
261  void get_material_parameters_for_recover(unsigned int & e_lid){
262  }
263 
264  void get_stress_for_recover(Epetra_SerialDenseMatrix & deformation_gradient, double & det, Epetra_SerialDenseMatrix & piola_stress){
265  }
266 
267 };
268 
269 #endif
Epetra_Comm * Comm
for j
Definition: costFunction.m:42
std::vector< int > local_nodes
Definition: meshpp.hpp:80
void tensor_product(double scalarAB, Epetra_SerialDenseVector &A, Epetra_SerialDenseVector &B, Epetra_SerialDenseMatrix &AoB, double scalarThis)
std::vector< double > nodes_coord
Definition: meshpp.hpp:77
unsigned int n_bc_dof
void set_parameters(Epetra_SerialDenseVector &x)
void get_stress_for_recover(Epetra_SerialDenseMatrix &deformation_gradient, double &det, Epetra_SerialDenseMatrix &piola_stress)
Epetra_SerialDenseVector get_forcing(double &x1, double &x2, double &x3, unsigned int &e_lid, unsigned int &gp)
tiMooney(Epetra_Comm &comm, Teuchos::ParameterList &Parameters)
std::vector< int > local_cells
Definition: meshpp.hpp:81
clc clear all close all mesh
Definition: run.m:5
void assemblePureDirichlet_homogeneousForcing(Epetra_Vector &x, Epetra_FECrsMatrix &K, Epetra_FEVector &F)
int n_local_nodes_without_ghosts
Definition: meshpp.hpp:92
L
Definition: costFunction.m:66
Epetra_Import * ImportToOverlapMap
void apply_dirichlet_conditions(Epetra_FECrsMatrix &K, Epetra_FEVector &F, double &displacement)
Epetra_Map * StandardMap
Epetra_SerialDenseVector get_neumannBc(Epetra_SerialDenseMatrix &matrix_X, Epetra_SerialDenseMatrix &xg, unsigned int &gp)
void get_material_parameters_for_recover(unsigned int &e_lid)
void sym_tensor_product(double scalarAB, Epetra_SerialDenseVector &A, Epetra_SerialDenseVector &B, Epetra_SerialDenseMatrix &AoB, double scalarThis)
int n_nodes
Definition: meshpp.hpp:87
for i
Definition: costFunction.m:38
void get_material_parameters(unsigned int &e_lid, unsigned int &gp)
Epetra_Map * OverlapMap
void get_constitutive_tensors(Epetra_SerialDenseMatrix &deformation_gradient, Epetra_SerialDenseVector &piola_stress, Epetra_SerialDenseMatrix &tangent_piola)
e
Definition: run.m:10
void get_matrix_and_rhs(Epetra_Vector &x, Epetra_FECrsMatrix &K, Epetra_FEVector &F)