41 CustomSolverMonitor(
const ParMesh *m,
46 void MonitorSolution(
int i,
double norm,
const Vector &x,
bool final)
52 MPI_Comm_size(pmesh->GetComm(),&num_procs);
53 MPI_Comm_rank(pmesh->GetComm(),&myid);
55 pgf->SetFromTrueDofs(x);
58 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
59 sol_sock.precision(8);
60 sol_sock <<
"solution\n" << *pmesh << *pgf
61 <<
"window_title 'Iteration no " << i <<
"'"
62 <<
"keys rRjlc\n" << flush;
70 int main(
int argc,
char *argv[])
74 MPI_Init(&argc, &argv);
75 MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
76 MPI_Comm_rank(MPI_COMM_WORLD, &myid);
79 const char *mesh_file =
"../data/star.mesh";
80 int ser_ref_levels = -1;
81 int par_ref_levels = 2;
85 bool visualization = 1;
88 args.
AddOption(&mesh_file,
"-m",
"--mesh",
90 args.
AddOption(&ser_ref_levels,
"-rs",
"--refine-serial",
91 "Number of times to refine the mesh uniformly in serial,"
93 args.
AddOption(&par_ref_levels,
"-rp",
"--refine-parallel",
94 "Number of times to refine the mesh uniformly in parallel.");
96 "Finite element order (polynomial degree) >= 0.");
98 "One of the two DG penalty parameters, typically +1/-1."
99 " See the documentation of class DGDiffusionIntegrator.");
101 "One of the two DG penalty parameters, should be positive."
102 " Negative values are replaced with (order+1)^2.");
103 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
104 "--no-visualization",
105 "Enable or disable GLVis visualization.");
118 kappa = (order+1)*(order+1);
128 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
136 if (ser_ref_levels < 0)
138 ser_ref_levels = (int)floor(log(10000./mesh->
GetNE())/log(2.)/
dim);
140 for (
int l = 0; l < ser_ref_levels; l++)
156 for (
int l = 0; l < par_ref_levels; l++)
169 cout <<
"Number of unknowns: " << size << endl;
223 CustomSolverMonitor monitor(pmesh, &x);
244 ostringstream mesh_name, sol_name;
245 mesh_name <<
"mesh." << setfill(
'0') << setw(6) << myid;
246 sol_name <<
"sol." << setfill(
'0') << setw(6) << myid;
248 ofstream mesh_ofs(mesh_name.str().c_str());
249 mesh_ofs.precision(8);
250 pmesh->
Print(mesh_ofs);
252 ofstream sol_ofs(sol_name.str().c_str());
253 sol_ofs.precision(8);
260 char vishost[] =
"localhost";
263 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
264 sol_sock.precision(8);
265 sol_sock <<
"solution\n" << *pmesh << x << flush;
Class for domain integration L(v) := (f, v)
A coefficient that is constant across space and time.
int GetNE() const
Returns number of elements.
virtual void Save(std::ostream &out) const
Abstract parallel finite element space.
int main(int argc, char *argv[])
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)
HYPRE_Int GlobalTrueVSize() const
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.