39 int 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;
165 sol_sock.
open(vishost, visport);
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;
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);
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");
virtual void Print(std::ostream &out=mfem::out) const
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.
virtual void Update(bool want_transform=true)
Reflect changes in the mesh: update number of DOFs, etc. Also, calculate GridFunction transformation ...
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 GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1)
Get a list of essential true dofs, ess_tdof_list, corresponding to the boundary attributes marked in ...
bool Stop() const
Check if STOP action is requested, e.g. stopping criterion is satisfied.
Data type for Gauss-Seidel smoother of sparse matrix.
Direct sparse solver using UMFPACK.
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
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 UniformRefinement(int i, const DSTable &, int *, int *, int *)
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.
void SetFluxAveraging(int fa)
Set the way the flux is averaged (smoothed) across elements.
void Set(int i, Coefficient *c, bool own=true)
Sets coefficient in the vector.
void PCG(const Operator &A, Solver &B, const Vector &b, Vector &x, int print_iter, int max_num_iter, double RTOLERANCE, double ATOLERANCE)
Preconditioned conjugate gradient method. (tolerances are squared)
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
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.
double Control[UMFPACK_CONTROL]
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
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...
virtual void Update()
Transform by the Space UpdateMatrix (e.g., on Mesh change).
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'.
The ZienkiewiczZhuEstimator class implements the Zienkiewicz-Zhu error estimation procedure...
void GetNodes(Vector &node_coord) const
Arbitrary order H1-conforming (continuous) finite elements.
void SetTotalErrorFraction(double fraction)
Set the total fraction used in the computation of the threshold. The default value is 1/2...
Array< int > attributes
A list of all unique element attributes used by the Mesh.
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
void ProjectBdrCoefficient(Coefficient &coeff, Array< int > &attr)
Project a Coefficient on the GridFunction, modifying only DOFs on the boundary associated with the bo...
double f(const Vector &p)
void Neg()
(*this) = -(*this)
virtual void SetOperator(const Operator &op)
Factorize the given Operator op which must be a SparseMatrix.
bool Good() const
Return true if the command line options were parsed successfully.