34#error This example requires that MFEM is built with MFEM_USE_PETSC=YES
40int main(
int argc,
char *argv[])
49 const char *mesh_file =
"../../data/star.mesh";
51 bool visualization =
true;
52 int max_dofs = 100000;
53 bool use_petsc =
true;
54 const char *petscrc_file =
"";
55 bool use_nonoverlapping =
false;
56 const char *device_config =
"cpu";
59 args.
AddOption(&mesh_file,
"-m",
"--mesh",
62 "Finite element order (polynomial degree).");
63 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
65 "Enable or disable GLVis visualization.");
66 args.
AddOption(&max_dofs,
"-md",
"--max_dofs",
67 "Maximum number of dofs.");
68 args.
AddOption(&use_petsc,
"-usepetsc",
"--usepetsc",
"-no-petsc",
70 "Use or not PETSc to solve the linear system.");
71 args.
AddOption(&petscrc_file,
"-petscopts",
"--petscopts",
72 "PetscOptions file to use.");
73 args.
AddOption(&use_nonoverlapping,
"-nonoverlapping",
"--nonoverlapping",
74 "-no-nonoverlapping",
"--no-nonoverlapping",
75 "Use or not the block diagonal PETSc's matrix format "
76 "for non-overlapping domain decomposition.");
77 args.
AddOption(&device_config,
"-d",
"--device",
78 "Device configuration string, see Device::Configure().");
95 Device device(device_config);
96 if (myid == 0) { device.
Print(); }
104 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
120 ParMesh pmesh(MPI_COMM_WORLD, *mesh);
124 "Boundary attributes required in the mesh.");
142 a.AddDomainIntegrator(integ);
162 cout <<
"Unable to connect to GLVis server at "
163 <<
vishost <<
':' << visport << endl;
164 cout <<
"GLVis visualization disabled.\n";
166 visualization =
false;
195 for (
int it = 0; ; it++)
200 cout <<
"\nAMR iteration " << it << endl;
201 cout <<
"Number of unknowns: " << global_dofs << endl;
217 const int copy_interior = 1;
221 a.SetOperatorType(use_nonoverlapping ?
225 MPI_Barrier(MPI_COMM_WORLD);
227 a.FormLinearSystem(ess_tdof_list, x,
b, pA, pX, pB, copy_interior);
228 MPI_Barrier(MPI_COMM_WORLD);
230 if (myid == 0) { cout <<
"PETSc assembly timing : " << time << endl; }
238 MPI_Barrier(MPI_COMM_WORLD);
240 a.FormLinearSystem(ess_tdof_list, x,
b, A, X, B, copy_interior);
241 MPI_Barrier(MPI_COMM_WORLD);
243 if (myid == 0) { cout <<
"HYPRE assembly timing : " << time << endl; }
259 a.RecoverFEMSolution(X,
b, x);
264 sout <<
"parallel " << num_procs <<
" " << myid <<
"\n";
265 sout <<
"solution\n" << pmesh << x << flush;
268 if (global_dofs > max_dofs)
272 cout <<
"Reached the maximum number of dofs. Stop." << endl;
287 refiner.
Apply(pmesh);
292 cout <<
"Stopping criterion satisfied. Stop." << endl;
40int main(
int argc,
char *argv[]) {
…}
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
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 .
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
Return a bool indicating whether this mesh is nonconforming.
int Dimension() const
Dimension of the reference space used within the elements.
int SpaceDimension() const
Dimension of the physical space containing the mesh.
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).
@ PETSC_MATIS
ID for class PetscParMatrix, MATIS format.
@ Hypre_ParCSR
ID for class HypreParMatrix.
@ PETSC_MATAIJ
ID for class PetscParMatrix, MATAIJ format.
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 Update(bool want_transform=true) override
Class for parallel grid function.
void Update() override
Transform by the Space UpdateMatrix (e.g., on Mesh change).
Class for parallel meshes.
Wrapper for PETSc's matrix class.
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 open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
void MFEMInitializePetsc()
Convenience functions to initialize/finalize PETSc.