MFEM  v4.5.1
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
fespacehierarchy.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2022, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 #ifndef MFEM_FESPACEHIERARCHY
13 #define MFEM_FESPACEHIERARCHY
14 
15 #include "fespace.hpp"
16 
17 #ifdef MFEM_USE_MPI
18 #include "pfespace.hpp"
19 #endif
20 
21 namespace mfem
22 {
23 
24 /// Class bundling a hierarchy finite element spaces together with the
25 /// corresponding prolongation operators
27 {
28 protected:
35 
36 public:
37 
38  /// Construct an empty finite element space hierarchy. This is useful if the
39  /// hierarchy is constructed by coarsening a fine space, rather than refining
40  /// a coarse space.
42 
43  /// @brief Constructs a space hierarchy with the given mesh and space on the
44  /// coarsest level.
45  /** The ownership of the mesh and space may be transferred to the
46  FiniteElementSpaceHierarchy by setting the according boolean variables. */
47  FiniteElementSpaceHierarchy(Mesh* mesh, FiniteElementSpace* fespace, bool ownM,
48  bool ownFES);
49 
50  /// Destructor deleting all meshes and spaces that are owned
52 
53  /// Returns the number of levels in the hierarchy
54  int GetNumLevels() const;
55 
56  /// Returns the index of the finest level
57  int GetFinestLevelIndex() const;
58 
59  /// Adds one level to the hierarchy
60  void AddLevel(Mesh* mesh, FiniteElementSpace* fespace, Operator* prolongation,
61  bool ownM, bool ownFES, bool ownP);
62 
63  /// @brief Adds one level to the hierarchy by uniformly refining the mesh on the
64  /// previous level
65  virtual void AddUniformlyRefinedLevel(int dim = 1,
66  int ordering = Ordering::byVDIM);
67 
68  /// @brief Adds one level to the hierarchy by using a different finite element
69  /// order defined through FiniteElementCollection
70  virtual void AddOrderRefinedLevel(FiniteElementCollection* fec, int dim = 1,
71  int ordering = Ordering::byVDIM);
72 
73  /// Returns the finite element space at the given level
74  virtual const FiniteElementSpace& GetFESpaceAtLevel(int level) const;
75 
76  /// Returns the finite element space at the given level
77  virtual FiniteElementSpace& GetFESpaceAtLevel(int level);
78 
79  /// Returns the finite element space at the finest level
80  virtual const FiniteElementSpace& GetFinestFESpace() const;
81 
82  /// Returns the finite element space at the finest level
84 
85  /// @brief Returns the prolongation operator from the finite element space at
86  /// level to the finite element space at level + 1
87  Operator* GetProlongationAtLevel(int level) const;
88 };
89 
90 #ifdef MFEM_USE_MPI
92 {
93 public:
94  /// @brief Constructs a parallel space hierarchy with the given mesh and spaces
95  /// on level zero.
96  /** The ownership of the mesh and space may be transferred to the
97  ParFiniteElementSpaceHierarchy by setting the according boolean variables. */
99  bool ownM,
100  bool ownFES);
101 
102  /// @brief Adds one level to the hierarchy by uniformly refining the mesh on the
103  /// previous level
104  void AddUniformlyRefinedLevel(int dim = 1,
105  int ordering = Ordering::byVDIM) override;
106 
107  /// @brief Adds one level to the hierarchy by using a different finite element
108  /// order defined through FiniteElementCollection
110  int ordering = Ordering::byVDIM) override;
111 
112  /// Returns the finite element space at the given level
113  const ParFiniteElementSpace& GetFESpaceAtLevel(int level) const override;
114 
115  /// Returns the finite element space at the given level
116  ParFiniteElementSpace& GetFESpaceAtLevel(int level) override;
117 
118  /// Returns the finite element space at the finest level
119  const ParFiniteElementSpace& GetFinestFESpace() const override;
120 
121  /// Returns the finite element space at the finest level
123 };
124 #endif
125 
126 } // namespace mfem
127 
128 #endif
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...
const ParFiniteElementSpace & GetFinestFESpace() const override
Returns the finite element space at the finest level.
Abstract parallel finite element space.
Definition: pfespace.hpp:28
const ParFiniteElementSpace & GetFESpaceAtLevel(int level) const override
Returns the finite element space at the given 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...
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.
virtual ~FiniteElementSpaceHierarchy()
Destructor deleting all meshes and spaces that are owned.
Array< FiniteElementSpace * > fespaces
int GetNumLevels() const
Returns the number of levels in the hierarchy.
void AddLevel(Mesh *mesh, FiniteElementSpace *fespace, Operator *prolongation, bool ownM, bool ownFES, bool ownP)
Adds one level to the hierarchy.
int GetFinestLevelIndex() const
Returns the index of the finest level.
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...
Definition: fespace.hpp:96
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
Definition: fe_coll.hpp:26
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.
ParFiniteElementSpaceHierarchy(ParMesh *mesh, ParFiniteElementSpace *fespace, bool ownM, bool ownFES)
Constructs a parallel space hierarchy with the given mesh and spaces on level zero.
int dim
Definition: ex24.cpp:53
Operator * GetProlongationAtLevel(int level) const
Returns the prolongation operator from the finite element space at level to the finite element space ...
Abstract operator.
Definition: operator.hpp:24
Class for parallel meshes.
Definition: pmesh.hpp:32
virtual const FiniteElementSpace & GetFinestFESpace() const
Returns the finite element space at the finest level.