56 for (
int level = 1; level < fespaces.
GetNumLevels(); ++level)
78 ConstructBilinearForm(coarse_fespace, ess_bdr);
81 opr.
SetType(Operator::ANY_TYPE);
82 bfs.Last()->FormSystemMatrix(*essentialTrueDofs.Last(), opr);
92 AddLevel(opr.
Ptr(), pcg,
true,
true);
98 ConstructBilinearForm(fespace, ess_bdr);
101 opr.
SetType(Operator::ANY_TYPE);
102 bfs.Last()->FormSystemMatrix(*essentialTrueDofs.Last(), opr);
106 bfs.Last()->AssembleDiagonal(diag);
109 *essentialTrueDofs.Last(), 2);
110 AddLevel(opr.
Ptr(), smoother,
true,
true);
115 int main(
int argc,
char *argv[])
118 const char *mesh_file =
"../data/star.mesh";
119 int geometric_refinements = 0;
120 int order_refinements = 2;
121 const char *device_config =
"cpu";
122 bool visualization =
true;
125 args.
AddOption(&mesh_file,
"-m",
"--mesh",
126 "Mesh file to use.");
127 args.
AddOption(&geometric_refinements,
"-gr",
"--geometric-refinements",
128 "Number of geometric refinements done prior to order refinements.");
129 args.
AddOption(&order_refinements,
"-or",
"--order-refinements",
130 "Number of order refinements. Finest level in the hierarchy has order 2^{or}.");
131 args.
AddOption(&device_config,
"-d",
"--device",
132 "Device configuration string, see Device::Configure().");
133 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
134 "--no-visualization",
135 "Enable or disable GLVis visualization.");
146 Device device(device_config);
152 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
162 for (
int l = 0; l < ref_levels; l++)
179 for (
int level = 0; level < geometric_refinements; ++level)
183 for (
int level = 0; level < order_refinements; ++level)
189 cout <<
"Number of finite element unknowns: "
213 DiffusionMultigrid M(fespaces, ess_bdr);
214 M.SetCycleType(Multigrid::CycleType::VCYCLE, 1, 1);
218 M.FormFineLinearSystem(x, *b, A, X, B);
219 cout <<
"Size of linear system: " << A->
Height() << endl;
222 PCG(*A, M, B, X, 1, 2000, 1e-12, 0.0);
225 M.RecoverFineFEMSolution(X, *b, x);
229 ofstream mesh_ofs(
"refined.mesh");
230 mesh_ofs.precision(8);
232 ofstream sol_ofs(
"sol.gf");
233 sol_ofs.precision(8);
242 sol_sock.precision(8);
249 for (
int level = 0; level < collections.
Size(); ++level)
251 delete collections[level];
virtual void AddOrderRefinedLevel(FiniteElementCollection *fec, int dim=1, int ordering=Ordering::byVDIM)
Adds one level to the hierarchy by using a different finite element order defined through FiniteEleme...
int Size() const
Return the logical size of the array.
Class for domain integration L(v) := (f, v)
Conjugate gradient method.
Class for grid function - Vector with associated FE space.
Chebyshev accelerated smoothing with given vector, no matrix necessary.
A coefficient that is constant across space and time.
Geometric multigrid associated with a hierarchy of finite element spaces.
Pointer to an Operator of a specified type.
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1)
Get a list of essential true dofs, ess_tdof_list, corresponding to the boundary attributes marked in ...
int GetNE() const
Returns number of elements.
void Print(std::ostream &out=mfem::out)
Print the configuration of the MFEM virtual device object.
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 ...
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
int Append(const T &el)
Append element 'el' to array, resize if necessary.
Mesh * GetMesh() const
Returns the mesh.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
void SetMaxIter(int max_it)
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
int GetNumLevels() const
Returns the number of levels in the hierarchy.
void PCG(const Operator &A, Solver &B, const Vector &b, Vector &x, int print_iter, int max_num_iter, double RTOLERANCE, double ATOLERANCE)
Preconditioned conjugate gradient method. (tolerances are squared)
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
void PrintUsage(std::ostream &out) const
Print the usage message.
Operator * Ptr() const
Access the underlying Operator pointer.
FDualNumber< tbase > pow(const FDualNumber< tbase > &a, const FDualNumber< tbase > &b)
pow([dual number],[dual number])
void SetAbsTol(double atol)
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
void SetRelTol(double rtol)
virtual const FiniteElementSpace & GetFESpaceAtLevel(int level) const
Returns the finite element space at the given level.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
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])
virtual void AddUniformlyRefinedLevel(int dim=1, int ordering=Ordering::byVDIM)
Adds one level to the hierarchy by uniformly refining the mesh on the previous level.
void SetOperatorOwner(bool own=true)
Set the ownership flag for the held Operator.
virtual void Print(std::ostream &os=mfem::out) const
FDualNumber< tbase > sqrt(const FDualNumber< tbase > &f)
sqrt([dual number])
void PrintOptions(std::ostream &out) const
Print the options.
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.
Arbitrary order H1-conforming (continuous) finite elements.
The MFEM Device class abstracts hardware devices such as GPUs, as well as programming models such as ...
virtual const FiniteElementSpace & GetFinestFESpace() const
Returns the finite element space at the finest level.
void SetType(Operator::Type tid)
Invoke Clear() and set a new type id.
bool Good() const
Return true if the command line options were parsed successfully.