61 virtual ~DiffusionMultigrid()
68 bool partial_assembly)
82 ConstructBilinearForm(coarse_fespace,
false);
98 AddLevel(hypreCoarseMat, pcg,
true,
true);
104 ConstructBilinearForm(fespace,
true);
108 bfs.Last()->FormSystemMatrix(ess_tdof_list, opr);
112 bfs.Last()->AssembleDiagonal(diag);
122int main(
int argc,
char *argv[])
131 const char *mesh_file =
"../data/star.mesh";
132 int geometric_refinements = 0;
133 int order_refinements = 2;
134 const char *device_config =
"cpu";
135 bool visualization =
true;
138 args.
AddOption(&mesh_file,
"-m",
"--mesh",
139 "Mesh file to use.");
140 args.
AddOption(&geometric_refinements,
"-gr",
"--geometric-refinements",
141 "Number of geometric refinements done prior to order refinements.");
142 args.
AddOption(&order_refinements,
"-or",
"--order-refinements",
143 "Number of order refinements. Finest level in the hierarchy has order 2^{or}.");
144 args.
AddOption(&device_config,
"-d",
"--device",
145 "Device configuration string, see Device::Configure().");
146 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
147 "--no-visualization",
148 "Enable or disable GLVis visualization.");
165 Device device(device_config);
166 if (myid == 0) { device.
Print(); }
171 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
180 (int)floor(log(1000./mesh->
GetNE())/log(2.)/
dim);
181 for (
int l = 0; l < ref_levels; l++)
193 int par_ref_levels = 2;
194 for (
int l = 0; l < par_ref_levels; l++)
211 pmesh, coarse_fespace,
true,
true);
212 for (
int level = 0; level < geometric_refinements; ++level)
216 for (
int level = 0; level < order_refinements; ++level)
225 cout <<
"Number of finite element unknowns: " << size << endl;
252 DiffusionMultigrid* M =
new DiffusionMultigrid(*fespaces, ess_bdr);
275 ostringstream mesh_name, sol_name;
276 mesh_name <<
"mesh." << setfill(
'0') << setw(6) << myid;
277 sol_name <<
"sol." << setfill(
'0') << setw(6) << myid;
279 ofstream mesh_ofs(mesh_name.str().c_str());
280 mesh_ofs.precision(8);
283 ofstream sol_ofs(sol_name.str().c_str());
284 sol_ofs.precision(8);
294 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
295 sol_sock.precision(8);
304 for (
int level = 0; level < collections.
Size(); ++level)
306 delete collections[level];
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
int Size() const
Return the logical size of the array.
int Append(const T &el)
Append element 'el' to array, resize if necessary.
T & Last()
Return the last element in the array.
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 .
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
int GetNumLevels() const
Returns the number of levels in the hierarchy.
virtual const FiniteElementSpace & GetFESpaceAtLevel(int level) const
Returns the finite element space at the given level.
Geometric multigrid associated with a hierarchy of finite element spaces.
void RecoverFineFEMSolution(const Vector &X, const Vector &b, Vector &x)
Recover the solution of a linear system formed with FormFineLinearSystem()
Array< Array< int > * > essentialTrueDofs
Array< BilinearForm * > bfs
const FiniteElementSpaceHierarchy & fespaces
void FormFineLinearSystem(Vector &x, Vector &b, OperatorHandle &A, Vector &X, Vector &B)
Arbitrary order H1-conforming (continuous) finite elements.
The BoomerAMG solver in hypre.
void SetPrintLevel(int print_level)
Wrapper for hypre's ParCSR matrix class.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
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 SetAbsTol(real_t atol)
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
int GetNE() const
Returns number of elements.
int Dimension() const
Dimension of the reference space used within the elements.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
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).
void AddLevel(Operator *op, Solver *smoother, bool ownOperator, bool ownSmoother)
Adds a level to the multigrid operator hierarchy.
void SetCycleType(CycleType cycleType_, int preSmoothingSteps_, int postSmoothingSteps_)
Set cycle type and number of pre- and post-smoothing steps used by Mult.
Chebyshev accelerated smoothing with given vector, no matrix necessary.
Pointer to an Operator of a specified type.
void SetOperatorOwner(bool own=true)
Set the ownership flag for the held Operator.
void SetType(Operator::Type tid)
Invoke Clear() and set a new type id.
Operator * Ptr() const
Access the underlying Operator pointer.
@ ANY_TYPE
ID for the base class Operator, i.e. any type.
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.
void AddUniformlyRefinedLevel(int dim=1, int ordering=Ordering::byVDIM) override
Adds one level to the hierarchy by uniformly refining the mesh on the previous level.
void AddOrderRefinedLevel(FiniteElementCollection *fec, int dim=1, int ordering=Ordering::byVDIM) override
Adds one level to the hierarchy by using a different finite element order defined through FiniteEleme...
const ParFiniteElementSpace & GetFinestFESpace() const override
Returns the finite element space at the finest level.
Abstract parallel finite element space.
HYPRE_BigInt GlobalTrueVSize() const
int GetTrueVSize() const override
Return the number of local vector true dofs.
ParMesh * GetParMesh() const
Class for parallel grid function.
void Save(std::ostream &out) const override
Class for parallel meshes.
void Print(std::ostream &out=mfem::out, const std::string &comments="") const override