53 \ Y / | \/ | \ | \ | \
54 \___|_ /\_______ /\_______ /____|__ \/_______ /
60int main(
int argc,
char *argv[])
67 const char *device_config =
"cpu";
68 int diagpc_type = ElasticityDiagonalPreconditioner::Type::Diagonal;
69 int serial_refinement_levels = 0;
70 bool visualization =
true;
71 bool paraview =
false;
79 args.AddOption(&order,
"-o",
"--order",
80 "Finite element order (polynomial degree).");
81 args.AddOption(&device_config,
"-d",
"--device",
82 "Device configuration string, see Device::Configure().");
83 args.AddOption(&diagpc_type,
"-pc",
"--pctype",
84 "Select diagonal preconditioner type"
85 " (0:Diagonal, 1:BlockDiagonal).");
86 args.AddOption(&serial_refinement_levels,
"-rs",
"--ref-serial",
87 "Number of uniform refinements on the serial mesh.");
88 args.AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
90 "Enable or disable GLVis visualization.");
91 args.AddOption(¶view,
"-pv",
"--paraview",
"-no-pv",
93 "Enable or disable ParaView DataCollection output.");
96 Device device(device_config);
106 MFEM_ABORT(
"This example only works in 3D.");
110 for (
int l = 0; l < serial_refinement_levels; l++)
112 mesh.UniformRefinement();
115 ParMesh pmesh(MPI_COMM_WORLD, mesh);
132 elasticity_op.SetMaterial(
material);
137 if (pmesh.bdr_attributes.Size())
139 Array<int> ess_attr(pmesh.bdr_attributes.Max());
143 elasticity_op.SetEssentialAttributes(ess_attr);
149 if (pmesh.bdr_attributes.Size())
151 Array<int> displaced_attr(pmesh.bdr_attributes.Max());
153 displaced_attr[2] = 1;
154 elasticity_op.SetPrescribedDisplacement(displaced_attr);
164 U.
SetSubVector(elasticity_op.GetPrescribedDisplacementTDofs(), 1.0e-2);
172 cg.SetMaxIter(10000);
174 cg.SetPreconditioner(diagonal_pc);
177 newton.SetSolver(cg);
178 newton.SetOperator(elasticity_op);
179#ifdef MFEM_USE_SINGLE
180 newton.SetRelTol(1e-4);
181#elif defined MFEM_USE_DOUBLE
182 newton.SetRelTol(1e-6);
184 MFEM_ABORT(
"Floating point type undefined");
186 newton.SetMaxIter(10);
187 newton.SetPrintLevel(1);
190 newton.Mult(zero, U);
199 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
200 sol_sock.precision(8);
201 sol_sock <<
"solution\n" << pmesh << U_gf << flush;
207 pd.RegisterField(
"solution", &U_gf);
208 pd.SetLevelsOfDetail(order);
209 pd.SetDataFormat(VTKFormat::BINARY);
210 pd.SetHighOrderOutput(
true);
static Mesh MakeCartesian3D(int nx, int ny, int nz, Element::Type type, real_t sx=1.0, real_t sy=1.0, real_t sz=1.0, bool sfc_ordering=true)
Creates a mesh for the parallelepiped [0,sx]x[0,sy]x[0,sz], divided into nx*ny*nz hexahedra if type =...
static void Init(int &argc, char **&argv, int required=default_thread_required, int *provided=nullptr)
Singleton creation with Mpi::Init(argc, argv).