15 std::string mesh_file = Teuchos::getParameter<std::string>(Parameters.sublist(
"Mesh"),
"mesh_file");
17 gc = Teuchos::getParameter<double>(Parameters.sublist(
"Damage"),
"gc");
18 lc = Teuchos::getParameter<double>(Parameters.sublist(
"Damage"),
"lc");
19 E = Teuchos::getParameter<double>(Parameters.sublist(
"Elasticity"),
"young");
20 nu = Teuchos::getParameter<double>(Parameters.sublist(
"Elasticity"),
"poisson");
22 Mesh =
new mesh(comm, mesh_file, 1.0);
27 StandardMap =
new Epetra_Map(-1, 3*Mesh->n_local_nodes_without_ghosts, &Mesh->local_dof_without_ghosts[0], 0, *
Comm);
28 OverlapMap =
new Epetra_Map(-1, 3*Mesh->n_local_nodes, &Mesh->local_dof[0], 0, *
Comm);
34 lambda = E*nu/((1.0+
nu)*(1.0-2.0*nu));
35 mu = E/(2.0*(1.0+
nu));
38 double c11 = E*(1.0-
nu)/((1.0+nu)*(1.0-2.0*
nu));
39 double c12 = E*nu/((1.0+
nu)*(1.0-2.0*nu));
40 double c44 = E/(2.0*(1.0+
nu));
53 double delta_u = Teuchos::getParameter<double>(ParametersList.sublist(
"Elasticity"),
"delta_u");
54 int n_steps = Teuchos::getParameter<int>(ParametersList.sublist(
"Elasticity"),
"n_steps");
56 Epetra_Time Time(*
Comm);
59 Epetra_FECrsMatrix matrix_u(Copy,*
FEGraph);
68 Epetra_Vector damageHistory(GaussMap);
70 if (
Comm->MyPID()==0){
71 std::cout <<
"step" << std::setw(15) <<
"cpu_time (s)" <<
"\n";
75 damageHistory.PutScalar(0.0);
76 for (
int n=0; n<n_steps; ++n){
78 Time.ResetStartTime();
80 damageInterface->solve(ParametersList.sublist(
"Damage"), matrix_d, lhs_d, rhs_d, damageHistory, GaussMap);
84 bc_disp = (double(n)+1.0)*delta_u;
89 if (
Comm->MyPID()==0){
90 std::cout << n << std::setw(15) << Time.ElapsedTime() <<
"\n";
94 std::string dispfile =
"/home/s/staber/Trilinos_results/examples/phasefield/displacement" + std::to_string(
int(n)) +
".mtx";
95 std::string damgfile =
"/home/s/staber/Trilinos_results/examples/phasefield/damage" + std::to_string(
int(n)) +
".mtx";
105 Epetra_FECrsMatrix & matrix, Epetra_Vector & lhs, Epetra_FEVector & rhs,
114 int max_iter = Teuchos::getParameter<int>(Parameters.sublist(
"Aztec"),
"AZ_max_iter");
115 double tol = Teuchos::getParameter<double>(Parameters.sublist(
"Aztec"),
"AZ_tol");
117 Epetra_LinearProblem problem(&matrix, &lhs, &rhs);
119 AztecOO solver(problem);
120 solver.SetParameters(Parameters.sublist(
"Aztec"));
121 solver.Iterate(max_iter, tol);
125 Epetra_Vector & displacement,
126 Epetra_Map & GaussMap){
135 double trepsilon, trepsilon2, potential, history;
137 Epetra_SerialDenseMatrix dx_shape_functions(
Mesh->
el_type,3);
138 Epetra_SerialDenseMatrix matrix_B(6,3*
Mesh->
el_type);
140 Epetra_SerialDenseVector epsilon(6);
145 for (
unsigned int inode=0; inode<
Mesh->
el_type; ++inode){
147 for (
unsigned int ddl=0; ddl<3; ++ddl){
149 cells_u(3*inode+ddl) = u[
OverlapMap->LID(
id)];
152 for (
unsigned int gp=0; gp<n_gauss_points; ++gp){
153 for (
unsigned int inode=0; inode<
Mesh->
el_type; ++inode){
154 dx_shape_functions(inode,0) =
Mesh->
DX_N_cells(gp+n_gauss_points*inode,elid);
155 dx_shape_functions(inode,1) =
Mesh->
DY_N_cells(gp+n_gauss_points*inode,elid);
156 dx_shape_functions(inode,2) =
Mesh->
DZ_N_cells(gp+n_gauss_points*inode,elid);
160 epsilon.Multiply(
'N',
'N',1.0,matrix_B,cells_u,0.0);
162 trepsilon = epsilon(0) + epsilon(1) + epsilon(2);
163 trepsilon2 = epsilon(0)*epsilon(0) + epsilon(1)*epsilon(1) + epsilon(2)*epsilon(2) +
164 0.5*epsilon(3)*epsilon(3) + 0.5*epsilon(4)*epsilon(4) + 0.5*epsilon(5)*epsilon(5);
166 id = n_gauss_points*egid+gp;
167 history = damageHistory[GaussMap.LID(
id)];
168 potential = (
lambda/2.0)*trepsilon*trepsilon +
mu*trepsilon2;
169 if (potential>history){
170 damageHistory[GaussMap.LID(
id)] = potential;
181 std::vector<int> local_gauss_points(n_local_cells*n_gauss_cells);
182 for (
unsigned int e_lid=0; e_lid<n_local_cells; ++e_lid){
184 for (
unsigned int gp=0; gp<n_gauss_cells; ++gp){
185 local_gauss_points[e_lid*n_gauss_cells+gp] = e_gid*n_gauss_cells+gp;
189 Epetra_Map GaussMap(-1, n_local_cells*n_gauss_cells, &local_gauss_points[0], 0, *
Comm);
195 Epetra_SerialDenseMatrix & tangent_matrix){
220 double g = (1.0-d)*(1.0-d) + 1.0e-6;
222 tangent_matrix.Scale(g);
226 Epetra_SerialDenseMatrix & tangent_matrix){
227 std::cout <<
"Not using this method yet.\n";
void updateDamageHistory(Epetra_Vector &damageHistory, Epetra_Vector &displacement, Epetra_Map &GaussMap)
Epetra_Vector * damageSolutionOverlaped
int print_solution(Epetra_Vector &solution, std::string fileName)
void shape_functions(Epetra_SerialDenseVector &N, double &xi, double &eta, double &zeta)
Epetra_SerialDenseVector DZ_N_cells
void get_elasticity_tensor_for_recovery(unsigned int &e_lid, Epetra_SerialDenseMatrix &tangent_matrix)
void initialize(Epetra_Comm &comm, Teuchos::ParameterList &Parameters)
void computeDisplacement(Teuchos::ParameterList &ParameterList, Epetra_FECrsMatrix &matrix, Epetra_Vector &lhs, Epetra_FEVector &rhs, double &bc_disp)
virtual void apply_dirichlet_conditions(Epetra_FECrsMatrix &K, Epetra_FEVector &F, double &displacement)
Epetra_SerialDenseVector eta_cells
void staggeredAlgorithmDirichletBC(Teuchos::ParameterList &ParametersList, bool print)
Epetra_SerialDenseVector xi_cells
Epetra_SerialDenseVector DX_N_cells
Epetra_FECrsGraph * FEGraph
void compute_B_matrices(Epetra_SerialDenseMatrix &dx_shape_functions, Epetra_SerialDenseMatrix &B)
std::vector< int > local_cells
clc clear all close all mesh
void shape_functions(Epetra_SerialDenseVector &N, double &xi, double &eta, double &zeta)
Epetra_SerialDenseVector DY_N_cells
std::vector< int > cells_nodes
void assemblePureDirichlet_homogeneousForcing(Epetra_FECrsMatrix &K)
Epetra_Import * ImportToOverlapMap
void shape_functions(Epetra_SerialDenseVector &N, double &xi, double &eta)
Teuchos::RCP< damageField > damageInterface
unsigned int n_gauss_cells
Epetra_SerialDenseMatrix elasticity
void get_elasticity_tensor(unsigned int &e_lid, unsigned int &gp, Epetra_SerialDenseMatrix &tangent_matrix)
~phaseFieldLinearizedElasticity()
Epetra_SerialDenseVector zeta_cells
Epetra_Map constructGaussMap()
phaseFieldLinearizedElasticity()
void shape_functions(Epetra_SerialDenseVector &N, double &xi, double &eta, double &zeta)