58 template<
typename GeometricSupport>
65 return (m >= 0 ? (m + 1) * (m + 2) / 2 : 0);
72 return (m >= 0 ? m + 1 : 0);
85 const Eigen::VectorXd & values,
122 Eigen::VectorXd
restr(
size_t iT)
const;
149 return m_values(index);
153 mutable Eigen::VectorXd m_values;
155 const int m_cell_deg;
156 const size_t m_edge_deg;
187 const Mesh* mesh_ptr,
189 const size_t edge_deg,
191 std::ostream & output = std::cout,
192 const bool ortho =
true
207 inline const size_t EdgeDegree()
const {
return m_edge_deg; };
213 assert( m_cell_basis[iT] );
214 return *m_cell_basis[iT].get();
221 assert( m_edge_basis[iE] );
222 return *m_edge_basis[iE].get();
237 template<
typename ContinuousFunction>
239 const ContinuousFunction& f,
241 const size_t deg_edge,
256 const std::string from_dofs
263 const int m_cell_deg;
264 const size_t m_cell_deg_pos;
266 const int m_edge_deg;
268 const bool m_use_threads;
270 std::ostream & m_output;
275 std::vector<std::unique_ptr<PolyCellBasisType>> m_cell_basis;
276 std::vector<std::unique_ptr<PolyEdgeBasisType>> m_edge_basis;
289 template<
typename ContinuousFunction>
292 size_t cell_deg_pos = std::max(cell_deg, 0);
297 size_t n_total_cell_dofs = m_mesh->
n_cells() * n_cell_dofs;
299 size_t n_total_edge_dofs = m_mesh->
n_edges() * n_edge_dofs;
300 Eigen::VectorXd XTF = Eigen::VectorXd::Zero( n_total_cell_dofs + n_total_edge_dofs );
303 std::function<void(
size_t,
size_t)> construct_all_edge_projections
304 = [&](
size_t start,
size_t end)->
void
306 for (
size_t iE = start; iE <
end; iE++) {
307 Edge E = *m_mesh->
edge(iE);
312 Eigen::VectorXd UF = l2_projection<PolyEdgeBasisType>(f,
EdgeBasis(iE), quadE, phiE_quadE);
315 XTF.segment(n_total_cell_dofs + iE * n_edge_dofs, n_edge_dofs) = UF;
321 std::function<void(
size_t,
size_t)> construct_all_cell_projections
322 = [&](
size_t start,
size_t end)->
void
324 for (
size_t iT = start; iT <
end; iT++) {
325 Cell* cell = m_mesh->
cell(iT);
331 Eigen::MatrixXd MT =
compute_gram_matrix(phiT_quadT, phiT_quadT, quadT, n_cell_dofs, n_cell_dofs,
"sym");
334 Eigen::VectorXd bT = Eigen::VectorXd::Zero(n_cell_dofs);
335 for (
size_t i = 0;
i < n_cell_dofs;
i++) {
336 for (
size_t iqn = 0; iqn < quadT.size(); iqn++){
337 bT(
i) += quadT[iqn].w * phiT_quadT[
i][iqn] * f(quadT[iqn].vector());
342 Eigen::VectorXd UT = MT.ldlt().solve(bT);
345 size_t offset_T = iT * n_cell_dofs;
346 XTF.segment(offset_T, n_cell_dofs) = UT;
350 size_t nedges = cell->n_edges();
356 for (
size_t ilE = 0; ilE < nedges; ilE++){
357 VectorRd xE = cell->edge(ilE)->center_mass();
358 size_t iE = cell->edge(ilE)->global_index();
360 barycoefT(ilE) *= phiE_cst / phiT_cst;
364 for (
size_t ilE = 0; ilE < nedges; ilE++) {
365 size_t iE = cell->edge(ilE)->global_index();
366 XTF(iT) += barycoefT(ilE) * XTF(n_total_cell_dofs + iE);
Definition hybridcore.hpp:179
Definition hybridcore.hpp:82
Compute max and min eigenvalues of all matrices for i
Definition compute_eigs.m:5
end
Definition compute_eigs.m:12
FunctionValue function(size_t i, const VectorRd &x) const
Evaluate the i-th function at point x.
Definition basis.hpp:351
Eigen::Vector2d VectorRd
Definition basis.hpp:55
Eigen::MatrixXd compute_gram_matrix(const boost::multi_array< VectorRd, 2 > &B1, const boost::multi_array< double, 2 > &B2, const QuadratureRule &qr)
Compute the Gram-like matrix given a family of vector-valued and one of scalar-valued functions by te...
Definition basis.cpp:225
static boost::multi_array< typename detail::basis_evaluation_traits< BasisType, BasisFunction >::ReturnValue, 2 > compute(const BasisType &basis, const QuadratureRule &quad)
Generic basis evaluation.
Definition basis.hpp:2288
static void parallel_for(unsigned nb_elements, std::function< void(size_t start, size_t end)> functor, bool use_threads=true, unsigned nb_threads_max=1e9)
Generic function to execute threaded processes.
Definition parallel_for.hpp:42
bool use_threads
Definition HHO_DiffAdvecReac.hpp:47
Eigen::VectorXd compute_weights(size_t iT) const
Computes the weights to get cell values from edge values when l=-1.
Definition hybridcore.cpp:138
Eigen::VectorXd VertexValues(const UVector Xh, const std::string from_dofs)
From a hybrid function, computes a vector of values at the vertices of the mesh.
Definition hybridcore.cpp:288
Eigen::VectorXd restr(size_t iT) const
Extract the restriction of the unknowns corresponding to cell iT and its edges.
Definition hybridcore.cpp:29
const size_t get_edge_deg() const
Return the edge degree.
Definition hybridcore.hpp:102
const int CellDegreePos() const
Definition hybridcore.hpp:205
const size_t DimPoly< Cell >(const int m)
Compute the size of the basis of 2-variate polynomials up to degree m.
Definition hybridcore.hpp:63
const size_t n_total_cell_dofs() const
Total number of cell dofs (in the vector, this is where the edge dofs start)
Definition hybridcore.hpp:117
const int CellDegree() const
Return the degree of cell polynomials.
Definition hybridcore.hpp:204
UVector operator+(const UVector &b)
Overloads the addition: adds the coefficients.
Definition hybridcore.hpp:125
const int get_cell_deg() const
Return the cell degree.
Definition hybridcore.hpp:97
void operator+=(const UVector &b)
Overloads the increment: adds the coefficients.
Definition hybridcore.hpp:137
const size_t EdgeDegree() const
Return the degree of edge polynomials.
Definition hybridcore.hpp:207
UVector operator-(const UVector &b)
Overloads the subtraction: subtracts the coefficients.
Definition hybridcore.hpp:131
Family< MonomialScalarBasisCell > PolyCellBasisType
type for cell basis
Definition hybridcore.hpp:196
const PolyEdgeBasisType & EdgeBasis(size_t iE) const
Return edge basis for edge with global index iE.
Definition hybridcore.hpp:218
Family< MonomialScalarBasisEdge > PolyEdgeBasisType
type for edge basis
Definition hybridcore.hpp:197
const size_t n_cell_dofs() const
Number of dofs in each cell.
Definition hybridcore.hpp:107
UVector interpolate(const ContinuousFunction &f, const int deg_cell, const size_t deg_edge, size_t doe) const
Compute the interpolant in the discrete space of a continuous function.
Definition hybridcore.hpp:290
Eigen::VectorXd & asVectorXd() const
Return the values as an Eigen vector.
Definition hybridcore.hpp:92
double evaluate_in_cell(const UVector Xh, size_t iT, VectorRd x) const
Evaluates a discrete function in the cell iT at point x.
Definition hybridcore.cpp:261
void operator/=(const double &r)
Overloads the increment: adds the coefficients.
Definition hybridcore.hpp:143
double L2norm(const UVector &Xh) const
Compute L2 norm of a discrete function (using cell values)
Definition hybridcore.cpp:164
double evaluate_in_edge(const UVector Xh, size_t iE, VectorRd x) const
Evaluates a discrete function on the edge iE at point x.
Definition hybridcore.cpp:272
size_t const DimPoly(int m)
double H1norm(const UVector &Xh) const
Compute discrete H1 norm of a discrete function.
Definition hybridcore.cpp:190
const size_t n_edge_dofs() const
Number of dofs on each edge.
Definition hybridcore.hpp:112
const Mesh * get_mesh() const
Returns a pointer to the mesh.
Definition hybridcore.hpp:201
const PolyCellBasisType & CellBasis(size_t iT) const
Return cell basis for element with global index iT.
Definition hybridcore.hpp:210
const size_t DimPoly< Edge >(const int m)
Compute the size of the basis of 1-variate polynomials up to degree m.
Definition hybridcore.hpp:70
double operator()(size_t index) const
Overloads the (): returns the corresponding coefficient.
Definition hybridcore.hpp:148
Cell * cell(std::size_t index) const
get a constant pointer to a cell using its global index
Definition Mesh2D.hpp:178
Edge * edge(std::size_t index) const
get a constant pointer to a edge using its global index
Definition Mesh2D.hpp:168
std::size_t n_cells() const
number of cells in the mesh.
Definition Mesh2D.hpp:63
std::size_t n_edges() const
number of edges in the mesh.
Definition Mesh2D.hpp:61
std::vector< QuadratureNode > QuadratureRule
Definition quadraturerule.hpp:55
QuadratureRule generate_quadrature_rule(const Cell &T, const int doe, const bool force_split)
Generate quadrature rule on mesh element.
Definition quadraturerule.cpp:10
Definition ddr-klplate.hpp:27