HArD::Core3D
Hybrid Arbitrary Degree::Core 3D - Library to implement 3D schemes with vertex, edge, face and cell polynomials as unknowns
sxgrad.hpp
Go to the documentation of this file.
1 #ifndef SXGRAD_HPP
2 #define SXGRAD_HPP
3 
4 #include <variabledofspace.hpp>
5 #include <ddrcore.hpp>
6 #include <integralweight.hpp>
7 #include <xgrad.hpp>
9 
10 namespace HArDCore3D
11 {
18 
19  class SXGrad : public VariableDOFSpace
20  {
21  public:
22  typedef std::function<double(const Eigen::Vector3d &)> FunctionType;
23 
25 
27  {
29  const Eigen::MatrixXd & _serendipity,
30  const Eigen::MatrixXd & _extension,
31  const Eigen::MatrixXd & _reduction
32  )
33  : serendipity(_serendipity),
34  extension(_extension),
35  reduction(_reduction)
36  {
37  // Do nothing
38  }
39 
40  Eigen::MatrixXd serendipity;
41  Eigen::MatrixXd extension;
42  Eigen::MatrixXd reduction;
43  };
44 
46  SXGrad(const DDRCore & ddr_core, const SerendipityProblem & ser_pro, bool use_threads = true, std::ostream & output = std::cout);
47 
49  const Mesh & mesh() const
50  {
51  return m_ddr_core.mesh();
52  }
53 
55  const size_t & degree() const
56  {
57  return m_ddr_core.degree();
58  }
59 
60  const SerendipityProblem & serPro() const
61  {
62  return m_ser_pro;
63  }
64 
66  Eigen::VectorXd interpolate(
67  const FunctionType & q,
68  const int doe_cell = -1,
69  const int doe_face = -1,
70  const int doe_edge = -1
71  ) const;
72 
73  //---------------------------------//
74  //---- Face transfer operators-----//
75 
77  inline const Eigen::MatrixXd & SgradFace(size_t iF) const
78  {
79  return (*m_face_transfer_operators[iF]).serendipity;
80  }
81 
83  inline const Eigen::MatrixXd & EgradFace(size_t iF) const
84  {
85  return (*m_face_transfer_operators[iF]).extension;
86  }
87 
89  inline const Eigen::MatrixXd & RgradFace(size_t iF) const
90  {
91  return (*m_face_transfer_operators[iF]).reduction;
92  }
93 
95  inline const Eigen::MatrixXd & SgradFace(const Face & F) const
96  {
97  return SgradFace(F.global_index());
98  }
99 
101  inline const Eigen::MatrixXd & EgradFace(const Face & F) const
102  {
103  return EgradFace(F.global_index());
104  }
105 
107  inline const Eigen::MatrixXd & RgradFace(const Face & F) const
108  {
109  return RgradFace(F.global_index());
110  }
111 
112  //---------------------------------//
113  //---- Cell transfer operators -----//
115  inline const Eigen::MatrixXd & SgradCell(size_t iT) const
116  {
117  return (*m_cell_transfer_operators[iT]).serendipity;
118  }
119 
121  inline const Eigen::MatrixXd & EgradCell(size_t iT) const
122  {
123  return (*m_cell_transfer_operators[iT]).extension;
124  }
125 
127  inline const Eigen::MatrixXd & RgradCell(size_t iT) const
128  {
129  return (*m_cell_transfer_operators[iT]).reduction;
130  }
131 
133  inline const Eigen::MatrixXd & SgradCell(const Cell & T) const
134  {
135  return SgradCell(T.global_index());
136  }
137 
139  inline const Eigen::MatrixXd & EgradCell(const Cell & T) const
140  {
141  return EgradCell(T.global_index());
142  }
143 
145  inline const Eigen::MatrixXd & RgradCell(const Cell & T) const
146  {
147  return RgradCell(T.global_index());
148  }
149 
150  //---------------------------------------------------------------------//
151  //---- Full gradient and potential reconstructions, and L2 product ----//
152 
154  inline const Eigen::MatrixXd edgeGradient(size_t iE) const
155  {
156  return m_xgrad.edgeOperators(iE).gradient;
157  }
158 
160  inline const Eigen::MatrixXd edgeGradient(const Edge & E) const
161  {
162  return edgeGradient(E.global_index());
163  }
164 
166  inline const Eigen::MatrixXd edgePotential(size_t iE) const
167  {
168  return m_xgrad.edgeOperators(iE).potential;
169  }
170 
172  inline const Eigen::MatrixXd edgePotential(const Edge & E) const
173  {
174  return edgePotential(E.global_index());
175  }
176 
178  inline const Eigen::MatrixXd faceGradient(size_t iF) const
179  {
180  return m_xgrad.faceOperators(iF).gradient * EgradFace(iF);
181  }
182 
184  inline const Eigen::MatrixXd faceGradient(const Face & F) const
185  {
186  return faceGradient(F.global_index());
187  }
188 
190  inline const Eigen::MatrixXd facePotential(size_t iF) const
191  {
192  return m_xgrad.faceOperators(iF).potential * EgradFace(iF);
193  }
194 
196  inline const Eigen::MatrixXd facePotential(const Face & F) const
197  {
198  return facePotential(F.global_index());
199  }
200 
202  inline const Eigen::MatrixXd cellGradient(size_t iT) const
203  {
204  return m_xgrad.cellOperators(iT).gradient * EgradCell(iT);
205  }
206 
208  inline const Eigen::MatrixXd cellGradient(const Cell & T) const
209  {
210  return cellGradient(T.global_index());
211  }
212 
214  inline const Eigen::MatrixXd cellPotential(size_t iT) const
215  {
216  return m_xgrad.cellOperators(iT).potential * EgradCell(iT);
217  }
218 
220  inline const Eigen::MatrixXd cellPotential(const Cell & T) const
221  {
222  return cellPotential(T.global_index());
223  }
224 
226  Eigen::MatrixXd computeL2Product(
227  const size_t iT,
228  const double & penalty_factor = 1.,
229  const Eigen::MatrixXd & mass_Pk3_T = Eigen::MatrixXd::Zero(1,1),
230  const IntegralWeight & weight = IntegralWeight(1.)
231  ) const
232  {
233  return EgradCell(iT).transpose()
234  * m_xgrad.computeL2Product(iT, penalty_factor, mass_Pk3_T, weight)
235  *EgradCell(iT);
236  }
237 
238 
239  //-----------------------//
240  //---- Getters ----------//
241 
243  inline const DDRCore::CellBases & cellBases(size_t iT) const
244  {
245  return m_ddr_core.cellBases(iT);
246  }
247 
249  inline const DDRCore::CellBases & cellBases(const Cell & T) const
250  {
251  return m_ddr_core.cellBases(T.global_index());
252  }
253 
255  inline const DDRCore::FaceBases & faceBases(size_t iF) const
256  {
257  return m_ddr_core.faceBases(iF);
258  }
259 
261  inline const DDRCore::FaceBases & faceBases(const Face & F) const
262  {
263  return m_ddr_core.faceBases(F.global_index());
264  }
265 
267  inline const DDRCore::EdgeBases & edgeBases(size_t iE) const
268  {
269  return m_ddr_core.edgeBases(iE);
270  }
271 
273  inline const DDRCore::EdgeBases & edgeBases(const Edge & E) const
274  {
275  return m_ddr_core.edgeBases(E.global_index());
276  }
277 
278  private:
279  TransferOperators _compute_face_transfer_operators(size_t iF);
280  TransferOperators _compute_cell_transfer_operators(size_t iT);
281 
282  const DDRCore & m_ddr_core;
283  const SerendipityProblem & m_ser_pro;
284  const XGrad m_xgrad;
285 
286  // Containers for serendipity, extension and reduction operators
287  std::vector<std::unique_ptr<TransferOperators> > m_face_transfer_operators;
288  std::vector<std::unique_ptr<TransferOperators> > m_cell_transfer_operators;
289 
290  bool m_use_threads;
291  std::ostream & m_output;
292 
293  };
294 
295 } // end of namespace HArDCore3D
296 #endif
Construct all polynomial spaces for the DDR sequence.
Definition: ddrcore.hpp:62
Discrete Serendipity Hgrad space: local operators, L2 product and global interpolator.
Definition: sxgrad.hpp:20
Construct all polynomial spaces for the DDR sequence.
Definition: serendipity_problem.hpp:40
Base class for global DOF spaces.
Definition: variabledofspace.hpp:17
Discrete H1 space: local operators, L2 product and global interpolator.
Definition: xgrad.hpp:18
Class to describe a mesh.
Definition: MeshND.hpp:17
const Eigen::MatrixXd & SgradCell(size_t iT) const
Return the serendipity reconstruction for the cell of index iT.
Definition: sxgrad.hpp:115
const Eigen::MatrixXd & EgradCell(const Cell &T) const
Return the extension for cell T.
Definition: sxgrad.hpp:139
const size_t & degree() const
Return the polynomial degree.
Definition: ddrcore.hpp:140
const Mesh & mesh() const
Return the mesh.
Definition: sxgrad.hpp:49
const Eigen::MatrixXd & EgradFace(const Face &F) const
Return the extension for face F.
Definition: sxgrad.hpp:101
const Eigen::MatrixXd edgePotential(size_t iE) const
Return the potential operator on the edge of index iE.
Definition: sxgrad.hpp:166
const Eigen::MatrixXd & RgradFace(size_t iF) const
Return the reduction for the face of index iF.
Definition: sxgrad.hpp:89
const CellBases & cellBases(size_t iT) const
Return cell bases for element iT.
Definition: ddrcore.hpp:146
const DDRCore::CellBases & cellBases(const Cell &T) const
Return cell bases for cell T.
Definition: sxgrad.hpp:249
const size_t & degree() const
Return the polynomial degree.
Definition: sxgrad.hpp:55
const Eigen::MatrixXd & SgradFace(size_t iF) const
Return the serendipity reconstruction for the face of index iF.
Definition: sxgrad.hpp:77
const Eigen::MatrixXd & EgradCell(size_t iT) const
Return the extension for the cell of index iT.
Definition: sxgrad.hpp:121
const Eigen::MatrixXd facePotential(size_t iF) const
Return the potential operator on the face of index iF.
Definition: sxgrad.hpp:190
TransferOperators(const Eigen::MatrixXd &_serendipity, const Eigen::MatrixXd &_extension, const Eigen::MatrixXd &_reduction)
Definition: sxgrad.hpp:28
const DDRCore::FaceBases & faceBases(const Face &F) const
Return cell bases for face F.
Definition: sxgrad.hpp:261
const Mesh & mesh() const
Return a const reference to the mesh.
Definition: ddrcore.hpp:134
SXGrad(const DDRCore &ddr_core, const SerendipityProblem &ser_pro, bool use_threads=true, std::ostream &output=std::cout)
Constructor.
Definition: sxgrad.cpp:13
Eigen::MatrixXd extension
Definition: sxgrad.hpp:41
const EdgeBases & edgeBases(size_t iE) const
Return edge bases for edge iE.
Definition: ddrcore.hpp:162
const Eigen::MatrixXd cellPotential(size_t iT) const
Return the potential operator on the cell of index iT.
Definition: sxgrad.hpp:214
const Eigen::MatrixXd edgePotential(const Edge &E) const
Return the potential operator on edge E.
Definition: sxgrad.hpp:172
const LocalOperators & edgeOperators(size_t iE) const
Return edge operators for the edge of index iE.
Definition: xgrad.hpp:63
const Eigen::MatrixXd & SgradFace(const Face &F) const
Return the serendipity reconstruction for face F.
Definition: sxgrad.hpp:95
Eigen::MatrixXd potential
Definition: xgrad.hpp:36
Eigen::MatrixXd computeL2Product(const size_t iT, const double &penalty_factor=1., const Eigen::MatrixXd &mass_Pkpo_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: xgrad.cpp:401
const Eigen::MatrixXd edgeGradient(size_t iE) const
Return the full gradient operator on the edge of index iE.
Definition: sxgrad.hpp:154
const Eigen::MatrixXd edgeGradient(const Edge &E) const
Return the full gradient operator on edge E.
Definition: sxgrad.hpp:160
const Eigen::MatrixXd & SgradCell(const Cell &T) const
Return the serendipity reconstruction for cell T.
Definition: sxgrad.hpp:133
const DDRCore::CellBases & cellBases(size_t iT) const
Return cell bases for the face of index iT.
Definition: sxgrad.hpp:243
const Eigen::MatrixXd faceGradient(size_t iF) const
Return the full gradient operator on the face of index iF.
Definition: sxgrad.hpp:178
const Eigen::MatrixXd cellGradient(size_t iT) const
Return the full gradient operator on the cell of index iT.
Definition: sxgrad.hpp:202
const SerendipityProblem & serPro() const
Definition: sxgrad.hpp:60
Eigen::MatrixXd gradient
Definition: xgrad.hpp:35
Eigen::VectorXd interpolate(const FunctionType &q, const int doe_cell=-1, const int doe_face=-1, const int doe_edge=-1) const
Interpolator of a continuous function.
Definition: sxgrad.cpp:65
Eigen::MatrixXd computeL2Product(const size_t iT, const double &penalty_factor=1., const Eigen::MatrixXd &mass_Pk3_T=Eigen::MatrixXd::Zero(1, 1), const IntegralWeight &weight=IntegralWeight(1.)) const
Compute the matrix of the (weighted) L2-product.
Definition: sxgrad.hpp:226
const Eigen::MatrixXd & RgradFace(const Face &F) const
Return cell reduction for cell T.
Definition: sxgrad.hpp:107
const Eigen::MatrixXd faceGradient(const Face &F) const
Return the full gradient operator on face F.
Definition: sxgrad.hpp:184
const Eigen::MatrixXd cellGradient(const Cell &T) const
Return the full gradient operator on cell T.
Definition: sxgrad.hpp:208
Eigen::MatrixXd reduction
Definition: sxgrad.hpp:42
const DDRCore::EdgeBases & edgeBases(size_t iE) const
Return edge bases for the edge of index iE.
Definition: sxgrad.hpp:267
const Eigen::MatrixXd facePotential(const Face &F) const
Return the potential operator on face F.
Definition: sxgrad.hpp:196
const LocalOperators & cellOperators(size_t iT) const
Return cell operators for the cell of index iT.
Definition: xgrad.hpp:87
const Eigen::MatrixXd cellPotential(const Cell &T) const
Return the potential operator on cell T.
Definition: sxgrad.hpp:220
Eigen::MatrixXd serendipity
Definition: sxgrad.hpp:40
std::function< double(const Eigen::Vector3d &)> FunctionType
Definition: sxgrad.hpp:22
const Eigen::MatrixXd & RgradCell(size_t iT) const
Return the reduction for the cell of index iT.
Definition: sxgrad.hpp:127
const Eigen::MatrixXd & RgradCell(const Cell &T) const
Return the reduction for cell T.
Definition: sxgrad.hpp:145
const LocalOperators & faceOperators(size_t iF) const
Return face operators for the face of index iF.
Definition: xgrad.hpp:75
const FaceBases & faceBases(size_t iF) const
Return face bases for face iF.
Definition: ddrcore.hpp:154
const Eigen::MatrixXd & EgradFace(size_t iF) const
Return the extension for the face of index iF.
Definition: sxgrad.hpp:83
const DDRCore::EdgeBases & edgeBases(const Edge &E) const
Return edge bases for edge E.
Definition: sxgrad.hpp:273
const DDRCore::FaceBases & faceBases(size_t iF) const
Return face bases for the face of index iF.
Definition: sxgrad.hpp:255
bool use_threads
Definition: HHO_DiffAdvecReac.hpp:47
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 to store element bases.
Definition: ddrcore.hpp:86
Structure to store edge bases.
Definition: ddrcore.hpp:121
Structure to store face bases.
Definition: ddrcore.hpp:105
Structure for weights (scalar, at the moment) in integral.
Definition: integralweight.hpp:36
A structure to store the serendipity, extension and reduction operators.
Definition: sxgrad.hpp:27