55 for (
int level = 1; level < fespaces.
GetNumLevels(); ++level)
61 virtual ~DiffusionMultigrid()
68 bool partial_assembly)
86 ConstructBilinearForm(coarse_fespace, ess_bdr,
false);
89 bfs.Last()->FormSystemMatrix(*essentialTrueDofs.Last(), *hypreCoarseMat);
102 AddLevel(hypreCoarseMat, pcg,
true,
true);
108 ConstructBilinearForm(fespace, ess_bdr,
true);
111 opr.
SetType(Operator::ANY_TYPE);
112 bfs.Last()->FormSystemMatrix(*essentialTrueDofs.Last(), opr);
116 bfs.Last()->AssembleDiagonal(diag);
121 AddLevel(opr.
Ptr(), smoother,
true,
true);
126 int main(
int argc,
char *argv[])
129 Mpi::Init(argc, argv);
130 int num_procs = Mpi::WorldSize();
131 int myid = Mpi::WorldRank();
135 const char *mesh_file =
"../data/star.mesh";
136 int geometric_refinements = 0;
137 int order_refinements = 2;
138 const char *device_config =
"cpu";
139 bool visualization =
true;
142 args.
AddOption(&mesh_file,
"-m",
"--mesh",
143 "Mesh file to use.");
144 args.
AddOption(&geometric_refinements,
"-gr",
"--geometric-refinements",
145 "Number of geometric refinements done prior to order refinements.");
146 args.
AddOption(&order_refinements,
"-or",
"--order-refinements",
147 "Number of order refinements. Finest level in the hierarchy has order 2^{or}.");
148 args.
AddOption(&device_config,
"-d",
"--device",
149 "Device configuration string, see Device::Configure().");
150 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
151 "--no-visualization",
152 "Enable or disable GLVis visualization.");
169 Device device(device_config);
170 if (myid == 0) { device.
Print(); }
175 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
184 (int)floor(log(1000./mesh->
GetNE())/log(2.)/
dim);
185 for (
int l = 0; l < ref_levels; l++)
197 int par_ref_levels = 2;
198 for (
int l = 0; l < par_ref_levels; l++)
215 pmesh, coarse_fespace,
true,
true);
216 for (
int level = 0; level < geometric_refinements; ++level)
220 for (
int level = 0; level < order_refinements; ++level)
229 cout <<
"Number of finite element unknowns: " << size << endl;
256 DiffusionMultigrid* M =
new DiffusionMultigrid(*fespaces, ess_bdr);
257 M->SetCycleType(Multigrid::CycleType::VCYCLE, 1, 1);
261 M->FormFineLinearSystem(x, *
b, A, X, B);
274 M->RecoverFineFEMSolution(X, *
b, x);
279 ostringstream mesh_name, sol_name;
280 mesh_name <<
"mesh." << setfill(
'0') << setw(6) << myid;
281 sol_name <<
"sol." << setfill(
'0') << setw(6) << myid;
283 ofstream mesh_ofs(mesh_name.str().c_str());
284 mesh_ofs.precision(8);
287 ofstream sol_ofs(sol_name.str().c_str());
288 sol_ofs.precision(8);
298 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
299 sol_sock.precision(8);
308 for (
int level = 0; level < collections.
Size(); ++level)
310 delete collections[level];
Class for domain integration L(v) := (f, v)
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1)
Conjugate gradient method.
Chebyshev accelerated smoothing with given vector, no matrix necessary.
A coefficient that is constant across space and time.
void PrintOptions(std::ostream &out) const
Print the options.
void PrintUsage(std::ostream &out) const
Print the usage message.
Geometric multigrid associated with a hierarchy of finite element spaces.
Pointer to an Operator of a specified type.
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
const ParFiniteElementSpace & GetFinestFESpace() const override
Returns the finite element space at the finest level.
void Print(std::ostream &out=mfem::out)
Print the configuration of the MFEM virtual device object.
bool Good() const
Return true if the command line options were parsed successfully.
Abstract parallel finite element space.
int main(int argc, char *argv[])
const ParFiniteElementSpace & GetFESpaceAtLevel(int level) const override
Returns the finite element space at the given level.
The BoomerAMG solver in hypre.
int GetNumLevels() const
Returns the number of levels in the hierarchy.
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...
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
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 Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
int Append(const T &el)
Append element 'el' to array, resize if necessary.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
void SetPrintLevel(int print_level)
ParMesh * GetParMesh() const
void SetMaxIter(int max_it)
HYPRE_BigInt GlobalTrueVSize() const
void SetAbsTol(double atol)
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
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...
int GetNE() const
Returns number of elements.
virtual int GetTrueVSize() const
Return the number of local vector true dofs.
void SetOperatorOwner(bool own=true)
Set the ownership flag for the held Operator.
Operator * Ptr() const
Access the underlying Operator pointer.
int Size() const
Return the logical size of the array.
T & Last()
Return the last element in the array.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
Arbitrary order H1-conforming (continuous) finite elements.
void Print(std::ostream &out=mfem::out) const override
Class for parallel grid function.
The MFEM Device class abstracts hardware devices such as GPUs, as well as programming models such as ...
Wrapper for hypre's ParCSR matrix class.
Class for parallel meshes.
void SetType(Operator::Type tid)
Invoke Clear() and set a new type id.