29 #ifndef MFEM_USE_PETSC
30 #error This example requires that MFEM is built with MFEM_USE_PETSC=YES
41 int main(
int argc,
char *argv[])
45 MPI_Init(&argc, &argv);
46 MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
47 MPI_Comm_rank(MPI_COMM_WORLD, &myid);
50 const char *mesh_file =
"../../data/star.mesh";
53 bool static_cond =
false;
54 bool hybridization =
false;
55 bool visualization = 1;
56 bool use_petsc =
true;
57 const char *petscrc_file =
"";
58 bool use_nonoverlapping =
false;
61 args.
AddOption(&mesh_file,
"-m",
"--mesh",
64 "Finite element order (polynomial degree).");
65 args.
AddOption(&set_bc,
"-bc",
"--impose-bc",
"-no-bc",
"--dont-impose-bc",
66 "Impose or not essential boundary conditions.");
67 args.
AddOption(&
freq,
"-f",
"--frequency",
"Set the frequency for the exact"
69 args.
AddOption(&static_cond,
"-sc",
"--static-condensation",
"-no-sc",
70 "--no-static-condensation",
"Enable static condensation.");
71 args.
AddOption(&hybridization,
"-hb",
"--hybridization",
"-no-hb",
72 "--no-hybridization",
"Enable hybridization.");
73 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
75 "Enable or disable GLVis visualization.");
76 args.
AddOption(&use_petsc,
"-usepetsc",
"--usepetsc",
"-no-petsc",
78 "Use or not PETSc to solve the linear system.");
79 args.
AddOption(&petscrc_file,
"-petscopts",
"--petscopts",
80 "PetscOptions file to use.");
81 args.
AddOption(&use_nonoverlapping,
"-nonoverlapping",
"--nonoverlapping",
82 "-no-nonoverlapping",
"--no-nonoverlapping",
83 "Use or not the block diagonal PETSc's matrix format "
84 "for non-overlapping domain decomposition.");
100 if (use_petsc) { PetscInitialize(NULL,NULL,petscrc_file,NULL); }
106 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
116 (int)floor(log(1000./mesh->
GetNE())/log(2.)/
dim);
117 for (
int l = 0; l < ref_levels; l++)
131 int par_ref_levels = 2;
132 for (
int l = 0; l < par_ref_levels; l++)
146 cout <<
"Number of finite element unknowns: " << size << endl;
157 ess_bdr = set_bc ? 1 : 0;
199 else if (hybridization)
222 cout <<
"Size of linear system: " << glob_size << endl;
235 if (dim == 2) { prec =
new HypreAMS(A, prec_fespace); }
236 else { prec =
new HypreADS(A, prec_fespace); }
247 Operator::PETSC_MATIS : Operator::PETSC_MATAIJ);
252 cout <<
"Size of linear system: " << A.
M() << endl;
256 if (use_nonoverlapping)
290 cout <<
"\n|| F_h - F ||_{L^2} = " << err <<
'\n' << endl;
297 ostringstream mesh_name, sol_name;
298 mesh_name <<
"mesh." << setfill(
'0') << setw(6) << myid;
299 sol_name <<
"sol." << setfill(
'0') << setw(6) << myid;
301 ofstream mesh_ofs(mesh_name.str().c_str());
302 mesh_ofs.precision(8);
303 pmesh->
Print(mesh_ofs);
305 ofstream sol_ofs(sol_name.str().c_str());
306 sol_ofs.precision(8);
313 char vishost[] =
"localhost";
316 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
317 sol_sock.precision(8);
318 sol_sock <<
"solution\n" << *pmesh << x << flush;
333 if (use_petsc) { PetscFinalize(); }
369 f(0) = temp*cos(kappa*x)*sin(kappa*y);
370 f(1) = temp*cos(kappa*y)*sin(kappa*x);
int Size() const
Logical size of the array.
Conjugate gradient method.
The Auxiliary-space Maxwell Solver in hypre.
Abstract class for PETSc's preconditioners.
double ComputeL2Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL) const
The Auxiliary-space Divergence Solver in hypre.
Subclass constant coefficient.
Wrapper for PETSc's matrix class.
virtual void ReorientTetMesh()
See the remarks for the serial version in mesh.hpp.
HYPRE_Int GlobalTrueVSize()
int Size() const
Returns the size of the vector.
int GetNE() const
Returns number of elements.
virtual void Save(std::ostream &out) const
Abstract parallel finite element space.
void ProjectCoefficient(Coefficient &coeff)
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
int main(int argc, char *argv[])
(Q div u, div v) for RT elements
PetscInt M() const
Returns the global number of rows.
The BoomerAMG solver in hypre.
HYPRE_Int GetGlobalNumRows() const
void SetPrintLevel(int print_lvl)
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Auxiliary class for BDDC customization.
void SetMaxIter(int max_it)
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
void F_exact(const Vector &, Vector &)
void PrintUsage(std::ostream &out) const
Arbitrary order H(div)-conforming Raviart-Thomas finite elements.
int SpaceDimension() const
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
void SetRelTol(double rtol)
Base class Coefficient that may optionally depend on time.
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list)
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)
void f_exact(const Vector &, Vector &)
void SetSpace(ParFiniteElementSpace *fe)
void PrintOptions(std::ostream &out) const
Abstract class for hypre's solvers and preconditioners.
for VectorFiniteElements (Nedelec, Raviart-Thomas)
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
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.
Integrator for (Q u, v) for VectorFiniteElements.
virtual void Print(std::ostream &out=std::cout) const