38 int main(
int argc,
char *argv[])
41 Mpi::Init(argc, argv);
42 int num_procs = Mpi::WorldSize();
43 int myid = Mpi::WorldRank();
47 const char *mesh_file =
"../data/beam-tri.mesh";
48 int serial_ref_levels = 0;
50 bool static_cond =
false;
51 bool visualization = 1;
54 args.
AddOption(&mesh_file,
"-m",
"--mesh",
56 args.
AddOption(&serial_ref_levels,
"-rs",
"--refine-serial",
57 "Number of uniform serial refinements (before parallel" 60 "Finite element order (polynomial degree).");
61 args.
AddOption(&static_cond,
"-sc",
"--static-condensation",
"-no-sc",
62 "--no-static-condensation",
"Enable static condensation.");
63 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
65 "Enable or disable GLVis visualization.");
82 Mesh mesh(mesh_file, 1, 1);
88 cerr <<
"\nInput mesh should have at least two materials and " 89 <<
"two boundary attributes! (See schematic in ex2.cpp)\n" 98 if (mesh.
NURBSext && serial_ref_levels == 0)
100 serial_ref_levels = 2;
102 for (
int i = 0; i < serial_ref_levels; i++)
112 ParMesh pmesh(MPI_COMM_WORLD, mesh);
131 for (
int i = 0; i <
dim-1; i++)
138 pull_force(1) = -1.0e-2;
150 lambda(0) = lambda(1)*50;
160 a.AddDomainIntegrator(integ);
161 if (static_cond) {
a.EnableStaticCondensation(); }
192 const int tdim =
dim*(
dim+1)/2;
197 smooth_flux_fespace);
208 const int max_dofs = 50000;
209 const int max_amr_itr = 20;
210 for (
int it = 0; it <= max_amr_itr; it++)
215 cout <<
"\nAMR iteration " << it << endl;
216 cout <<
"Number of unknowns: " << global_dofs << endl;
235 const int copy_interior = 1;
236 a.FormLinearSystem(ess_tdof_list, x,
b, A, X, B, copy_interior);
248 pcg.SetPrintLevel(3);
254 a.RecoverFEMSolution(X,
b, x);
257 if (visualization && it == 0)
260 sol_sock.precision(8);
262 if (visualization && sol_sock.good())
270 sol_sock <<
"parallel " << num_procs <<
' ' << myid <<
'\n';
271 sol_sock <<
"solution\n" << pmesh << x << flush;
276 sol_sock <<
"keys '" << ((
dim == 2) ?
"Rjl" :
"") <<
"m'" << endl;
278 sol_sock <<
"window_title 'AMR iteration: " << it <<
"'\n" 282 cout <<
"Visualization paused. " 283 "Press <space> in the GLVis window to continue." << endl;
287 if (global_dofs > max_dofs)
291 cout <<
"Reached the maximum number of dofs. Stop." << endl;
300 refiner.
Apply(pmesh);
305 cout <<
"Stopping criterion satisfied. Stop." << endl;
338 ostringstream mref_name, mesh_name, sol_name;
339 mref_name <<
"ex21p_reference_mesh." << setfill(
'0') << setw(6) << myid;
340 mesh_name <<
"ex21p_deformed_mesh." << setfill(
'0') << setw(6) << myid;
341 sol_name <<
"ex21p_displacement." << setfill(
'0') << setw(6) << myid;
343 ofstream mesh_ref_out(mref_name.str().c_str());
344 mesh_ref_out.precision(16);
345 pmesh.
Print(mesh_ref_out);
347 ofstream mesh_out(mesh_name.str().c_str());
348 mesh_out.precision(16);
354 pmesh.
Print(mesh_out);
357 ofstream x_out(sol_name.str().c_str());
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1)
Conjugate gradient method.
Vector coefficient defined by an array of scalar coefficients. Coefficients that are not set will eva...
Class for grid function - Vector with associated FE space.
int main(int argc, char *argv[])
A coefficient that is constant across space and time.
void PrintOptions(std::ostream &out) const
Print the options.
int Dimension() const
Dimension of the reference space used within the elements.
void PrintUsage(std::ostream &out) const
Print the usage message.
Vector coefficient that is constant in space and time.
void SwapNodes(GridFunction *&nodes, int &own_nodes_)
Swap the internal node GridFunction pointer and ownership flag members with the given ones...
virtual void Update(bool want_transform=true)
bool Nonconforming() const
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
bool Good() const
Return true if the command line options were parsed successfully.
Abstract parallel finite element space.
The L2ZienkiewiczZhuEstimator class implements the Zienkiewicz-Zhu error estimation procedure where t...
The BoomerAMG solver in hypre.
bool Apply(Mesh &mesh)
Perform the mesh operation.
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void EnsureNCMesh(bool simplices_nonconforming=false)
virtual void Update()
Transform by the Space UpdateMatrix (e.g., on Mesh change).
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
void SetPrintLevel(int print_level)
Mesh refinement operator using an error threshold.
virtual void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1)
Set the curvature of the mesh nodes using the given polynomial degree.
HYPRE_BigInt GlobalTrueVSize() const
MPI_Comm GetComm() const
MPI communicator.
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
void ProjectBdrCoefficient(Coefficient *coeff[], VectorCoefficient *vcoeff, Array< int > &attr)
void AddOption(bool *var, const char *enable_short_name, const char *enable_long_name, const char *disable_short_name, const char *disable_long_name, const char *description, bool required=false)
Add a boolean option and set 'var' to receive the value. Enable/disable tags are used to set the bool...
int SpaceDimension() const
Dimension of the physical space containing the mesh.
virtual void Save(std::ostream &out) const
NURBSExtension * NURBSext
Optional NURBS mesh extension.
A piecewise constant coefficient with the constants keyed off the element attribute numbers...
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
void Clear()
Clear the contents of the Mesh.
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
Arbitrary order H1-conforming (continuous) finite elements.
void GetNodes(Vector &node_coord) const
void Print(std::ostream &out=mfem::out) const override
Class for parallel grid function.
void SetTotalErrorFraction(double fraction)
Set the total fraction used in the computation of the threshold. The default value is 1/2...
Wrapper for hypre's ParCSR matrix class.
bool Stop() const
Check if STOP action is requested, e.g. stopping criterion is satisfied.
Class for parallel meshes.
Array< int > attributes
A list of all unique element attributes used by the Mesh.
Arbitrary order "L2-conforming" discontinuous finite elements.
double f(const Vector &p)
void Neg()
(*this) = -(*this)