49int main(
int argc,
char *argv[])
58 const char *mesh_file =
"../data/beam-tri.mesh";
60 bool static_cond =
false;
61 bool visualization = 1;
63 bool reorder_space =
false;
64 const char *device_config =
"cpu";
67 args.
AddOption(&mesh_file,
"-m",
"--mesh",
70 "Finite element order (polynomial degree).");
71 args.
AddOption(&amg_elast,
"-elast",
"--amg-for-elasticity",
"-sys",
73 "Use the special AMG elasticity solver (GM/LN approaches), "
74 "or standard AMG for systems (unknown approach).");
75 args.
AddOption(&static_cond,
"-sc",
"--static-condensation",
"-no-sc",
76 "--no-static-condensation",
"Enable static condensation.");
77 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
79 "Enable or disable GLVis visualization.");
80 args.
AddOption(&reorder_space,
"-nodes",
"--by-nodes",
"-vdim",
"--by-vdim",
81 "Use byNODES ordering of vector space instead of byVDIM");
82 args.
AddOption(&device_config,
"-d",
"--device",
83 "Device configuration string, see Device::Configure().");
100 Device device(device_config);
101 if (myid == 0) { device.
Print(); }
106 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
112 cerr <<
"\nInput mesh should have at least two materials and "
113 <<
"two boundary attributes! (See schematic in ex2.cpp)\n"
131 (int)floor(log(1000./mesh->
GetNE())/log(2.)/
dim);
132 for (
int l = 0; l < ref_levels; l++)
144 int par_ref_levels = 1;
145 for (
int l = 0; l < par_ref_levels; l++)
159 const bool use_nodal_fespace = pmesh->
NURBSext && !amg_elast;
160 if (use_nodal_fespace)
180 cout <<
"Number of finite element unknowns: " << size << endl
181 <<
"Assembling: " << flush;
202 for (
int i = 0; i <
dim-1; i++)
209 pull_force(1) = -1.0e-2;
217 cout <<
"r.h.s. ... " << flush;
232 lambda(0) = lambda(1)*50;
246 if (myid == 0) { cout <<
"matrix ... " << flush; }
247 if (static_cond) {
a->EnableStaticCondensation(); }
252 a->FormLinearSystem(ess_tdof_list, x, *
b, A, X, B);
255 cout <<
"done." << endl;
262 if (amg_elast && !
a->StaticCondensationIsEnabled())
279 a->RecoverFEMSolution(X, *
b, x);
288 if (!use_nodal_fespace)
301 ostringstream mesh_name, sol_name;
302 mesh_name <<
"mesh." << setfill(
'0') << setw(6) << myid;
303 sol_name <<
"sol." << setfill(
'0') << setw(6) << myid;
305 ofstream mesh_ofs(mesh_name.str().c_str());
306 mesh_ofs.precision(8);
307 pmesh->
Print(mesh_ofs);
309 ofstream sol_ofs(sol_name.str().c_str());
310 sol_ofs.precision(8);
321 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
322 sol_sock.precision(8);
323 sol_sock <<
"solution\n" << *pmesh << x << flush;
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.
The MFEM Device class abstracts hardware devices such as GPUs, as well as programming models such as ...
void Print(std::ostream &out=mfem::out)
Print the configuration of the MFEM virtual device object.
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
Class for grid function - Vector with associated FE space.
Arbitrary order H1-conforming (continuous) finite elements.
The BoomerAMG solver in hypre.
void SetSystemsOptions(int dim, bool order_bynodes=false)
void SetElasticityOptions(ParFiniteElementSpace *fespace, bool interp_refine=true)
void SetPrintLevel(int print_lvl)
void SetPreconditioner(HypreSolver &precond)
Set the hypre solver to be used as a preconditioner.
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Solve Ax=b with hypre's PCG.
void SetMaxIter(int max_iter)
Wrapper for hypre's ParCSR matrix class.
HYPRE_BigInt GetGlobalNumRows() const
Return the global number of rows.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
NURBSExtension * NURBSext
Optional NURBS mesh extension.
int GetNE() const
Returns number of elements.
int Dimension() const
Dimension of the reference space used within the elements.
void GetNodes(Vector &node_coord) const
void DegreeElevate(int rel_degree, int degree=16)
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
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
Class for parallel grid function.
void Save(std::ostream &out) const override
Class for parallel meshes.
void SetNodalFESpace(FiniteElementSpace *nfes) override
void Print(std::ostream &out=mfem::out, const std::string &comments="") const override
Vector coefficient defined by an array of scalar coefficients. Coefficients that are not set will eva...
Vector & Set(const real_t a, const Vector &x)
(*this) = a * x
std::function< real_t(const Vector &)> f(real_t mass_coeff)