73 ConstructBilinearForm(coarse_fespace);
93 ConstructBilinearForm(fespace);
97 bfs[level]->FormSystemMatrix(ess_tdof_list, opr);
101 bfs[level]->AssembleDiagonal(diag);
109int main(
int argc,
char *argv[])
112 const char *mesh_file =
"../data/star.mesh";
113 int geometric_refinements = 0;
114 int order_refinements = 2;
115 const char *device_config =
"cpu";
116 bool visualization =
true;
119 args.
AddOption(&mesh_file,
"-m",
"--mesh",
120 "Mesh file to use.");
121 args.
AddOption(&geometric_refinements,
"-gr",
"--geometric-refinements",
122 "Number of geometric refinements done prior to order refinements.");
123 args.
AddOption(&order_refinements,
"-or",
"--order-refinements",
124 "Number of order refinements. Finest level in the hierarchy has order 2^{or}.");
125 args.
AddOption(&device_config,
"-d",
"--device",
126 "Device configuration string, see Device::Configure().");
127 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
128 "--no-visualization",
129 "Enable or disable GLVis visualization.");
140 Device device(device_config);
146 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
155 (int)floor(log(5000./mesh->
GetNE())/log(2.)/
dim);
156 for (
int l = 0; l < ref_levels; l++)
173 for (
int level = 0; level < geometric_refinements; ++level)
177 for (
int level = 0; level < order_refinements; ++level)
183 cout <<
"Number of finite element unknowns: "
207 DiffusionMultigrid M(fespaces, ess_bdr);
213 cout <<
"Size of linear system: " << A->
Height() << endl;
216 PCG(*A, M, B, X, 1, 2000, 1e-12, 0.0);
223 ofstream mesh_ofs(
"refined.mesh");
224 mesh_ofs.precision(8);
226 ofstream sol_ofs(
"sol.gf");
227 sol_ofs.precision(8);
236 sol_sock.precision(8);
243 for (
int level = 0; level < collections.
Size(); ++level)
245 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.
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 & GetFinestFESpace() const
Returns the finite element space at the finest level.
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.
virtual const FiniteElementSpace & GetFESpaceAtLevel(int level) const
Returns the finite element space at the given 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...
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
Mesh * GetMesh() const
Returns the mesh.
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)
Class for grid function - Vector with associated FE space.
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
Arbitrary order H1-conforming (continuous) finite elements.
void SetRelTol(real_t rtol)
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.
virtual void Print(std::ostream &os=mfem::out, const std::string &comments="") const
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 *)
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.
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
@ 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 PCG(const Operator &A, Solver &B, const Vector &b, Vector &x, int print_iter, int max_num_iter, real_t RTOLERANCE, real_t ATOLERANCE)
Preconditioned conjugate gradient method. (tolerances are squared)