49 os << R
"(
___ ___ ________ ________ ____ __.___________
/ | \\_____ \ \_____ \ | |/ _|\_ _____/
/ ~ \/ | \ / | \| < | __)_
\ Y / | \/ | \ | \ | \
\___|_ /\_______ /\_______ /____|__ \/_______ /
\/ \/ \/ \/ \/
)"
53 int main(
int argc,
char *argv[])
55 Mpi::Init(argc, argv);
56 int num_procs = Mpi::WorldSize();
57 int myid = Mpi::WorldRank();
60 const char *device_config =
"cpu";
61 int diagpc_type = ElasticityDiagonalPreconditioner::Type::Diagonal;
62 int serial_refinement_levels = 0;
63 bool visualization =
true;
64 bool paraview =
false;
72 args.AddOption(&order,
"-o",
"--order",
73 "Finite element order (polynomial degree).");
74 args.AddOption(&device_config,
"-d",
"--device",
75 "Device configuration string, see Device::Configure().");
76 args.AddOption(&diagpc_type,
"-pc",
"--pctype",
77 "Select diagonal preconditioner type"
78 " (0:Diagonal, 1:BlockDiagonal).");
79 args.AddOption(&serial_refinement_levels,
"-rs",
"--ref-serial",
80 "Number of uniform refinements on the serial mesh.");
81 args.AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
83 "Enable or disable GLVis visualization.");
84 args.AddOption(¶view,
"-pv",
"--paraview",
"-no-pv",
86 "Enable or disable ParaView DataCollection output.");
89 Device device(device_config);
96 Mesh::MakeCartesian3D(8, 2, 2, Element::HEXAHEDRON, 8.0, 1.0, 1.0);
99 MFEM_ABORT(
"This example only works in 3D.");
103 for (
int l = 0; l < serial_refinement_levels; l++)
105 mesh.UniformRefinement();
108 ParMesh pmesh(MPI_COMM_WORLD, mesh);
125 elasticity_op.SetMaterial(
material);
130 if (pmesh.bdr_attributes.Size())
132 Array<int> ess_attr(pmesh.bdr_attributes.Max());
136 elasticity_op.SetEssentialAttributes(ess_attr);
142 if (pmesh.bdr_attributes.Size())
144 Array<int> displaced_attr(pmesh.bdr_attributes.Max());
146 displaced_attr[2] = 1;
147 elasticity_op.SetPrescribedDisplacement(displaced_attr);
157 U.
SetSubVector(elasticity_op.GetPrescribedDisplacementTDofs(), 1.0e-2);
161 static_cast<ElasticityDiagonalPreconditioner::Type>(diagpc_type));
165 cg.SetMaxIter(10000);
167 cg.SetPreconditioner(diagonal_pc);
170 newton.SetSolver(cg);
171 newton.SetOperator(elasticity_op);
172 newton.SetRelTol(1e-6);
173 newton.SetMaxIter(10);
174 newton.SetPrintLevel(1);
177 newton.Mult(zero, U);
186 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
187 sol_sock.precision(8);
188 sol_sock <<
"solution\n" << pmesh << U_gf << flush;
194 pd.RegisterField(
"solution", &U_gf);
195 pd.SetLevelsOfDetail(order);
196 pd.SetDataFormat(VTKFormat::BINARY);
197 pd.SetHighOrderOutput(
true);
205 void SetSubVector(const Array< int > &dofs, const double value)
Set the entries listed in dofs to the given value.
Conjugate gradient method.
Helper class for ParaView visualization data.
int material(Vector &x, Vector &xmin, Vector &xmax)
Newton's method for solving F(x)=b for a given operator F.
constexpr int dimension
This example only works in 3D. Kernels for 2D are not implemented.
ElasticityDiagonalPreconditioner acts as a matrix-free preconditioner for ElasticityOperator.
Class for parallel grid function.
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
The MFEM Device class abstracts hardware devices such as GPUs, as well as programming models such as ...
void display_banner(ostream &os)
Class for parallel meshes.