51 CustomSolverMonitor(
const ParMesh &pmesh_,
56 void MonitorSolution(
int i,
real_t norm,
const Vector &x,
bool final)
62 MPI_Comm_size(pmesh.
GetComm(), &num_procs);
63 MPI_Comm_rank(pmesh.
GetComm(), &myid);
68 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
69 sol_sock.precision(8);
70 sol_sock <<
"solution\n" << pmesh << pgf
71 <<
"window_title 'Iteration no " << i <<
"'"
72 <<
"keys rRjlc\n" << flush;
76int main(
int argc,
char *argv[])
83 const char *mesh_file =
"../data/star.mesh";
84 int ser_ref_levels = -1;
85 int par_ref_levels = 2;
91 bool visualization = 1;
92 const char *device_config =
"cpu";
95 args.
AddOption(&mesh_file,
"-m",
"--mesh",
97 args.
AddOption(&ser_ref_levels,
"-rs",
"--refine-serial",
98 "Number of times to refine the mesh uniformly in serial,"
100 args.
AddOption(&par_ref_levels,
"-rp",
"--refine-parallel",
101 "Number of times to refine the mesh uniformly in parallel.");
103 "Finite element order (polynomial degree) >= 0.");
105 "One of the three DG penalty parameters, typically +1/-1."
106 " See the documentation of class DGDiffusionIntegrator.");
108 "One of the three DG penalty parameters, should be positive."
109 " Negative values are replaced with (order+1)^2.");
110 args.
AddOption(&eta,
"-e",
"--eta",
"BR2 penalty parameter.");
111 args.
AddOption(&pa,
"-pa",
"--partial-assembly",
"-no-pa",
112 "--no-partial-assembly",
"Enable Partial Assembly.");
113 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
114 "--no-visualization",
115 "Enable or disable GLVis visualization.");
116 args.
AddOption(&device_config,
"-d",
"--device",
117 "Device configuration string, see Device::Configure().");
129 kappa = (order+1)*(order+1);
136 Device device(device_config);
142 Mesh mesh(mesh_file);
150 if (ser_ref_levels < 0)
152 ser_ref_levels = (int)floor(log(10000./mesh.
GetNE())/log(2.)/
dim);
154 for (
int l = 0; l < ser_ref_levels; l++)
167 ParMesh pmesh(MPI_COMM_WORLD, mesh);
170 for (
int l = 0; l < par_ref_levels; l++)
184 cout <<
"Number of unknowns: " << size << endl;
193 b.AddBdrFaceIntegrator(
214 MFEM_VERIFY(!pa,
"BR2 not yet compatible with partial assembly.");
218 if (pa) {
a.SetAssemblyLevel(AssemblyLevel::PARTIAL); }
226 std::unique_ptr<HypreBoomerAMG> amg;
234 a.ParallelAssemble(A);
252 CustomSolverMonitor monitor(pmesh, x);
268 ostringstream mesh_name, sol_name;
269 mesh_name <<
"mesh." << setfill(
'0') << setw(6) <<
Mpi::WorldRank();
270 sol_name <<
"sol." << setfill(
'0') << setw(6) <<
Mpi::WorldRank();
272 ofstream mesh_ofs(mesh_name.str().c_str());
273 mesh_ofs.precision(8);
274 pmesh.
Print(mesh_ofs);
276 ofstream sol_ofs(sol_name.str().c_str());
277 sol_ofs.precision(8);
288 sol_sock.precision(8);
289 sol_sock <<
"solution\n" << pmesh << x << flush;
@ GaussLobatto
Closed type.
@ GaussLegendre
Open type.
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.
The MFEM Device class abstracts hardware devices such as GPUs, as well as programming models such as ...
void Print(std::ostream &out=mfem::out)
Print the configuration of the MFEM virtual device object.
Class for domain integration .
void SetKDim(int dim)
Set the number of iteration to perform between restarts, default is 50.
virtual void Mult(const Vector &b, Vector &x) const
Iterative solution of the linear system using the GMRES method.
The BoomerAMG solver in hypre.
Wrapper for hypre's ParCSR matrix class.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
Abstract base class for an iterative solver monitor.
virtual void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
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)
Set the iterative solver monitor.
void SetAbsTol(real_t atol)
Arbitrary order "L2-conforming" discontinuous finite elements.
NURBSExtension * NURBSext
Optional NURBS mesh extension.
void Clear()
Clear the contents of the Mesh.
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 *)
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).
Pointer to an Operator of a specified type.
OpType * As() const
Return the Operator pointer statically cast to a specified OpType. Similar to the method Get().
void SetType(Operator::Type tid)
Invoke Clear() and set a new type id.
void Reset(OpType *A, bool own_A=true)
Reset the OperatorHandle to the given OpType pointer, A.
@ Hypre_ParCSR
ID for class HypreParMatrix.
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.
HYPRE_BigInt GlobalTrueVSize() const
Class for parallel grid function.
void Save(std::ostream &out) const override
void SetFromTrueDofs(const Vector &tv) override
Set the GridFunction from the given true-dof vector.
Class for parallel meshes.
void Print(std::ostream &out=mfem::out, const std::string &comments="") const override
real_t sigma(const Vector &x)