HArD::Core3D
Hybrid Arbitrary Degree::Core 3D - Library to implement 3D schemes with vertex, edge, face and cell polynomials as unknowns
laxgrad.hpp
Go to the documentation of this file.
1 #ifndef LAXGRAD_HPP
2 #define LAXGRAD_HPP
3 
4 #include <globaldofspace.hpp>
5 #include <xgrad.hpp>
6 #include <liealgebra.hpp>
7 
8 namespace HArDCore3D
9 {
16 
17  class LAXGrad : public GlobalDOFSpace
18  {
19  public:
20 
21  typedef std::function<double(const Eigen::Vector3d &)> FunctionType;
22  typedef std::vector<FunctionType> LAFunctionType;
23 
26  {
28  const Eigen::MatrixXd & _gradient,
29  const Eigen::MatrixXd & _potential
30  )
31  : gradient(_gradient),
32  potential(_potential)
33  {
34  // Do nothing
35  }
36 
37  Eigen::MatrixXd gradient;
38  Eigen::MatrixXd potential;
39  };
40 
42  LAXGrad(const LieAlgebra & lie_algebra, const XGrad & xgrad, bool use_threads = true, std::ostream & output = std::cout);
43 
45  const Mesh & mesh() const
46  {
47  return m_xgrad.mesh();
48  }
49 
51  const size_t & degree() const
52  {
53  return m_xgrad.degree();
54  }
55 
57  Eigen::VectorXd interpolate(
58  const LAFunctionType & q,
59  const int doe_cell = -1,
60  const int doe_face = -1,
61  const int doe_edge = -1
62  ) const;
63 
65  inline const LocalOperators & edgeOperators(size_t iE) const
66  {
67  return *m_edge_operators[iE];
68  }
69 
71  inline const LocalOperators & edgeOperators(const Edge & E) const
72  {
73  return *m_edge_operators[E.global_index()];
74  }
75 
77  inline const LocalOperators & faceOperators(size_t iF) const
78  {
79  return *m_face_operators[iF];
80  }
81 
83  inline const LocalOperators & faceOperators(const Face & F) const
84  {
85  return *m_face_operators[F.global_index()];
86  }
87 
89  inline const LocalOperators & cellOperators(size_t iT) const
90  {
91  return *m_cell_operators[iT];
92  }
93 
95  inline const LocalOperators & cellOperators(const Cell & T) const
96  {
97  return *m_cell_operators[T.global_index()];
98  }
99 
101  inline const DDRCore::CellBases & cellBases(size_t iT) const
102  {
103  return m_xgrad.cellBases(iT);
104  }
105 
107  inline const DDRCore::CellBases & cellBases(const Cell & T) const
108  {
109  return m_xgrad.cellBases(T.global_index());
110  }
111 
113  inline const DDRCore::FaceBases & faceBases(size_t iF) const
114  {
115  return m_xgrad.faceBases(iF);
116  }
117 
119  inline const DDRCore::FaceBases & faceBases(const Face & F) const
120  {
121  return m_xgrad.faceBases(F.global_index());
122  }
123 
125  inline const DDRCore::EdgeBases & edgeBases(size_t iE) const
126  {
127  return m_xgrad.edgeBases(iE);
128  }
129 
131  inline const DDRCore::EdgeBases & edgeBases(const Edge & E) const
132  {
133  return m_xgrad.edgeBases(E.global_index());
134  }
135 
137  // The mass matrix of P^{k+1}(T) is the most expensive mass matrix in the calculation of this norm, which
138  // is why there's the option of passing it as parameter if it's been already pre-computed when the norm is called.
139  Eigen::MatrixXd computeL2Product(
140  const size_t iT,
141  const double & penalty_factor = 1.,
142  const Eigen::MatrixXd & mass_Pkpo_T = Eigen::MatrixXd::Zero(1,1),
143  const IntegralWeight & weight = IntegralWeight(1.)
144  ) const;
145 
146  private:
147  LocalOperators _compute_edge_gradient_potential(size_t iE);
148  LocalOperators _compute_face_gradient_potential(size_t iF);
149  LocalOperators _compute_cell_gradient_potential(size_t iT);
150 
151  const LieAlgebra & m_lie_algebra;
152  const XGrad & m_xgrad;
153  bool m_use_threads;
154  std::ostream & m_output;
155 
156  // Containers for local operators
157  std::vector<std::unique_ptr<LocalOperators> > m_edge_operators;
158  std::vector<std::unique_ptr<LocalOperators> > m_face_operators;
159  std::vector<std::unique_ptr<LocalOperators> > m_cell_operators;
160  };
161 
162 } // end of namespace HArDCore3D
163 
164 #endif
Base class for global DOF spaces. Provides functions to manipulate global DOFs (the local version bei...
Definition: globaldofspace.hpp:16
Discrete Lie algebra valued H1 space: local operators, L2 product and global interpolator.
Definition: laxgrad.hpp:18
Lie algebra class: mass matrix, structure constants and Lie bracket.
Definition: liealgebra.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 size_t & degree() const
Return the polynomial degree.
Definition: xgrad.hpp:49
const Mesh & mesh() const
Return the mesh.
Definition: xgrad.hpp:43
const DDRCore::EdgeBases & edgeBases(size_t iE) const
Return edge bases for the edge of index iE.
Definition: xgrad.hpp:123
const DDRCore::FaceBases & faceBases(size_t iF) const
Return face bases for the face of index iF.
Definition: xgrad.hpp:111
const DDRCore::CellBases & cellBases(size_t iT) const
Return cell bases for the cell of index iT.
Definition: xgrad.hpp:99
bool use_threads
Definition: HHO_DiffAdvecReac.hpp:47
const DDRCore::FaceBases & faceBases(size_t iF) const
Return face bases for the face of index iF.
Definition: laxgrad.hpp:113
const LocalOperators & faceOperators(const Face &F) const
Return face operators for face F.
Definition: laxgrad.hpp:83
std::function< double(const Eigen::Vector3d &)> FunctionType
Definition: laxgrad.hpp:21
const LocalOperators & faceOperators(size_t iF) const
Return face operators for the face of index iF.
Definition: laxgrad.hpp:77
const DDRCore::EdgeBases & edgeBases(size_t iE) const
Return edge bases for the edge of index iE.
Definition: laxgrad.hpp:125
const LocalOperators & cellOperators(size_t iT) const
Return cell operators for the cell of index iT.
Definition: laxgrad.hpp:89
LAXGrad(const LieAlgebra &lie_algebra, const XGrad &xgrad, bool use_threads=true, std::ostream &output=std::cout)
Constructor.
Definition: laxgrad.cpp:11
const DDRCore::CellBases & cellBases(size_t iT) const
Return cell bases for the cell of index iT.
Definition: laxgrad.hpp:101
const size_t & degree() const
Return the polynomial degree.
Definition: laxgrad.hpp:51
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: laxgrad.cpp:135
Eigen::MatrixXd potential
Definition: laxgrad.hpp:38
const DDRCore::FaceBases & faceBases(const Face &F) const
Return cell bases for face F.
Definition: laxgrad.hpp:119
Eigen::MatrixXd gradient
Definition: laxgrad.hpp:37
const DDRCore::EdgeBases & edgeBases(const Edge &E) const
Return edge bases for edge E.
Definition: laxgrad.hpp:131
const Mesh & mesh() const
Return the mesh.
Definition: laxgrad.hpp:45
const LocalOperators & cellOperators(const Cell &T) const
Return cell operators for cell T.
Definition: laxgrad.hpp:95
const LocalOperators & edgeOperators(size_t iE) const
Return edge operators for the edge of index iE.
Definition: laxgrad.hpp:65
LocalOperators(const Eigen::MatrixXd &_gradient, const Eigen::MatrixXd &_potential)
Definition: laxgrad.hpp:27
const LocalOperators & edgeOperators(const Edge &E) const
Return edge operators for edge E.
Definition: laxgrad.hpp:71
std::vector< FunctionType > LAFunctionType
Definition: laxgrad.hpp:22
const DDRCore::CellBases & cellBases(const Cell &T) const
Return cell bases for cell T.
Definition: laxgrad.hpp:107
Eigen::VectorXd interpolate(const LAFunctionType &q, const int doe_cell=-1, const int doe_face=-1, const int doe_edge=-1) const
Interpolator of a continuous function.
Definition: laxgrad.cpp:76
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 local operators (gradient and potential)
Definition: laxgrad.hpp:26