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;
58 args.
AddOption(&mesh_file,
"-m",
"--mesh",
61 "Finite element order (polynomial degree).");
62 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
64 "Enable or disable GLVis visualization.");
65 args.
AddOption(&max_dofs,
"-md",
"--max_dofs",
66 "Maximum number of dofs.");
67 args.
AddOption(&use_petsc,
"-usepetsc",
"--usepetsc",
"-no-petsc",
69 "Use or not PETSc to solve the linear system.");
70 args.
AddOption(&petscrc_file,
"-petscopts",
"--petscopts",
71 "PetscOptions file to use.");
72 args.
AddOption(&use_nonoverlapping,
"-nonoverlapping",
"--nonoverlapping",
73 "-no-nonoverlapping",
"--no-nonoverlapping",
74 "Use or not the block diagonal PETSc's matrix format "
75 "for non-overlapping domain decomposition.");
95 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
111 ParMesh pmesh(MPI_COMM_WORLD, *mesh);
115 "Boundary attributes required in the mesh.");
133 a.AddDomainIntegrator(integ);
153 cout <<
"Unable to connect to GLVis server at "
155 cout <<
"GLVis visualization disabled.\n";
157 visualization =
false;
186 for (
int it = 0; ; it++)
191 cout <<
"\nAMR iteration " << it << endl;
192 cout <<
"Number of unknowns: " << global_dofs << endl;
208 const int copy_interior = 1;
212 a.SetOperatorType(use_nonoverlapping ?
216 MPI_Barrier(MPI_COMM_WORLD);
218 a.FormLinearSystem(ess_tdof_list, x,
b, pA, pX, pB, copy_interior);
219 MPI_Barrier(MPI_COMM_WORLD);
221 if (myid == 0) { cout <<
"PETSc assembly timing : " << time << endl; }
229 MPI_Barrier(MPI_COMM_WORLD);
231 a.FormLinearSystem(ess_tdof_list, x,
b, A, X, B, copy_interior);
232 MPI_Barrier(MPI_COMM_WORLD);
234 if (myid == 0) { cout <<
"HYPRE assembly timing : " << time << endl; }
250 a.RecoverFEMSolution(X,
b, x);
255 sout <<
"parallel " << num_procs <<
" " << myid <<
"\n";
256 sout <<
"solution\n" << pmesh << x << flush;
259 if (global_dofs > max_dofs)
263 cout <<
"Reached the maximum number of dofs. Stop." << endl;
278 refiner.
Apply(pmesh);
283 cout <<
"Stopping criterion satisfied. Stop." << endl;
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.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
virtual void Mult(const Vector &b, Vector &x) const
Iterative solution of the linear system using the Conjugate Gradient method.
A coefficient that is constant across space and time.
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
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.