38 int main(
int argc,
char *argv[])
42 MPI_Init(&argc, &argv);
43 MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
44 MPI_Comm_rank(MPI_COMM_WORLD, &myid);
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.");
83 Mesh mesh(mesh_file, 1, 1);
89 cerr <<
"\nInput mesh should have at least two materials and "
90 <<
"two boundary attributes! (See schematic in ex2.cpp)\n"
100 if (mesh.
NURBSext && serial_ref_levels == 0)
102 serial_ref_levels = 2;
104 for (
int i = 0; i < serial_ref_levels; i++)
114 ParMesh pmesh(MPI_COMM_WORLD, mesh);
133 for (
int i = 0; i < dim-1; i++)
140 pull_force(1) = -1.0e-2;
152 lambda(0) = lambda(1)*50;
194 const int tdim = dim*(dim+1)/2;
199 smooth_flux_fespace);
210 const int max_dofs = 50000;
211 const int max_amr_itr = 20;
212 for (
int it = 0; it <= max_amr_itr; it++)
217 cout <<
"\nAMR iteration " << it << endl;
218 cout <<
"Number of unknowns: " << global_dofs << endl;
237 const int copy_interior = 1;
250 pcg.SetPrintLevel(3);
259 if (visualization && it == 0)
261 sol_sock.
open(vishost, visport);
262 sol_sock.precision(8);
264 if (visualization && sol_sock.good())
272 sol_sock <<
"parallel " << num_procs <<
' ' << myid <<
'\n';
273 sol_sock <<
"solution\n" << pmesh << x << flush;
278 sol_sock <<
"keys '" << ((dim == 2) ?
"Rjl" :
"") <<
"m'" << endl;
280 sol_sock <<
"window_title 'AMR iteration: " << it <<
"'\n"
284 cout <<
"Visualization paused. "
285 "Press <space> in the GLVis window to continue." << endl;
289 if (global_dofs > max_dofs)
293 cout <<
"Reached the maximum number of dofs. Stop." << endl;
302 refiner.
Apply(pmesh);
307 cout <<
"Stopping criterion satisfied. Stop." << endl;
340 ostringstream mref_name, mesh_name, sol_name;
341 mref_name <<
"ex21p_reference_mesh." << setfill(
'0') << setw(6) << myid;
342 mesh_name <<
"ex21p_deformed_mesh." << setfill(
'0') << setw(6) << myid;
343 sol_name <<
"ex21p_displacement." << setfill(
'0') << setw(6) << myid;
345 ofstream mesh_ref_out(mref_name.str().c_str());
346 mesh_ref_out.precision(16);
347 pmesh.
Print(mesh_ref_out);
349 ofstream mesh_out(mesh_name.str().c_str());
350 mesh_out.precision(16);
356 pmesh.
Print(mesh_out);
359 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.
MPI_Comm GetComm() const
MPI communicator.
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.
A coefficient that is constant across space and time.
Vector coefficient that is constant in space and time.
void SwapNodes(GridFunction *&nodes, int &own_nodes_)
virtual void Update(bool want_transform=true)
virtual void Save(std::ostream &out) const
bool Stop() const
Check if STOP action is requested, e.g. stopping criterion is satisfied.
Abstract parallel finite element space.
int main(int argc, char *argv[])
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.
bool Nonconforming() const
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)
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
HYPRE_Int GlobalTrueVSize() const
void Set(int i, Coefficient *c, bool own=true)
Sets coefficient in the vector.
virtual void Print(std::ostream &out=mfem::out) const
void PrintUsage(std::ostream &out) const
Print the usage message.
int SpaceDimension() const
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...
NURBSExtension * NURBSext
Optional NURBS mesh extension.
A piecewise constant coefficient with the constants keyed off the element attribute numbers...
void PrintOptions(std::ostream &out) const
Print the options.
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
void Clear()
Clear the contents of the Mesh.
void GetNodes(Vector &node_coord) const
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
Arbitrary order H1-conforming (continuous) finite elements.
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.
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)
bool Good() const
Return true if the command line options were parsed successfully.