43int main(
int argc,
char *argv[])
50 string mesh_file =
"../../data/ref-cube.mesh";
56 int assembly_type_int = 3;
59 int refine_serial = 4;
60 int refine_parallel = 0;
71 string device_config =
"cpu";
72 bool use_monitor =
false;
73 bool visualization =
true;
77 args.
AddOption(&mesh_file,
"-m",
"--mesh",
80 "Finite element order (polynomial degree)");
81 args.
AddOption((
int*)&solver_type,
"-s",
"--solver",
82 "Solvers to be considered:"
83 "\n\t0: Stationary Linear Iteration"
84 "\n\t1: Preconditioned Conjugate Gradient");
85 args.
AddOption((
int*)&integrator_type,
"-i",
"--integrator",
86 "Integrators to be considered:"
87 "\n\t0: MassIntegrator"
88 "\n\t1: DiffusionIntegrator"
89 "\n\t2: CurlCurlIntegrator + VectorFEMassIntegrator");
90 args.
AddOption(&assembly_type_int,
"-a",
"--assembly",
91 "Assembly level to be considered:"
97 args.
AddOption((
int*)&pc_type,
"-pc",
"--preconditioner",
98 "Preconditioners to be considered:"
99 "\n\t0: No preconditioner"
100 "\n\t1: Absolute L(1)-Jacobi preconditioner"
101 "\n\t2: Element L(p,q)-Jacobi preconditioner");
102 args.
AddOption(&refine_serial,
"-rs",
"--refine-serial",
103 "Number of serial refinements");
104 args.
AddOption(&refine_parallel,
"-rp",
"--refine-parallel",
105 "Number of parallel refinements");
106 args.
AddOption(&p_order,
"-p",
"--p-order",
107 "P-order for L(p,q)-Jacobi preconditioner");
108 args.
AddOption(&q_order,
"-q",
"--q-order",
109 "Q-order for L(p,q)-Jacobi preconditioner");
110 args.
AddOption(&rel_tol,
"-t",
"--tolerance",
111 "Relative tolerance for the iterative solver");
112 args.
AddOption(&max_iter,
"-ni",
"--iterations",
113 "Maximum number of iterations");
114 args.
AddOption(&eps_y,
"-Ky",
"--Kershaw-y",
115 "Kershaw transform factor, eps_y in (0,1]");
116 args.
AddOption(&eps_z,
"-Kz",
"--Kershaw-z",
117 "Kershaw transform factor, eps_z in (0,1]");
118 args.
AddOption(&
freq,
"-f",
"--frequency",
"Set the frequency for the exact"
120 args.
AddOption(&device_config,
"-d",
"--device",
121 "Device configuration string, see Device::Configure().");
122 args.
AddOption(&use_monitor,
"-mon",
"--monitor",
"-no-mon",
124 "Enable or disable Data Monitor.");
125 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
126 "--no-visualization",
127 "Enable or disable GLVis visualization.");
130 MFEM_VERIFY(p_order > 0.0,
"p needs to be positive");
131 MFEM_VERIFY((0 <= solver_type) && (solver_type <
num_solvers),
132 "invalid solver type: " << solver_type);
133 MFEM_VERIFY((0 <= integrator_type) && (integrator_type <
num_integrators),
134 "invalid integrator type: " << integrator_type);
135 MFEM_VERIFY((0 <= assembly_type_int) && (assembly_type_int < 5),
136 "invalid assembly type: " << assembly_type_int);
137 MFEM_VERIFY((0 <= pc_type) && (pc_type <
num_pc),
138 "invalid preconditioner type: " << pc_type);
139 MFEM_VERIFY((0.0 <= eps_y) && (eps_y <= 1.0),
"eps_y must be in [0,1]");
140 MFEM_VERIFY((0.0 <= eps_z) && (eps_z <= 1.0),
"eps_z must be in [0,1]");
144 ostringstream file_name;
149 <<
"I" << (int) integrator_type
150 <<
"S" << (
int) solver_type
151 <<
"A" << assembly_type_int
155 switch (assembly_type_int)
158 assembly_type = AssemblyLevel::LEGACY;
161 assembly_type = AssemblyLevel::FULL;
164 assembly_type = AssemblyLevel::ELEMENT;
167 assembly_type = AssemblyLevel::PARTIAL;
170 assembly_type = AssemblyLevel::NONE;
173 MFEM_ABORT(
"Unsupported option!");
176 Device device(device_config);
181 Mesh *serial_mesh =
new Mesh(mesh_file);
182 for (
int ls = 0; ls < refine_serial; ls++)
192 for (
int lp = 0; lp < refine_parallel; lp++)
200 bool cond_z = (
dim < 3) ?
true : (eps_z != 0);
201 if (eps_y != 0.0 && cond_z)
203 if (
dim < 3) { eps_z = 0.0; }
216 switch (integrator_type)
228 mfem_error(
"Invalid integrator type! Check FiniteElementCollection");
234 mfem::out <<
"Number of unknowns: " << sys_size << endl;
279 switch (integrator_type)
285 x.ProjectBdrCoefficient(*scalar_u, ess_bdr);
292 x.ProjectBdrCoefficient(*scalar_u, ess_bdr);
302 x.ProjectBdrCoefficientTangent(*vector_u, ess_bdr);
305 mfem_error(
"Invalid integrator type! Check ParLinearForm");
308 a->SetAssemblyLevel(assembly_type);
309 a->AddDomainIntegrator(bfi);
312 b->AddDomainIntegrator(lfi);
354 solver =
new CGSolver(MPI_COMM_WORLD);
382 a->RecoverFEMSolution(X, *
b, x);
392 sol_sock.precision(8);
393 sol_sock <<
"solution\n" << *mesh << x << flush;
399 switch (integrator_type)
403 error = x.ComputeL2Error(*scalar_u);
406 error = x.ComputeL2Error(*vector_u);
409 mfem_error(
"Invalid integrator type! Check ComputeL2Error");
413 mfem::out <<
"\n|| u_h - u ||_{L^2} = " << error <<
"\n" << endl;
419 if (jacobi) {
delete jacobi; }
425 if (monitor) {
delete monitor; }
426 if (scalar_u) {
delete scalar_u; }
427 if (scalar_f) {
delete scalar_f; }
428 if (vector_u) {
delete vector_u; }
429 if (vector_f) {
delete vector_f; }
Custom monitor that prints a csv-formatted file.
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.
A coefficient that is constant across space and time.
Integrator for for Nedelec elements.
The MFEM Device class abstracts hardware devices such as GPUs, as well as programming models such as ...
void Print(std::ostream &os=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...
A general function coefficient.
Arbitrary order H1-conforming (continuous) finite elements.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
Abstract base class for iterative solver.
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)
void SetMonitor(IterativeSolverMonitor &m)
An alias of SetController() for backward compatibility.
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
int Dimension() const
Dimension of the reference space used within the elements.
void Transform(std::function< void(const Vector &, Vector &)> f)
int SpaceDimension() const
Dimension of the physical space containing the mesh.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
static bool Root()
Return true if the rank in MPI_COMM_WORLD is zero.
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).
Arbitrary order H(curl)-conforming Nedelec finite elements.
Pointer to an Operator of a specified type.
Jacobi smoothing for a given bilinear form (no matrix necessary).
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
virtual void AbsMult(const Vector &x, Vector &y) const
Action of the absolute-value operator: y=|A|(x). The default behavior in class Operator is to generat...
void ParseCheck(std::ostream &out=mfem::out)
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...
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
int GetTrueVSize() const override
Return the number of local vector true dofs.
Class for parallel grid function.
Class for parallel meshes.
Stationary linear iteration: x <- x + B (b - A x)
virtual void SetOperator(const Operator &op)=0
Set/update the solver for the given operator.
Integrator defining a sum of multiple Integrators.
void AddIntegrator(BilinearFormIntegrator *integ)
for VectorFiniteElements (Nedelec, Raviart-Thomas)
A general vector function coefficient.
const int * ess_tdof_list
real_t diffusion_source(const Vector &x)
void maxwell_source(const Vector &x, Vector &f)
void maxwell_solution(const Vector &x, Vector &u)
void AssembleElementLpqJacobiDiag(ParBilinearForm &form, real_t p, real_t q, Vector &diag)
real_t diffusion_solution(const Vector &x)
void mfem_error(const char *msg)
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
AssemblyLevel
Enumeration defining the assembly level for bilinear and nonlinear form classes derived from Operator...