HArD::Core3D
Hybrid Arbitrary Degree::Core 3D - Library to implement 3D schemes with vertex, edge, face and cell polynomials as unknowns
vgrad.hpp
Go to the documentation of this file.
1 #ifndef VGRAD_HPP
2 #define VGRAD_HPP
3 
4 #include <globaldofspace.hpp>
5 #include <vemcore.hpp>
6 #include <integralweight.hpp>
7 
8 namespace HArDCore3D
9 {
16 
26  class VGrad : public GlobalDOFSpace
27  {
28  public:
29  typedef std::function<double(const Eigen::Vector3d &)> FunctionType;
30  typedef std::function<Eigen::Vector3d(const Eigen::Vector3d &)> GradientType;
31 
34  {
36  const Eigen::MatrixXd & _proj_gradient,
37  const Eigen::MatrixXd & _dofs_gradient,
38  const Eigen::MatrixXd & _proj_function
39  )
40  : proj_gradient(_proj_gradient),
41  dofs_gradient(_dofs_gradient),
42  proj_function(_proj_function)
43  {
44  // Do nothing
45  }
46 
47  Eigen::MatrixXd proj_gradient;
48  Eigen::MatrixXd dofs_gradient;
49  Eigen::MatrixXd proj_function;
50  };
51 
53  VGrad(const VEMCore & vem_core, bool use_threads = true, std::ostream & output = std::cout);
54 
56  const Mesh & mesh() const
57  {
58  return m_vem_core.mesh();
59  }
60 
62  const size_t & degree() const
63  {
64  return m_vem_core.degree();
65  }
66 
68  Eigen::VectorXd interpolate(
69  const FunctionType & q,
70  const GradientType & grad_q,
71  const int doe_cell = -1,
72  const int doe_face = -1,
73  const int doe_edge = -1
74  ) const;
75 
77  inline const LocalOperators & edgeOperators(size_t iE) const
78  {
79  return *m_edge_operators[iE];
80  }
81 
83  inline const LocalOperators & edgeOperators(const Edge & E) const
84  {
85  return *m_edge_operators[E.global_index()];
86  }
87 
89  inline const LocalOperators & faceOperators(size_t iF) const
90  {
91  return *m_face_operators[iF];
92  }
93 
95  inline const LocalOperators & faceOperators(const Face & F) const
96  {
97  return *m_face_operators[F.global_index()];
98  }
99 
101  inline const LocalOperators & cellOperators(size_t iT) const
102  {
103  return *m_cell_operators[iT];
104  }
105 
107  inline const LocalOperators & cellOperators(const Cell & T) const
108  {
109  return *m_cell_operators[T.global_index()];
110  }
111 
113  inline const VEMCore::CellBases & cellBases(size_t iT) const
114  {
115  return m_vem_core.cellBases(iT);
116  }
117 
119  inline const VEMCore::CellBases & cellBases(const Cell & T) const
120  {
121  return m_vem_core.cellBases(T.global_index());
122  }
123 
125  inline const VEMCore::FaceBases & faceBases(size_t iF) const
126  {
127  return m_vem_core.faceBases(iF);
128  }
129 
131  inline const VEMCore::FaceBases & faceBases(const Face & F) const
132  {
133  return m_vem_core.faceBases(F.global_index());
134  }
135 
137  inline const VEMCore::EdgeBases & edgeBases(size_t iE) const
138  {
139  return m_vem_core.edgeBases(iE);
140  }
141 
143  inline const VEMCore::EdgeBases & edgeBases(const Edge & E) const
144  {
145  return m_vem_core.edgeBases(E.global_index());
146  }
147 
149  // The mass matrix of P^{k+1}(T) is the most expensive mass matrix in the calculation of this norm, which
150  // is why there's the option of passing it as parameter if it's been already pre-computed when the norm is called.
151  Eigen::MatrixXd computeL2Product(
152  const size_t iT,
153  const double & penalty_factor = 1.,
154  const Eigen::MatrixXd & mass_Pkmo_T = Eigen::MatrixXd::Zero(1,1),
155  const IntegralWeight & weight = IntegralWeight(1.)
156  ) const;
157 
158 
159  private:
160  LocalOperators _compute_edge_operators(size_t iE);
161  LocalOperators _compute_face_operators(size_t iF);
162  LocalOperators _compute_cell_operators(size_t iT);
163 
164  const VEMCore & m_vem_core;
165  bool m_use_threads;
166  std::ostream & m_output;
167 
168  // Containers for local operators
169  std::vector<std::unique_ptr<LocalOperators> > m_edge_operators;
170  std::vector<std::unique_ptr<LocalOperators> > m_face_operators;
171  std::vector<std::unique_ptr<LocalOperators> > m_cell_operators;
172  };
173 
174 } // end of namespace HArDCore3D
175 
176 #endif
Base class for global DOF spaces. Provides functions to manipulate global DOFs (the local version bei...
Definition: globaldofspace.hpp:16
Construct all polynomial spaces for the VEM sequence.
Definition: vemcore.hpp:39
Virtual H1 space: local operators, L2 product and global interpolator.
Definition: vgrad.hpp:27
Class to describe a mesh.
Definition: MeshND.hpp:17
bool use_threads
Definition: HHO_DiffAdvecReac.hpp:47
Eigen::MatrixXd proj_function
Definition: vgrad.hpp:49
Eigen::MatrixXd computeL2Product(const size_t iT, const double &penalty_factor=1., const Eigen::MatrixXd &mass_Pkmo_T=Eigen::MatrixXd::Zero(1, 1), const IntegralWeight &weight=IntegralWeight(1.)) const
Compute the matrix of the (weighted) L2-product for the cell of index iT. The stabilisation here is b...
Definition: vgrad.cpp:443
const CellBases & cellBases(size_t iT) const
Return cell bases for element iT.
Definition: vemcore.hpp:129
const Mesh & mesh() const
Return a const reference to the mesh.
Definition: vemcore.hpp:117
const VEMCore::EdgeBases & edgeBases(const Edge &E) const
Return edge bases for edge E.
Definition: vgrad.hpp:143
const VEMCore::CellBases & cellBases(const Cell &T) const
Return cell bases for cell T.
Definition: vgrad.hpp:119
const LocalOperators & faceOperators(size_t iF) const
Return face operators for the face of index iF.
Definition: vgrad.hpp:89
const LocalOperators & edgeOperators(size_t iE) const
Return edge operators for the edge of index iE.
Definition: vgrad.hpp:77
const size_t & degree() const
Return the polynomial degree.
Definition: vgrad.hpp:62
const FaceBases & faceBases(size_t iF) const
Return face bases for face iF.
Definition: vemcore.hpp:137
std::function< double(const Eigen::Vector3d &)> FunctionType
Definition: vgrad.hpp:29
const LocalOperators & edgeOperators(const Edge &E) const
Return edge operators for edge E.
Definition: vgrad.hpp:83
Eigen::MatrixXd dofs_gradient
Definition: vgrad.hpp:48
const VEMCore::CellBases & cellBases(size_t iT) const
Return cell bases for the cell of index iT.
Definition: vgrad.hpp:113
const LocalOperators & cellOperators(const Cell &T) const
Return cell operators for cell T.
Definition: vgrad.hpp:107
const VEMCore::FaceBases & faceBases(size_t iF) const
Return face bases for the face of index iF.
Definition: vgrad.hpp:125
const size_t & degree() const
Return the polynomial degree.
Definition: vemcore.hpp:123
Eigen::MatrixXd proj_gradient
Definition: vgrad.hpp:47
std::function< Eigen::Vector3d(const Eigen::Vector3d &)> GradientType
Definition: vgrad.hpp:30
Eigen::VectorXd interpolate(const FunctionType &q, const GradientType &grad_q, const int doe_cell=-1, const int doe_face=-1, const int doe_edge=-1) const
Interpolator of a continuous function.
Definition: vgrad.cpp:77
const LocalOperators & cellOperators(size_t iT) const
Return cell operators for the cell of index iT.
Definition: vgrad.hpp:101
const VEMCore::FaceBases & faceBases(const Face &F) const
Return cell bases for face F.
Definition: vgrad.hpp:131
const LocalOperators & faceOperators(const Face &F) const
Return face operators for face F.
Definition: vgrad.hpp:95
LocalOperators(const Eigen::MatrixXd &_proj_gradient, const Eigen::MatrixXd &_dofs_gradient, const Eigen::MatrixXd &_proj_function)
Definition: vgrad.hpp:35
const VEMCore::EdgeBases & edgeBases(size_t iE) const
Return edge bases for the edge of index iE.
Definition: vgrad.hpp:137
VGrad(const VEMCore &vem_core, bool use_threads=true, std::ostream &output=std::cout)
Constructor.
Definition: vgrad.cpp:15
const EdgeBases & edgeBases(size_t iE) const
Return edge bases for edge iE.
Definition: vemcore.hpp:145
const Mesh & mesh() const
Return the mesh.
Definition: vgrad.hpp:56
Definition: ddr-magnetostatics.hpp:40
MeshND::Edge< 2 > Edge
Definition: Mesh2D.hpp:11
MeshND::Face< 2 > Face
Definition: Mesh2D.hpp:12
MeshND::Cell< 2 > Cell
Definition: Mesh2D.hpp:13
Structure for weights (scalar, at the moment) in integral.
Definition: integralweight.hpp:36
Structure to store element bases.
Definition: vemcore.hpp:63
Structure to store edge bases.
Definition: vemcore.hpp:104
Structure to store face bases.
Definition: vemcore.hpp:84
A structure to store local operators (projection of gradient and function, dof of gradient in Vcurl)
Definition: vgrad.hpp:34