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[])
75 MPI_Init(&argc, &argv);
76 MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
77 MPI_Comm_rank(MPI_COMM_WORLD, &myid);
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.");
121 kappa = (order+1)*(order+1);
131 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
139 if (ser_ref_levels < 0)
141 ser_ref_levels = (int)floor(log(10000./mesh->
GetNE())/log(2.)/
dim);
143 for (
int l = 0; l < ser_ref_levels; l++)
159 for (
int l = 0; l < par_ref_levels; l++)
172 cout <<
"Number of unknowns: " << size << endl;
231 CustomSolverMonitor monitor(pmesh, &x);
252 ostringstream mesh_name, sol_name;
253 mesh_name <<
"mesh." << setfill(
'0') << setw(6) << myid;
254 sol_name <<
"sol." << setfill(
'0') << setw(6) << myid;
256 ofstream mesh_ofs(mesh_name.str().c_str());
257 mesh_ofs.precision(8);
258 pmesh->
Print(mesh_ofs);
260 ofstream sol_ofs(sol_name.str().c_str());
261 sol_ofs.precision(8);
268 char vishost[] =
"localhost";
271 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
272 sol_sock.precision(8);
273 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 Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
The BoomerAMG solver in hypre.
void SetPrintLevel(int print_lvl)
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
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.
virtual void Print(std::ostream &out=mfem::out) const
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...
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.
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.