46int main(
int argc,
char *argv[])
49 const char *mesh_file =
"../data/star.mesh";
56 bool visualization = 1;
57 const char *device_config =
"cpu";
60 args.
AddOption(&mesh_file,
"-m",
"--mesh",
62 args.
AddOption(&ref_levels,
"-r",
"--refine",
63 "Number of times to refine the mesh uniformly, -1 for auto.");
65 "Finite element order (polynomial degree) >= 0.");
67 "One of the three DG penalty parameters, typically +1/-1."
68 " See the documentation of class DGDiffusionIntegrator.");
70 "One of the three DG penalty parameters, should be positive."
71 " Negative values are replaced with (order+1)^2.");
72 args.
AddOption(&eta,
"-e",
"--eta",
"BR2 penalty parameter.");
73 args.
AddOption(&pa,
"-pa",
"--partial-assembly",
"-no-pa",
74 "--no-partial-assembly",
"Enable Partial Assembly.");
75 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
77 "Enable or disable GLVis visualization.");
78 args.
AddOption(&device_config,
"-d",
"--device",
79 "Device configuration string, see Device::Configure().");
88 kappa = (order+1)*(order+1);
94 Device device(device_config);
100 Mesh mesh(mesh_file);
110 ref_levels = (int)floor(log(50000./mesh.
GetNE())/log(2.)/
dim);
112 for (
int l = 0; l < ref_levels; l++)
127 cout <<
"Number of unknowns: " << fespace.
GetVSize() << endl;
135 b.AddBdrFaceIntegrator(
156 MFEM_VERIFY(!pa,
"BR2 not yet compatible with partial assembly.");
160 if (pa) {
a.SetAssemblyLevel(AssemblyLevel::PARTIAL); }
172 MFEM_VERIFY(
sigma == -1.0,
173 "The case of PA with sigma != -1 is not yet supported.");
174 CG(
a,
b, x, 1, 500, 1e-12, 0.0);
179#ifndef MFEM_USE_SUITESPARSE
183 PCG(A, M,
b, x, 1, 500, 1e-12, 0.0);
187 GMRES(A, M,
b, x, 1, 500, 10, 1e-12, 0.0);
191 umf_solver.
Control[UMFPACK_ORDERING] = UMFPACK_ORDERING_METIS;
193 umf_solver.
Mult(
b, x);
199 ofstream mesh_ofs(
"refined.mesh");
200 mesh_ofs.precision(8);
201 mesh.
Print(mesh_ofs);
202 ofstream sol_ofs(
"sol.gf");
203 sol_ofs.precision(8);
212 sol_sock.precision(8);
213 sol_sock <<
"solution\n" << mesh << x << flush;
@ GaussLobatto
Closed type.
@ GaussLegendre
Open type.
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 &os=mfem::out)
Print the configuration of the MFEM virtual device object.
Class for domain integration .
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
Data type for Gauss-Seidel smoother of sparse matrix.
Class for grid function - Vector with associated FE space.
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
Arbitrary order "L2-conforming" discontinuous finite elements.
NURBSExtension * NURBSext
Optional NURBS mesh extension.
virtual void Print(std::ostream &os=mfem::out, const std::string &comments="") const
Print the mesh to the given stream using the default MFEM mesh format.
int GetNE() const
Returns number of elements.
int Dimension() const
Dimension of the reference space used within the elements.
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 *)
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.
Direct sparse solver using UMFPACK.
real_t Control[UMFPACK_CONTROL]
void SetOperator(const Operator &op) override
Factorize the given Operator op which must be a SparseMatrix.
void Mult(const Vector &b, Vector &x) const override
Direct solution of the linear system using UMFPACK.
real_t sigma(const Vector &x)
int GMRES(const Operator &A, Vector &x, const Vector &b, Solver &M, int &max_iter, int m, real_t &tol, real_t atol, int printit)
GMRES method. (tolerances are squared)
void PCG(const Operator &A, Solver &B, const Vector &b, Vector &x, int print_iter, int max_num_iter, real_t RTOLERANCE, real_t ATOLERANCE)
Preconditioned conjugate gradient method. (tolerances are squared)
void CG(const Operator &A, const Vector &b, Vector &x, int print_iter, int max_num_iter, real_t RTOLERANCE, real_t ATOLERANCE)
Conjugate gradient method. (tolerances are squared)