MFEM  v4.2.0
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-2020, 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  /// @brief Constructs a space hierarchy with the given mesh and space on the
39  /// coarsest level.
40  /** The ownership of the mesh and space may be transferred to the
41  FiniteElementSpaceHierarchy by setting the according boolean variables. */
42  FiniteElementSpaceHierarchy(Mesh* mesh, FiniteElementSpace* fespace, bool ownM,
43  bool ownFES);
44 
45  /// Destructor deleting all meshes and spaces that are owned
47 
48  /// Returns the number of levels in the hierarchy
49  int GetNumLevels() const;
50 
51  /// Returns the index of the finest level
52  int GetFinestLevelIndex() const;
53 
54  /// Adds one level to the hierarchy
55  void AddLevel(Mesh* mesh, FiniteElementSpace* fespace, Operator* prolongation,
56  bool ownM, bool ownFES, bool ownP);
57 
58  /// @brief Adds one level to the hierarchy by uniformly refining the mesh on the
59  /// previous level
60  virtual void AddUniformlyRefinedLevel(int dim = 1,
61  int ordering = Ordering::byVDIM);
62 
63  /// @brief Adds one level to the hierarchy by using a different finite element
64  /// order defined through FiniteElementCollection
65  virtual void AddOrderRefinedLevel(FiniteElementCollection* fec, int dim = 1,
66  int ordering = Ordering::byVDIM);
67 
68  /// Returns the finite element space at the given level
69  virtual const FiniteElementSpace& GetFESpaceAtLevel(int level) const;
70 
71  /// Returns the finite element space at the given level
72  virtual FiniteElementSpace& GetFESpaceAtLevel(int level);
73 
74  /// Returns the finite element space at the finest level
75  virtual const FiniteElementSpace& GetFinestFESpace() const;
76 
77  /// Returns the finite element space at the finest level
79 
80  /// @brief Returns the prolongation operator from the finite element space at
81  /// level to the finite element space at level + 1
82  Operator* GetProlongationAtLevel(int level) const;
83 };
84 
85 #ifdef MFEM_USE_MPI
87 {
88 public:
89  /// @brief Constructs a parallel space hierarchy with the given mesh and spaces
90  /// on level zero.
91  /** The ownership of the mesh and space may be transferred to the
92  ParFiniteElementSpaceHierarchy by setting the according boolean variables. */
94  bool ownM,
95  bool ownFES);
96 
97  /// @brief Adds one level to the hierarchy by uniformly refining the mesh on the
98  /// previous level
99  void AddUniformlyRefinedLevel(int dim = 1,
100  int ordering = Ordering::byVDIM) override;
101 
102  /// @brief Adds one level to the hierarchy by using a different finite element
103  /// order defined through FiniteElementCollection
105  int ordering = Ordering::byVDIM) override;
106 
107  /// Returns the finite element space at the given level
108  const ParFiniteElementSpace& GetFESpaceAtLevel(int level) const override;
109 
110  /// Returns the finite element space at the given level
111  ParFiniteElementSpace& GetFESpaceAtLevel(int level) override;
112 
113  /// Returns the finite element space at the finest level
114  const ParFiniteElementSpace& GetFinestFESpace() const override;
115 
116  /// Returns the finite element space at the finest level
118 };
119 #endif
120 
121 } // namespace mfem
122 
123 #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:87
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
Definition: fe_coll.hpp:26
FiniteElementSpaceHierarchy(Mesh *mesh, FiniteElementSpace *fespace, bool ownM, bool ownFES)
Constructs a space hierarchy with the given mesh and space on the coarsest 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.
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.