38int main(
int argc,
char *argv[])
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);
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());
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
Conjugate gradient method.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
virtual void Mult(const Vector &b, Vector &x) const
Iterative solution of the linear system using the Conjugate Gradient method.
A coefficient that is constant across space and time.
Class for grid function - Vector with associated FE space.
Arbitrary order H1-conforming (continuous) finite elements.
The BoomerAMG solver in hypre.
void SetPrintLevel(int print_level)
Wrapper for hypre's ParCSR matrix class.
MPI_Comm GetComm() const
MPI communicator.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
void SetRelTol(real_t rtol)
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
void SetMaxIter(int max_it)
The L2ZienkiewiczZhuEstimator class implements the Zienkiewicz-Zhu error estimation procedure where t...
Arbitrary order "L2-conforming" discontinuous finite elements.
bool Apply(Mesh &mesh)
Perform the mesh operation.
bool Stop() const
Check if STOP action is requested, e.g. stopping criterion is satisfied.
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
NURBSExtension * NURBSext
Optional NURBS mesh extension.
bool Nonconforming() const
void Clear()
Clear the contents of the Mesh.
int Dimension() const
Dimension of the reference space used within the elements.
int SpaceDimension() const
Dimension of the physical space containing the mesh.
void GetNodes(Vector &node_coord) const
void EnsureNCMesh(bool simplices_nonconforming=false)
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.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
void SwapNodes(GridFunction *&nodes, int &own_nodes_)
Swap the internal node GridFunction pointer and ownership flag members with the given ones.
Array< int > attributes
A list of all unique element attributes used by the Mesh.
static int WorldRank()
Return the MPI rank in MPI_COMM_WORLD.
static int WorldSize()
Return the size of MPI_COMM_WORLD.
static void Init(int &argc, char **&argv, int required=default_thread_required, int *provided=nullptr)
Singleton creation with Mpi::Init(argc, argv).
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void PrintUsage(std::ostream &out) const
Print the usage message.
void PrintOptions(std::ostream &out) const
Print the options.
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...
bool Good() const
Return true if the command line options were parsed successfully.
A piecewise constant coefficient with the constants keyed off the element attribute numbers.
Abstract parallel finite element space.
void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1) const override
HYPRE_BigInt GlobalTrueVSize() const
void Update(bool want_transform=true) override
Class for parallel grid function.
void Save(std::ostream &out) const override
void ProjectBdrCoefficient(Coefficient *coeff[], VectorCoefficient *vcoeff, const Array< int > &attr)
void Update() override
Transform by the Space UpdateMatrix (e.g., on Mesh change).
Class for parallel meshes.
void Print(std::ostream &out=mfem::out, const std::string &comments="") const override
Mesh refinement operator using an error threshold.
void SetTotalErrorFraction(real_t fraction)
Set the total fraction used in the computation of the threshold. The default value is 1/2.
Vector coefficient defined by an array of scalar coefficients. Coefficients that are not set will eva...
Vector coefficient that is constant in space and time.
void Neg()
(*this) = -(*this)
Vector & Set(const real_t a, const Vector &x)
(*this) = a * x
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
std::function< real_t(const Vector &)> f(real_t mass_coeff)