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;
80 args.AddOption(&order,
"-o",
"--order",
81 "Finite element order (polynomial degree).");
82 args.AddOption(&device_config,
"-d",
"--device",
83 "Device configuration string, see Device::Configure().");
84 args.AddOption(&diagpc_type,
"-pc",
"--pctype",
85 "Select diagonal preconditioner type"
86 " (0:Diagonal, 1:BlockDiagonal).");
87 args.AddOption(&serial_refinement_levels,
"-rs",
"--ref-serial",
88 "Number of uniform refinements on the serial mesh.");
89 args.AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
91 "Enable or disable GLVis visualization.");
92 args.AddOption(¶view,
"-pv",
"--paraview",
"-no-pv",
94 "Enable or disable ParaView DataCollection output.");
97 Device device(device_config);
107 MFEM_ABORT(
"This example only works in 3D.");
111 for (
int l = 0; l < serial_refinement_levels; l++)
113 mesh.UniformRefinement();
116 ParMesh pmesh(MPI_COMM_WORLD, mesh);
133 elasticity_op.SetMaterial(
material);
138 if (pmesh.bdr_attributes.Size())
140 Array<int> ess_attr(pmesh.bdr_attributes.Max());
144 elasticity_op.SetEssentialAttributes(ess_attr);
150 if (pmesh.bdr_attributes.Size())
152 Array<int> displaced_attr(pmesh.bdr_attributes.Max());
154 displaced_attr[2] = 1;
155 elasticity_op.SetPrescribedDisplacement(displaced_attr);
165 U.
SetSubVector(elasticity_op.GetPrescribedDisplacementTDofs(), 1.0e-2);
173 cg.SetMaxIter(10000);
175 cg.SetPreconditioner(diagonal_pc);
178 newton.SetSolver(cg);
179 newton.SetOperator(elasticity_op);
180#ifdef MFEM_USE_SINGLE
181 newton.SetRelTol(1e-4);
182#elif defined MFEM_USE_DOUBLE
183 newton.SetRelTol(1e-6);
185 MFEM_ABORT(
"Floating point type undefined");
187 newton.SetMaxIter(10);
188 newton.SetPrintLevel(1);
191 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).