39int main(
int argc,
char *argv[])
42 const char *mesh_file =
"../data/beam-tri.mesh";
44 bool static_cond =
false;
45 int flux_averaging = 0;
46 bool visualization = 1;
49 args.
AddOption(&mesh_file,
"-m",
"--mesh",
52 "Finite element order (polynomial degree).");
53 args.
AddOption(&static_cond,
"-sc",
"--static-condensation",
"-no-sc",
54 "--no-static-condensation",
"Enable static condensation.");
55 args.
AddOption(&flux_averaging,
"-f",
"--flux-averaging",
56 "Flux averaging: 0 - global, 1 - by mesh attribute.");
57 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
59 "Enable or disable GLVis visualization.");
70 Mesh mesh(mesh_file, 1, 1);
76 cerr <<
"\nInput mesh should have at least two materials and "
77 <<
"two boundary attributes! (See schematic in ex2.cpp)\n"
87 for (
int i = 0; i < 2; i++)
110 for (
int i = 0; i <
dim-1; i++)
117 pull_force(1) = -1.0e-2;
129 lambda(0) = lambda(1)*50;
139 a.AddDomainIntegrator(integ);
140 if (static_cond) {
a.EnableStaticCondensation(); }
166 sol_sock.precision(8);
176 const int tdim =
dim*(
dim+1)/2;
190 const int max_dofs = 50000;
191 const int max_amr_itr = 20;
192 for (
int it = 0; it <= max_amr_itr; it++)
195 cout <<
"\nAMR iteration " << it << endl;
196 cout <<
"Number of unknowns: " << cdofs << endl;
213 const int copy_interior = 1;
214 a.FormLinearSystem(ess_tdof_list, x,
b, A, X, B, copy_interior);
216#ifndef MFEM_USE_SUITESPARSE
220 PCG(A, M, B, X, 3, 2000, 1e-12, 0.0);
225 umf_solver.
Control[UMFPACK_ORDERING] = UMFPACK_ORDERING_METIS;
227 umf_solver.
Mult(B, X);
233 a.RecoverFEMSolution(X,
b, x);
236 if (visualization && sol_sock.good())
244 sol_sock <<
"solution\n" << mesh << x << flush;
249 sol_sock <<
"keys '" << ((
dim == 2) ?
"Rjl" :
"") <<
"m'" << endl;
251 sol_sock <<
"window_title 'AMR iteration: " << it <<
"'\n"
253 cout <<
"Visualization paused. "
254 "Press <space> in the GLVis window to continue." << endl;
257 if (cdofs > max_dofs)
259 cout <<
"Reached the maximum number of dofs. Stop." << endl;
270 cout <<
"Stopping criterion satisfied. Stop." << endl;
290 ofstream mesh_ref_out(
"ex21_reference.mesh");
291 mesh_ref_out.precision(16);
292 mesh.
Print(mesh_ref_out);
294 ofstream mesh_out(
"ex21_deformed.mesh");
295 mesh_out.precision(16);
301 mesh.
Print(mesh_out);
304 ofstream x_out(
"ex21_displacement.sol");
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
A coefficient that is constant across space and time.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1) const
Get a list of essential true dofs, ess_tdof_list, corresponding to the boundary attributes marked in ...
virtual void Update(bool want_transform=true)
Reflect changes in the mesh: update number of DOFs, etc. Also, calculate GridFunction transformation ...
Data type for Gauss-Seidel smoother of sparse matrix.
Class for grid function - Vector with associated FE space.
virtual void Update()
Transform by the Space UpdateMatrix (e.g., on Mesh change).
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
void ProjectBdrCoefficient(Coefficient &coeff, const Array< int > &attr)
Project a Coefficient on the GridFunction, modifying only DOFs on the boundary associated with the bo...
Arbitrary order H1-conforming (continuous) 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.
virtual void Print(std::ostream &os=mfem::out, const std::string &comments="") const
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
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.
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.
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.
Direct sparse solver using UMFPACK.
virtual void SetOperator(const Operator &op)
Factorize the given Operator op which must be a SparseMatrix.
real_t Control[UMFPACK_CONTROL]
virtual void Mult(const Vector &b, Vector &x) const
Direct solution of the linear system using UMFPACK.
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
The ZienkiewiczZhuEstimator class implements the Zienkiewicz-Zhu error estimation procedure.
void SetFluxAveraging(int fa)
Set the way the flux is averaged (smoothed) across elements.
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
void PCG(const Operator &A, Solver &B, const Vector &b, Vector &x, int print_iter, int max_num_iter, real_t RTOLERANCE, real_t ATOLERANCE)
Preconditioned conjugate gradient method. (tolerances are squared)
std::function< real_t(const Vector &)> f(real_t mass_coeff)