18 #ifndef INTEGRAL_HPP_INCLUDED
19 #define INTEGRAL_HPP_INCLUDED
46 template<
size_t dimension,
size_t d>
requires(d > 0 && d <= dimension)
50 Integral(
const Mesh<dimension>* mesh ) : _mesh(mesh) {;}
53 QuadratureRule<d> generate_quad(
size_t i_cell ,
int dqr )
const
55 return generate_quadrature_rule(_mesh->template get_cell_map<d>(i_cell),dqr);
61 Eigen::MatrixXd evaluate_scalar_quad(
size_t i_cell ,
63 QuadratureRule<d>
const & quad )
const;
67 Eigen::MatrixXd evaluate_scalar_quad_tr(
size_t i_cell ,
70 QuadratureRule<d-1>
const & quad )
const requires(d > 1);
74 Eigen::VectorXd evaluate_volume_form(
size_t i_cell ,QuadratureRule<d>
const & quad )
const;
82 evaluate_exterior_quad(
size_t i_cell ,
83 QuadratureRule<d>
const & quad )
const;
91 evaluate_exterior_quad_tr(
size_t i_cell ,
93 QuadratureRule<d-1>
const & quad )
const requires(d > 1);
102 evaluate_exterior_quad_star_tr(
size_t i_cell ,
103 size_t bd_rel_index ,
104 QuadratureRule<d-1>
const & quad )
const requires(d > 1);
107 const Mesh<dimension>* mesh()
const {
return _mesh;}
109 const Mesh<dimension>* _mesh;
116 template<
size_t dimension,
size_t d>
requires(d > 0 && d <= dimension)
117 Eigen::MatrixXd Integral<dimension,d>::evaluate_scalar_quad(
120 QuadratureRule<d>
const & quad)
const
122 auto const & F = _mesh->template get_cell_map<d>(i_cell);
123 const size_t nbp = quad.size();
126 for (
size_t iqr = 0; iqr < nbp; ++iqr) {
127 auto const x = quad[iqr].vector;
129 rv(iqr,i_b) = F.evaluate_poly_on_ref(x,i_b,r);
135 template<
size_t dimension,
size_t d>
requires(d > 0 && d <= dimension)
136 Eigen::MatrixXd Integral<dimension,d>::evaluate_scalar_quad_tr(
140 QuadratureRule<d-1>
const & quad)
const requires(d > 1)
142 auto const & T = _mesh->template get_cell_map<d>(i_cell);
143 auto const & F = _mesh->template get_cell_map<d-1>(_mesh->get_boundary(d-1,d,i_cell)[bd_rel_index]);
144 size_t bd_map = _mesh->get_relative_map(d-1,d,i_cell)[bd_rel_index];
146 const size_t nbp = quad.size();
149 for (
size_t iqr = 0; iqr < nbp; ++iqr) {
150 auto const Ix = F.evaluate_I(bd_map,quad[iqr].vector);
152 rv(iqr,i_b) = T.evaluate_poly_pullback(0,Ix,i_b,r);
159 template<
size_t dimension,
size_t d>
requires(d > 0 && d <= dimension)
160 Eigen::VectorXd Integral<dimension,d>::evaluate_volume_form(
size_t i_cell,QuadratureRule<d>
const & quad)
const
162 auto const & F = _mesh->template get_cell_map<d>(i_cell);
163 const size_t nbp = quad.size();
164 Eigen::VectorXd rv(nbp);
166 for (
size_t iqr = 0; iqr < nbp; ++iqr) {
167 auto const x = quad[iqr].vector;
168 auto const DI = F.evaluate_DI(0,x);
169 if constexpr(d == dimension) {
170 rv(iqr) = _mesh->volume_form(_mesh->get_map_ids(d,i_cell)[0],F.evaluate_I(0,x))*DI.determinant();
172 rv(iqr) = std::sqrt((DI.transpose()*_mesh->metric(_mesh->get_map_ids(d,i_cell)[0],F.evaluate_I(0,x))*DI).determinant());
178 template<
size_t dimension,
size_t d>
requires(d > 0 && d <= dimension)
180 std::vector<Eigen::Matrix<double,
Dimension::ExtDim(l,d),
Dimension::ExtDim(l,d)>> Integral<dimension,d>::evaluate_exterior_quad(
size_t i_cell,QuadratureRule<d>
const & quad)
const
182 auto const & F = _mesh->template get_cell_map<d>(i_cell);
183 const size_t nbp = quad.size();
187 for (
size_t iqr = 0; iqr < nbp; ++iqr) {
188 auto const x = quad[iqr].vector;
189 auto const Ix = F.evaluate_I(0,x);
191 if constexpr(dimension == d) {
192 auto const Jp = F.template evaluate_DJ_p<l>(0,Ix);
195 auto const DI = F.evaluate_DI(0,x);
196 Eigen::Matrix<double,d,d> invIpG = (DI.transpose()*_mesh->metric(_mesh->get_map_ids(d,i_cell)[0],Ix)*DI).inverse();
204 template<
size_t dimension,
size_t d>
requires(d > 0 && d <= dimension)
206 std::vector<Eigen::Matrix<double,
Dimension::ExtDim(l,d-1),
Dimension::ExtDim(l,d)>> Integral<dimension,d>::evaluate_exterior_quad_tr(
size_t i_cell,
size_t bd_rel_index, QuadratureRule<d-1>
const & quad)
const requires(d > 1)
208 auto const & T = _mesh->template get_cell_map<d>(i_cell);
209 auto const & F = _mesh->template get_cell_map<d-1>(_mesh->get_boundary(d-1,d,i_cell)[bd_rel_index]);
210 size_t bd_map = _mesh->get_relative_map(d-1,d,i_cell)[bd_rel_index];
212 const size_t nbp = quad.size();
216 for (
size_t iqr = 0; iqr < nbp; ++iqr) {
217 auto const x = quad[iqr].vector;
218 auto const Ix = F.evaluate_I(bd_map,x);
219 auto const DIF = F.evaluate_DI(bd_map,x);
220 auto const IpF = F.template evaluate_DI_p<l>(bd_map,x);
221 auto const JpT = T.template evaluate_DJ_p<l>(0,Ix);
222 Eigen::Matrix<double,d-1,d-1> invIpG = (DIF.transpose()*_mesh->metric(_mesh->get_map_ids(d,i_cell)[0],Ix)*DIF).inverse();
229 template<
size_t dimension,
size_t d>
requires(d > 0 && d <= dimension)
231 std::vector<Eigen::Matrix<double,
Dimension::ExtDim(l,d-1),
Dimension::ExtDim(l,d)>> Integral<dimension,d>::evaluate_exterior_quad_star_tr(
size_t i_cell,
size_t bd_rel_index, QuadratureRule<d-1>
const & quad)
const requires(d > 1)
233 auto const & T = _mesh->template get_cell_map<d>(i_cell);
234 auto const & F = _mesh->template get_cell_map<d-1>(_mesh->get_boundary(d-1,d,i_cell)[bd_rel_index]);
235 size_t bd_map = _mesh->get_relative_map(d-1,d,i_cell)[bd_rel_index];
237 const size_t nbp = quad.size();
241 for (
size_t iqr = 0; iqr < nbp; ++iqr) {
242 auto const x = quad[iqr].vector;
243 auto const Ix = F.evaluate_I(bd_map,x);
244 auto const JIx = T.evaluate_J(0,Ix);
245 auto const DIF = F.evaluate_DI(bd_map,x);
246 Eigen::Matrix<double,d-1,d-1> invIpG = (DIF.transpose()*_mesh->metric(_mesh->get_map_ids(d,i_cell)[0],Ix)*DIF).inverse();
247 auto const IpF = F.template evaluate_DI_p<l>(bd_map,x);
248 auto const JpT = T.template evaluate_DJ_p<l>(0,Ix);
250 starR = _mesh->template getHodge<d-l,d>(i_cell,JIx)*(((l*(d-l))%2)? -1. : 1.);
252 starL = _mesh->template getHodge<l,d-1>(_mesh->get_boundary(d-1,d,i_cell)[bd_rel_index],x);
constexpr size_t ExtDim(size_t l, size_t d)
Dimension of the exterior algebra .
Definition: exterior_dimension.hpp:37
constexpr size_t PolyDim(int r, size_t d)
Dimension of .
Definition: exterior_dimension.hpp:43
requires(d > 0 &&d<=dimension) struct dCell_mass
Compute the mass matrices of a d-cell.
Definition: dcell_integral.hpp:17
Compute and store the topological and geometrical data of the mesh.
Definition: maxwell.hpp:21
Wrapper to provide an uniform interface to every quadrature rule.
static Eigen::Matrix< double, Dimension::ExtDim(l, Eigen::internal::traits< Derived >::RowsAtCompileTime), Dimension::ExtDim(l, Eigen::internal::traits< Derived >::RowsAtCompileTime)> compute(Eigen::MatrixBase< Derived > const &g)
Definition: exterior_algebra.hpp:287