33 #ifndef MFEM_USE_PETSC 34 #error This example requires that MFEM is built with MFEM_USE_PETSC=YES 46 int main(
int argc,
char *argv[])
49 Mpi::Init(argc, argv);
50 int num_procs = Mpi::WorldSize();
51 int myid = Mpi::WorldRank();
55 const char *mesh_file =
"../../data/beam-tet.mesh";
57 bool static_cond =
false;
58 bool visualization = 1;
59 bool use_petsc =
true;
60 const char *petscrc_file =
"";
61 bool use_nonoverlapping =
false;
64 args.
AddOption(&mesh_file,
"-m",
"--mesh",
67 "Finite element order (polynomial degree).");
68 args.
AddOption(&
freq,
"-f",
"--frequency",
"Set the frequency for the exact" 70 args.
AddOption(&static_cond,
"-sc",
"--static-condensation",
"-no-sc",
71 "--no-static-condensation",
"Enable static condensation.");
72 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
74 "Enable or disable GLVis visualization.");
75 args.
AddOption(&use_petsc,
"-usepetsc",
"--usepetsc",
"-no-petsc",
77 "Use or not PETSc to solve the linear system.");
78 args.
AddOption(&petscrc_file,
"-petscopts",
"--petscopts",
79 "PetscOptions file to use.");
80 args.
AddOption(&use_nonoverlapping,
"-nonoverlapping",
"--nonoverlapping",
81 "-no-nonoverlapping",
"--no-nonoverlapping",
82 "Use or not the block diagonal PETSc's matrix format " 83 "for non-overlapping domain decomposition.");
104 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
114 (int)floor(log(1000./mesh->
GetNE())/log(2.)/
dim);
115 for (
int l = 0; l < ref_levels; l++)
127 int par_ref_levels = 2;
128 for (
int l = 0; l < par_ref_levels; l++)
141 cout <<
"Number of finite element unknowns: " << size << endl;
187 if (static_cond) {
a->EnableStaticCondensation(); }
194 a->FormLinearSystem(ess_tdof_list, x, *
b, A, X, B);
204 (
a->StaticCondensationIsEnabled() ?
a->SCParFESpace() : fespace);
218 a->SetOperatorType(use_nonoverlapping ?
219 Operator::PETSC_MATIS : Operator::PETSC_MATAIJ);
220 a->FormLinearSystem(ess_tdof_list, x, *
b, A, X, B);
224 cout <<
"Size of linear system: " << A.
M() << endl;
229 (
a->StaticCondensationIsEnabled() ?
a->SCParFESpace() : fespace);
235 if (use_nonoverlapping)
260 a->RecoverFEMSolution(X, *
b, x);
267 cout <<
"\n|| E_h - E ||_{L^2} = " <<
err <<
'\n' << endl;
274 ostringstream mesh_name, sol_name;
275 mesh_name <<
"mesh." << setfill(
'0') << setw(6) << myid;
276 sol_name <<
"sol." << setfill(
'0') << setw(6) << myid;
278 ofstream mesh_ofs(mesh_name.str().c_str());
279 mesh_ofs.precision(8);
280 pmesh->
Print(mesh_ofs);
282 ofstream sol_ofs(sol_name.str().c_str());
283 sol_ofs.precision(8);
293 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
294 sol_sock.precision(8);
295 sol_sock <<
"solution\n" << *pmesh << x << flush;
318 E(0) = sin(
kappa * x(1));
319 E(1) = sin(
kappa * x(2));
320 E(2) = sin(
kappa * x(0));
324 E(0) = sin(
kappa * x(1));
325 E(1) = sin(
kappa * x(0));
326 if (x.
Size() == 3) { E(2) = 0.0; }
342 if (x.
Size() == 3) {
f(2) = 0.0; }
void SetPreconditioner(Solver &precond)
void SetPrintLevel(int plev)
virtual void Mult(const Vector &b, Vector &x) const
Application of the solver.
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1)
The Auxiliary-space Maxwell Solver in hypre.
Abstract class for PETSc's preconditioners.
OutStream err(std::cerr)
Global stream used by the library for standard error output. Initially it uses the same std::streambu...
A coefficient that is constant across space and time.
void PrintOptions(std::ostream &out) const
Print the options.
Wrapper for PETSc's matrix class.
void PrintUsage(std::ostream &out) const
Print the usage message.
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Solve Ax=b with hypre's PCG.
Integrator for (curl u, curl v) for Nedelec elements.
int Size() const
Returns the size of the vector.
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
void E_exact(const Vector &, Vector &)
bool Good() const
Return true if the command line options were parsed successfully.
Abstract parallel finite element space.
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
PetscInt M() const
Returns the global number of rows.
void SetMaxIter(int max_iter)
void SetPrintLevel(int print_lvl)
int main(int argc, char *argv[])
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 *)
Auxiliary class for BDDC customization.
virtual double ComputeL2Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL, const Array< int > *elems=NULL) const
HYPRE_BigInt GlobalTrueVSize() const
void SetMaxIter(int max_iter)
A general vector function coefficient.
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
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...
int SpaceDimension() const
virtual void Save(std::ostream &out) const
int GetNE() const
Returns number of elements.
void MFEMInitializePetsc()
Convenience functions to initialize/finalize PETSc.
void SetSpace(ParFiniteElementSpace *fe)
void SetPreconditioner(HypreSolver &precond)
Set the hypre solver to be used as a preconditioner.
Abstract class for hypre's solvers and preconditioners.
int Size() const
Return the logical size of the array.
for VectorFiniteElements (Nedelec, Raviart-Thomas)
Arbitrary order H(curl)-conforming Nedelec finite elements.
void Print(std::ostream &out=mfem::out) const override
Class for parallel grid function.
Wrapper for hypre's ParCSR matrix class.
Class for parallel meshes.
void SetEssBdrDofs(const Array< int > *essdofs, bool loc=false)
Specify dofs on the essential boundary.
HYPRE_BigInt GetGlobalNumRows() const
Return the global number of rows.
void f_exact(const Vector &, Vector &)
double f(const Vector &p)
double sigma(const Vector &x)