42 CustomSolverMonitor(
const ParMesh *m,
47 void MonitorSolution(
int i,
double norm,
const Vector &x,
bool final)
53 MPI_Comm_size(pmesh->GetComm(),&num_procs);
54 MPI_Comm_rank(pmesh->GetComm(),&myid);
56 pgf->SetFromTrueDofs(x);
59 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
60 sol_sock.precision(8);
61 sol_sock <<
"solution\n" << *pmesh << *pgf
62 <<
"window_title 'Iteration no " << i <<
"'"
63 <<
"keys rRjlc\n" << flush;
71 int main(
int argc,
char *argv[])
74 Mpi::Init(argc, argv);
75 int num_procs = Mpi::WorldSize();
76 int myid = Mpi::WorldRank();
80 const char *mesh_file =
"../data/star.mesh";
81 int ser_ref_levels = -1;
82 int par_ref_levels = 2;
87 bool visualization = 1;
90 args.
AddOption(&mesh_file,
"-m",
"--mesh",
92 args.
AddOption(&ser_ref_levels,
"-rs",
"--refine-serial",
93 "Number of times to refine the mesh uniformly in serial,"
95 args.
AddOption(&par_ref_levels,
"-rp",
"--refine-parallel",
96 "Number of times to refine the mesh uniformly in parallel.");
98 "Finite element order (polynomial degree) >= 0.");
100 "One of the three DG penalty parameters, typically +1/-1."
101 " See the documentation of class DGDiffusionIntegrator.");
103 "One of the three DG penalty parameters, should be positive."
104 " Negative values are replaced with (order+1)^2.");
105 args.
AddOption(&eta,
"-e",
"--eta",
"BR2 penalty parameter.");
106 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
107 "--no-visualization",
108 "Enable or disable GLVis visualization.");
120 kappa = (order+1)*(order+1);
130 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
138 if (ser_ref_levels < 0)
140 ser_ref_levels = (int)floor(
log(10000./mesh->
GetNE())/
log(2.)/
dim);
142 for (
int l = 0; l < ser_ref_levels; l++)
158 for (
int l = 0; l < par_ref_levels; l++)
171 cout <<
"Number of unknowns: " << size << endl;
230 CustomSolverMonitor monitor(pmesh, &x);
251 ostringstream mesh_name, sol_name;
252 mesh_name <<
"mesh." << setfill(
'0') << setw(6) << myid;
253 sol_name <<
"sol." << setfill(
'0') << setw(6) << myid;
255 ofstream mesh_ofs(mesh_name.str().c_str());
256 mesh_ofs.precision(8);
257 pmesh->
Print(mesh_ofs);
259 ofstream sol_ofs(sol_name.str().c_str());
260 sol_ofs.precision(8);
267 char vishost[] =
"localhost";
270 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
271 sol_sock.precision(8);
272 sol_sock <<
"solution\n" << *pmesh << x << flush;
Class for domain integration L(v) := (f, v)
A coefficient that is constant across space and time.
HYPRE_BigInt GlobalTrueVSize() const
int GetNE() const
Returns number of elements.
virtual void Save(std::ostream &out) const
Abstract parallel finite element space.
void SetPrintLevel(int print_lvl)
virtual void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
The BoomerAMG solver in hypre.
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
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 *)
void SetMaxIter(int max_it)
virtual void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1)
void SetKDim(int dim)
Set the number of iteration to perform between restarts, default is 50.
void PrintUsage(std::ostream &out) const
Print the usage message.
void SetMaxIter(int max_iter)
L2_FECollection DG_FECollection
Declare an alternative name for L2_FECollection = DG_FECollection.
Wrapper for hypre's parallel vector class.
Abstract base class for an iterative solver monitor.
void SetAbsTol(double atol)
void SetRelTol(double rtol)
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...
FDualNumber< tbase > log(const FDualNumber< tbase > &f)
log([dual number])
void SetMonitor(IterativeSolverMonitor &m)
Set the iterative solver monitor.
NURBSExtension * NURBSext
Optional NURBS mesh extension.
void SetPreconditioner(HypreSolver &precond)
Set the hypre solver to be used as a preconditioner.
void PrintOptions(std::ostream &out) const
Print the options.
Abstract class for hypre's solvers and preconditioners.
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
void Print(std::ostream &out=mfem::out) const override
Class for parallel grid function.
Wrapper for hypre's ParCSR matrix class.
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Solve Ax=b with hypre's PCG.
Class for parallel meshes.
void ParallelProject(Vector &tv) const
Returns the vector restricted to the true dofs.
double f(const Vector &p)
double sigma(const Vector &x)
bool Good() const
Return true if the command line options were parsed successfully.