1 #ifndef RUBBERBLOCK_HPP 2 #define RUBBERBLOCK_HPP 14 rubberblock(Epetra_Comm & comm, Teuchos::ParameterList & Parameters){
16 std::string mesh_file = Teuchos::getParameter<std::string>(Parameters.sublist(
"Mesh"),
"mesh_file");
17 Mesh =
new mesh(comm, mesh_file, 1000.0);
21 StandardMap =
new Epetra_Map(-1,3*Mesh->n_local_nodes_without_ghosts,&Mesh->local_dof_without_ghosts[0],0,*
Comm);
22 OverlapMap =
new Epetra_Map(-1,3*Mesh->n_local_nodes,&Mesh->local_dof[0],0,*
Comm);
39 if (
Comm->MyPID()==0){
46 Comm->Broadcast(&topcoord,1,0);
103 F.Update(-1.0,rhs_dir,1.0);
120 void get_constitutive_tensors(Epetra_SerialDenseMatrix & deformation_gradient, Epetra_SerialDenseVector & piola_stress, Epetra_SerialDenseMatrix & tangent_piola){
122 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);
124 Epetra_SerialDenseMatrix C(3,3);
125 Epetra_SerialDenseVector eye(6),
L(6);
127 C.Multiply(
'T',
'N',1.0,deformation_gradient,deformation_gradient,0.0);
129 L(0) = (1.0/(det*det))*(C(1,1)*C(2,2)-C(1,2)*C(2,1));
130 L(1) = (1.0/(det*det))*(C(0,0)*C(2,2)-C(0,2)*C(2,0));
131 L(2) = (1.0/(det*det))*(C(0,0)*C(1,1)-C(0,1)*C(1,0));
132 L(3) = (1.0/(det*det))*(C(0,2)*C(1,0)-C(0,0)*C(1,2));
133 L(4) = (1.0/(det*det))*(C(0,1)*C(1,2)-C(0,2)*C(1,1));
134 L(5) = (1.0/(det*det))*(C(0,2)*C(2,1)-C(0,1)*C(2,2));
136 eye(0) = 1.0; eye(1) = 1.0; eye(2) = 1.0; eye(3) = 0.0; eye(4) = 0.0; eye(5) = 0.0;
138 double I1 = C(0,0) + C(1,1) + C(2,2);
139 double dpressure = (lambda/2.0)*det - ((lambda/2.0) +
mu)/det;
140 double ddpressure = (lambda/2.0) + ((lambda/2.0) +
mu)/(det*det);
142 for (
unsigned int i=0;
i<6; ++
i){
143 piola_stress(
i) = mu*eye(
i) + det*dpressure*
L(
i);
146 double scalarAB = det*(dpressure+det*ddpressure);
148 scalarAB = -2.0*det*dpressure;
158 Epetra_Vector sig22(CellsMap);
161 double det_jac_cells;
162 double I1, det, dpressure;
164 Epetra_SerialDenseMatrix deformation_gradient(3,3), right_cauchy(3,3), inv_right_cauchy(3,3);
165 Epetra_SerialDenseMatrix
s(3,3), sig(3,3), sf(3,3), eye(3,3);
166 Epetra_SerialDenseMatrix matrix_X(3,
Mesh->
el_type);
167 Epetra_SerialDenseMatrix matrix_x(3,
Mesh->
el_type);
168 Epetra_SerialDenseMatrix dx_shape_functions(
Mesh->
el_type,3);
170 Epetra_SerialDenseMatrix JacobianMatrix(3,3);
172 eye(0,0) = 1.0; eye(0,1) = 0.0; eye(0,2) = 0.0;
173 eye(1,0) = 0.0; eye(1,1) = 1.0; eye(1,2) = 0.0;
174 eye(2,0) = 0.0; eye(2,1) = 0.0; eye(2,2) = 1.0;
179 for (
unsigned int inode=0; inode<
Mesh->
el_type; ++inode){
204 deformation_gradient.Multiply(
'N',
'N',1.0,matrix_x,dx_shape_functions,0.0);
205 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);
206 right_cauchy.Multiply(
'T',
'N',1.0,deformation_gradient,deformation_gradient,0.0);
207 inv_right_cauchy(0,0) = (1.0/(det*det))*(right_cauchy(1,1)*right_cauchy(2,2)-right_cauchy(1,2)*right_cauchy(2,1));
208 inv_right_cauchy(1,1) = (1.0/(det*det))*(right_cauchy(0,0)*right_cauchy(2,2)-right_cauchy(0,2)*right_cauchy(2,0));
209 inv_right_cauchy(2,2) = (1.0/(det*det))*(right_cauchy(0,0)*right_cauchy(1,1)-right_cauchy(0,1)*right_cauchy(1,0));
210 inv_right_cauchy(1,2) = (1.0/(det*det))*(right_cauchy(0,2)*right_cauchy(1,0)-right_cauchy(0,0)*right_cauchy(1,2));
211 inv_right_cauchy(2,1) = inv_right_cauchy(1,2);
212 inv_right_cauchy(0,2) = (1.0/(det*det))*(right_cauchy(0,1)*right_cauchy(1,2)-right_cauchy(0,2)*right_cauchy(1,1));
213 inv_right_cauchy(2,0) = inv_right_cauchy(0,2);
214 inv_right_cauchy(0,1) = (1.0/(det*det))*(right_cauchy(0,2)*right_cauchy(2,1)-right_cauchy(0,1)*right_cauchy(2,2));
215 inv_right_cauchy(1,0) = inv_right_cauchy(0,1);
216 I1 = right_cauchy(0,0) + right_cauchy(1,1) + right_cauchy(2,2);
217 dpressure = (lambda/2.0)*det - ((lambda/2.0) +
mu)/det;
218 for (
unsigned int i=0;
i<3; ++
i){
219 for (
unsigned int j=0;
j<3; ++
j){
220 s(
i,
j) = mu*eye(
i,
j) + det*dpressure*inv_right_cauchy(
i,
j);
223 sf.Multiply(
'N',
'T',1.0,
s,deformation_gradient,0.0);
224 sig.Multiply(
'N',
'N',1.0,deformation_gradient,sf,0.0);
226 sig22[e_lid] = sig(1,1);
229 int NumTargetElements = 0;
230 if (
Comm->MyPID()==0){
233 Epetra_Map MapOnRoot(-1,NumTargetElements,0,*
Comm);
234 Epetra_Export ExportOnRoot(CellsMap,MapOnRoot);
235 Epetra_MultiVector lhs_root(MapOnRoot,
true);
236 lhs_root.Export(sig22,ExportOnRoot,Insert);
238 int error = EpetraExt::MultiVectorToMatrixMarketFile(filename.c_str(),lhs_root,0,0,
false);
241 Epetra_SerialDenseVector
get_neumannBc(Epetra_SerialDenseMatrix & matrix_X, Epetra_SerialDenseMatrix & xg,
unsigned int & gp){
242 Epetra_SerialDenseVector h(3);
243 std::cout <<
"**Err: Not using that method in this example!\n";
247 Epetra_SerialDenseVector
get_forcing(
double & x1,
double & x2,
double & x3,
unsigned int & e_lid,
unsigned int & gp){
248 Epetra_SerialDenseVector f(3);
249 std::cout <<
"**Err: Not using that method in this example!\n";
258 std::cout <<
"**Err: Not using that method in this example!\n";
261 void get_stress_for_recover(Epetra_SerialDenseMatrix & deformation_gradient,
double & det, Epetra_SerialDenseMatrix & piola_stress){
262 std::cout <<
"**Err: Not using that method in this example!\n";
void set_parameters(Epetra_SerialDenseVector &x)
std::vector< int > local_nodes
void tensor_product(double scalarAB, Epetra_SerialDenseVector &A, Epetra_SerialDenseVector &B, Epetra_SerialDenseMatrix &AoB, double scalarThis)
rubberblock(Epetra_Comm &comm, Teuchos::ParameterList &Parameters)
std::vector< double > nodes_coord
void compute_cauchy(Epetra_Vector &solution, double &xi, double &eta, double &zeta, std::string &filename)
void apply_dirichlet_conditions(Epetra_FECrsMatrix &K, Epetra_FEVector &F, double &displacement)
void d_shape_functions(Epetra_SerialDenseMatrix &D, double &xi, double &eta, double &zeta)
void dX_shape_functions(Epetra_SerialDenseMatrix &D, Epetra_SerialDenseMatrix JacobianMatrix, double &jac, Epetra_SerialDenseMatrix &DX)
void setup_dirichlet_conditions()
Epetra_SerialDenseVector get_neumannBc(Epetra_SerialDenseMatrix &matrix_X, Epetra_SerialDenseMatrix &xg, unsigned int &gp)
void get_stress_for_recover(Epetra_SerialDenseMatrix &deformation_gradient, double &det, Epetra_SerialDenseMatrix &piola_stress)
std::vector< int > local_cells
clc clear all close all mesh
void d_shape_functions(Epetra_SerialDenseMatrix &D, double &xi, double &eta, double &zeta)
void assemblePureDirichlet_homogeneousForcing(Epetra_Vector &x, Epetra_FECrsMatrix &K, Epetra_FEVector &F)
int n_local_nodes_without_ghosts
void jacobian_det(Epetra_SerialDenseMatrix &JacobianMatrix, double &jac)
void get_material_parameters_for_recover(unsigned int &e_lid)
std::vector< int > cells_nodes
void get_constitutive_tensors(Epetra_SerialDenseMatrix &deformation_gradient, Epetra_SerialDenseVector &piola_stress, Epetra_SerialDenseMatrix &tangent_piola)
Epetra_Import * ImportToOverlapMap
Epetra_SerialDenseVector get_forcing(double &x1, double &x2, double &x3, unsigned int &e_lid, unsigned int &gp)
void get_material_parameters(unsigned int &e_lid, unsigned int &gp)
void sym_tensor_product(double scalarAB, Epetra_SerialDenseVector &A, Epetra_SerialDenseVector &B, Epetra_SerialDenseMatrix &AoB, double scalarThis)
void get_matrix_and_rhs(Epetra_Vector &x, Epetra_FECrsMatrix &K, Epetra_FEVector &F)
void d_shape_functions(Epetra_SerialDenseMatrix &D, double &xi, double &eta, double &zeta)
void jacobian_matrix(Epetra_SerialDenseMatrix &X, Epetra_SerialDenseMatrix &D, Epetra_SerialDenseMatrix &JacobianMatrix)