60int main(
int argc,
char *argv[])
69 const char *mesh_file =
"../data/star.mesh";
72 const char *device_config =
"cpu";
73 bool nc_simplices =
true;
75 int max_dofs = 100000;
76 bool smooth_rt =
true;
78 bool visualization =
true;
79 bool rebalance =
true;
80 bool usePRefinement =
false;
83 args.
AddOption(&mesh_file,
"-m",
"--mesh",
86 "Finite element order (polynomial degree).");
87 args.
AddOption(&pa,
"-pa",
"--partial-assembly",
"-no-pa",
88 "--no-partial-assembly",
"Enable Partial Assembly.");
89 args.
AddOption(&device_config,
"-d",
"--device",
90 "Device configuration string, see Device::Configure().");
91 args.
AddOption(&reorder_mesh,
"-rm",
"--reorder-mesh",
92 "Reorder elements of the coarse mesh to improve "
93 "dynamic partitioning: 0=none, 1=hilbert, 2=gecko.");
94 args.
AddOption(&nc_simplices,
"-ns",
"--nonconforming-simplices",
95 "-cs",
"--conforming-simplices",
96 "For simplicial meshes, enable/disable nonconforming"
98 args.
AddOption(&max_dofs,
"-md",
"--max-dofs",
99 "Stop after reaching this many degrees of freedom.");
100 args.
AddOption(&smooth_rt,
"-rt",
"--smooth-rt",
"-h1",
"--smooth-h1",
101 "Represent the smooth flux in RT or vector H1 space.");
102 args.
AddOption(&usePRefinement,
"-pref",
"--p-refine",
"-no-pref",
103 "--no-p-refine",
"Alternate between h- and p-refinement.");
104 args.
AddOption(&rebalance,
"-reb",
"--rebalance",
"-no-reb",
105 "--no-rebalance",
"Load balance the nonconforming mesh.");
106 args.
AddOption(&restart,
"-res",
"--restart",
"-no-res",
"--no-restart",
107 "Restart computation from the last checkpoint.");
108 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
109 "--no-visualization",
110 "Enable or disable GLVis visualization.");
125 if (usePRefinement && rebalance)
130 cout <<
"Load balancing is not performed with p-refinements.\n";
136 Device device(device_config);
137 if (myid == 0) { device.
Print(); }
145 Mesh mesh(mesh_file, 1, 1);
167 switch (reorder_mesh)
171 default: MFEM_ABORT(
"Unknown mesh reodering type " << reorder_mesh);
185 pmesh =
new ParMesh(MPI_COMM_WORLD, mesh);
193 MFEM_VERIFY(ifs.good(),
"Checkpoint file " << fname <<
" not found.");
194 pmesh =
new ParMesh(MPI_COMM_WORLD, ifs);
201 "Boundary attributes required in the mesh.");
216 a.SetAssemblyLevel(AssemblyLevel::PARTIAL);
224 a.AddDomainIntegrator(integ);
244 cout <<
"Unable to connect to GLVis server at "
245 <<
vishost <<
':' << visport << endl;
246 cout <<
"GLVis visualization disabled.\n";
248 visualization =
false;
262 if (smooth_rt &&
dim > 1)
285 for (
int it = 0; ; it++)
290 cout <<
"\nAMR iteration " << it << endl;
291 cout <<
"Number of unknowns: " << global_dofs << endl;
311 const int copy_interior = 1;
312 a.FormLinearSystem(ess_tdof_list, x,
b, A, X, B, copy_interior);
345 sout <<
"parallel " << num_procs <<
" " << myid <<
"\n";
349 sout <<
"solution\n" << *pmesh << *vis_x << flush;
353 sout <<
"solution\n" << *pmesh << x << flush;
357 if (global_dofs >= max_dofs)
361 cout <<
"Reached the maximum number of dofs. Stop." << endl;
372 const bool pRefine = usePRefinement && ((it % 2) == 1);
382 for (
int i=0; i<refinements.
Size(); ++i)
384 prefinements[i].index = refinements[i].index;
385 prefinements[i].delta = 1;
390 refiner.
Apply(*pmesh);
391 stop = refiner.
Stop();
398 cout <<
"Stopping criterion satisfied. Stop." << endl;
440 if ((it + 1) % 5 == 0)
448 cout <<
"\nCheckpoint saved." << endl;
461 for (
int e=0; e<pmesh->
GetNE(); ++e)
466 xo[dofs[0]] = p_elem;
469 ostringstream mesh_name, sol_name, order_name;
470 mesh_name <<
"mesh." << setfill(
'0') << setw(6) << myid;
471 sol_name <<
"sol." << setfill(
'0') << setw(6) << myid;
472 order_name <<
"order." << setfill(
'0') << setw(6) << myid;
474 ofstream mesh_ofs(mesh_name.str().c_str());
475 mesh_ofs.precision(8);
478 ofstream sol_ofs(sol_name.str().c_str());
479 sol_ofs.precision(8);
482 vis_x->Save(sol_ofs);
484 ofstream order_ofs(order_name.str().c_str());
485 order_ofs.precision(8);
489 delete smooth_flux_fes;
490 delete smooth_flux_fec;
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
int Size() const
Return the logical size of the array.
Conjugate gradient method.
void Mult(const Vector &b, Vector &x) const override
Iterative solution of the linear system using the Conjugate Gradient method.
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
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.
Class for domain integration .
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
int GetElementOrder(int i) const
Returns the order of the i'th finite element.
Arbitrary order H1-conforming (continuous) finite elements.
The BoomerAMG solver in hypre.
void SetPrintLevel(int print_level)
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
Return a bool indicating whether this mesh is nonconforming.
real_t GetGeckoElementOrdering(Array< int > &ordering, int iterations=4, int window=4, int period=2, int seed=0, bool verbose=false, real_t time_limit=0)
int GetNE() const
Returns number of elements.
int Dimension() const
Dimension of the reference space used within the elements.
void ReorderElements(const Array< int > &ordering, bool reorder_vertices=true)
int SpaceDimension() const
Dimension of the physical space containing the mesh.
void GetHilbertElementOrdering(Array< int > &ordering)
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 *)
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).
Pointer to an Operator of a specified type.
Jacobi smoothing for a given bilinear form (no matrix necessary).
@ DIAG_ONE
Set the diagonal value to one.
virtual void RecoverFEMSolution(const Vector &X, const Vector &b, Vector &x)
Reconstruct a solution vector x (e.g. a GridFunction) from the solution X of a constrained linear sys...
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.
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 GetElementDofs(int i, Array< int > &dofs, DofTransformation &doftrans) const override
The same as GetElementDofs(), but with a user-allocated DofTransformation object. doftrans must be al...
void PRefineAndUpdate(const Array< pRefinement > &refs, bool want_transfer=true) override
void Update(bool want_transform=true) override
Class for parallel grid function.
void Save(std::ostream &out) const override
void Update() override
Transform by the Space UpdateMatrix (e.g., on Mesh change).
std::unique_ptr< ParGridFunction > ProlongateToMaxOrder() const
Return a GridFunction with the values of this, prolongated to the maximum order of all elements in th...
Class for parallel meshes.
void ParPrint(std::ostream &out, const std::string &comments="") const
long long ReduceInt(int value) const override
Utility function: sum integers from all processors (Allreduce).
Arbitrary order H(div)-conforming Raviart-Thomas finite elements.
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.
int MarkWithoutRefining(Mesh &mesh, Array< Refinement > &refinements)
Set the array refinements of elements to refine, without refining.
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
std::string MakeParFilename(const std::string &prefix, const int myid, const std::string suffix, const int width)
Construct a string of the form "<prefix><myid><suffix>" where the integer myid is padded with leading...