25 Epetra_Vector & damageHistory, Epetra_Map & GaussMap){
27 matrix.PutScalar(0.0);
33 Epetra_SerialDenseMatrix dx_shape_functions(3,
Mesh->
el_type);
37 double gauss_weight, hn, an;
49 ke(inode,jnode) = 0.0;
50 me(inode,jnode) = 0.0;
54 for (
unsigned int gp=0; gp<n_gauss_points; ++gp){
56 id = n_gauss_points*eglob+gp;
57 hn = damageHistory[GaussMap.LID(
id)];
58 an = 2.0*hn +
gc/double(lc);
59 for (
unsigned int inode=0; inode<
Mesh->
el_type; ++inode){
60 dx_shape_functions(0,inode) =
Mesh->
DX_N_cells(gp+n_gauss_points*inode,eloc);
61 dx_shape_functions(1,inode) =
Mesh->
DY_N_cells(gp+n_gauss_points*inode,eloc);
62 dx_shape_functions(2,inode) =
Mesh->
DZ_N_cells(gp+n_gauss_points*inode,eloc);
67 ke.Multiply(
'T',
'N',bn*gauss_weight*
Mesh->
detJac_cells(eloc,gp),dx_shape_functions,dx_shape_functions,1.0);
71 for (
unsigned int inode=0; inode<
Mesh->
el_type; ++inode){
72 rhs.SumIntoGlobalValues(1, &index[inode], &fe(inode));
73 for (
unsigned int jnode=0; jnode<
Mesh->
el_type; ++jnode){
74 matrix.SumIntoGlobalValues(1, &index[inode], 1, &index[jnode], &ke(inode,jnode));
81 matrix.GlobalAssemble();
82 matrix.FillComplete();
89 Epetra_FECrsMatrix & matrix, Epetra_Vector & lhs, Epetra_FEVector & rhs,
90 Epetra_Vector & damageHistory,
91 Epetra_Map & GaussMap){
93 assemble(matrix, rhs, damageHistory, GaussMap);
95 double tol = Teuchos::getParameter<double>(Parameters.sublist(
"Aztec"),
"AZ_tol");
96 int max_iter = Teuchos::getParameter<int>(Parameters.sublist(
"Aztec"),
"AZ_max_iter");
100 Epetra_LinearProblem problem(&matrix, &lhs, &rhs);
102 AztecOO solver(problem);
103 solver.SetParameters(Parameters.sublist(
"Aztec"));
104 solver.Iterate(max_iter, tol);
122 FEGraph->InsertGlobalIndices(1, &index[
i], 1, &index[
j]);
132 std::cout <<
"No essential boundary conditions.\n";
136 std::cout <<
"No essential boundary conditions.\n";
140 int NumTargetElements = 0;
141 if (
Comm->MyPID()==0){
144 Epetra_Map MapOnRoot(-1,NumTargetElements,0,*
Comm);
145 Epetra_Export ExportOnRoot(*
StandardMap,MapOnRoot);
146 Epetra_MultiVector lhs_root(MapOnRoot,
true);
147 lhs_root.Export(lhs,ExportOnRoot,Insert);
148 int error = EpetraExt::MultiVectorToMatrixMarketFile(fileName.c_str(),lhs_root,0,0,
false);
damageField(Epetra_Comm &comm, mesh &mesh, double &gc_, double &lc_)
std::vector< int > local_nodes
Epetra_SerialDenseVector DZ_N_cells
Epetra_SerialDenseVector N_cells
Epetra_SerialDenseVector DX_N_cells
Epetra_FECrsGraph * FEGraph
Epetra_SerialDenseVector detJac_cells
std::vector< int > local_cells
clc clear all close all mesh
void assemble(Epetra_FECrsMatrix &matrix, Epetra_FEVector &rhs, Epetra_Vector &damageHistory, Epetra_Map &GaussMap)
int n_local_nodes_without_ghosts
Epetra_SerialDenseVector DY_N_cells
std::vector< int > cells_nodes
void solve(Teuchos::ParameterList &Parameters, Epetra_FECrsMatrix &matrix, Epetra_Vector &lhs, Epetra_FEVector &rhs, Epetra_Vector &damageHistory, Epetra_Map &GaussMap)
Epetra_Import * ImportToOverlapMap
void shape_functions(Epetra_SerialDenseVector &N, double &xi, double &eta)
unsigned int n_gauss_cells
std::vector< int > local_nodes_without_ghosts
void apply_dirichlet_conditions(Epetra_FECrsMatrix &K, Epetra_FEVector &F, double &displacement)
Epetra_SerialDenseVector gauss_weight_cells
int print_solution(Epetra_Vector &lhs, std::string fileName)
void setup_dirichlet_conditions()