24#ifndef VULPES_FE_FE_VALUES_HPP_
25#define VULPES_FE_FE_VALUES_HPP_
71template <std::
size_t D,
typename I>
73 polynomial::SparsePolynomial<D, I, double, false>> : std::true_type {};
93template <std::
size_t Dim>
100 using FeValuesGrad = Eigen::Matrix<Eigen::Vector<real_t, Dim>, -1, -1>;
121 constexpr std::uint64_t
stamp()
const {
162 template <
typename FloatType,
typename Polynomial>
164 const std::vector<Polynomial>& basis,
166 const int64_t basis_size = basis.size();
167 const int64_t nodes_size =
qrule.nodes.size();
173 for (int64_t i = 0; i < basis_size; ++i) {
174 const auto& basis_func = basis[i];
175 const auto grad = basis_func.gradient();
176 for (int64_t j = 0; j < nodes_size; ++j) {
178 basis_func.evaluate(
qrule.nodes[j].point.data()));
179 for (std::size_t d = 0; d < Dim; ++d) {
181 grad[d].evaluate(
qrule.nodes[j].point.data()));
187 for (int64_t j = 0; j < nodes_size; ++j) {
189 for (std::size_t d = 0; d < Dim; ++d) {
232 template <
typename MappingType>
283 static std::atomic<std::uint64_t> counter{0};
284 return counter.fetch_add(1, std::memory_order_relaxed) + 1;
290 template <
typename FloatType,
typename Polynomial>
292 const std::vector<Polynomial>& basis,
295 Polynomial::dim == Dim,
"basis and FeValues dimensions differ");
297 std::is_same_v<FloatType, double>,
"quadrature nodes must be double");
298 using ExpType = std::decay_t<
decltype(basis[0].data()[0].exp()[0])>;
299 std::size_t n_pow = 1;
300 for (
const auto& poly : basis) {
301 for (
const auto& mono : poly.data()) {
302 for (
const auto e : mono.exp()) {
303 n_pow = std::max<std::size_t>(n_pow,
static_cast<std::size_t
>(e) + 1);
308 const int64_t nodes_size =
qrule.nodes.size();
309 for (int64_t j = 0; j < nodes_size; ++j) {
310 const double* pt =
qrule.nodes[j].point.data();
311 for (std::size_t d = 0; d < Dim; ++d) {
312 for (std::size_t k = 0; k < n_pow; ++k) {
317 for (std::size_t i = 0; i < basis.size(); ++i) {
319 Eigen::Vector<double, Dim>
grad = Eigen::Vector<double, Dim>::Zero();
320 for (
const auto& mono : basis[i].data()) {
321 const auto& e = mono.exp();
322 double term = mono.coef();
323 for (std::size_t d = 0; d < Dim; ++d) {
327 for (std::size_t c = 0; c < Dim; ++c) {
331 double dterm = mono.coef() * e[c];
335 for (std::size_t d = 0; d < Dim; ++d) {
336 dterm *=
m_pow_table[d * n_pow + e[d] - (d == c ? 1 : 0)];
This class works as a cache table for computing efficiently the value of the basis function and its d...
Definition fe_values.hpp:94
Eigen::Vector< real_t, -1 > QuadtratureWeigths
Definition fe_values.hpp:101
index_t m_cell_id
Definition fe_values.hpp:354
Eigen::Matrix< real_t, -1, -1 > FeValuesScalar
Definition fe_values.hpp:99
constexpr std::uint64_t stamp() const
Definition fe_values.hpp:121
index_t getFaceId() const
Definition fe_values.hpp:154
void setFaceNormal(const Eigen::Vector< real_t, Dim > &normal)
Definition fe_values.hpp:138
const auto & neighValues() const
Definition fe_values.hpp:265
FeValuesScalar m_scalar_shapes_ref
Definition fe_values.hpp:358
void resizeTables(int64_t basis_size, int64_t nodes_size)
Definition fe_values.hpp:268
void setCellId(index_t cell_id)
Definition fe_values.hpp:144
constexpr const auto & qpts() const
Definition fe_values.hpp:107
void setFaceId(index_t face_id)
Definition fe_values.hpp:155
std::vector< double > m_pow_table
Definition fe_values.hpp:365
PhysicalQPts m_physical_qpts
Definition fe_values.hpp:350
constexpr const auto & weights() const
Definition fe_values.hpp:105
index_t getCellId() const
Definition fe_values.hpp:143
constexpr auto & qpts()
Definition fe_values.hpp:108
Eigen::Vector< real_t, Dim > m_face_normal
Definition fe_values.hpp:352
std::uint64_t m_stamp
Definition fe_values.hpp:363
void evalOnReferenceFrame(const std::vector< Polynomial > &basis, const qrule::QuadratureRule< FloatType, Dim > &qrule)
Compute and cache the evaluation of the basis on the quadrature points passed as argument....
Definition fe_values.hpp:163
constexpr const auto & qptsRef() const
Definition fe_values.hpp:111
constexpr auto & weightsRef()
Definition fe_values.hpp:110
FeValuesGrad m_grads_shapes
Definition fe_values.hpp:349
PhysicalQPts m_physical_qpts_ref
Definition fe_values.hpp:360
constexpr const auto & getShapeEval() const
Definition fe_values.hpp:103
real_t m_basis_scaling
Definition fe_values.hpp:355
bool m_stamp_enabled
Definition fe_values.hpp:364
void createNeighValues()
Definition fe_values.hpp:260
QuadtratureWeigths m_quadrature_weights_ref
Definition fe_values.hpp:361
constexpr const auto & getGradEval() const
Definition fe_values.hpp:104
Eigen::Matrix< real_t, Dim, -1 > PhysicalQPts
Definition fe_values.hpp:98
constexpr bool hasFaceNeigh() const
Definition fe_values.hpp:141
void saveReferenceFrame(ReferenceTables &tables) const
Copies the reference-frame tables of the last evalOnReferenceFrame.
Definition fe_values.hpp:207
int32_t index_t
Definition fe_values.hpp:97
constexpr auto & qptsRef()
Definition fe_values.hpp:112
constexpr const auto & weightsRef() const
Definition fe_values.hpp:109
void evalSparseBasis(const std::vector< Polynomial > &basis, const qrule::QuadratureRule< FloatType, Dim > &qrule)
Definition fe_values.hpp:291
real_t basisScaling() const
sqrt(det J) of the cell mapping, the factor scaled bases are divided by
Definition fe_values.hpp:149
QuadtratureWeigths m_quadrature_weights
Definition fe_values.hpp:351
bool m_face_has_neigh
Definition fe_values.hpp:353
FeValuesGrad m_grads_shapes_ref
Definition fe_values.hpp:359
const void * m_tabulated_basis
Definition fe_values.hpp:362
FeValuesScalar m_scalar_shapes
Definition fe_values.hpp:348
void setHasFaceNeigh(bool has_neigh)
Definition fe_values.hpp:142
void loadReferenceFrame(const ReferenceTables &tables)
Definition fe_values.hpp:217
std::unique_ptr< FeValues< Dim > > m_fe_values_neigh
Definition fe_values.hpp:367
static std::uint64_t nextStamp()
Definition fe_values.hpp:282
constexpr const void * tabulatedBasis() const
Basis tabulated by the last evalOnReferenceFrame, to compare by address.
Definition fe_values.hpp:114
constexpr auto & weights()
Definition fe_values.hpp:106
auto & neighValues()
Definition fe_values.hpp:264
index_t m_face_id
Definition fe_values.hpp:356
void setStampEnabled(bool enabled)
Definition fe_values.hpp:128
Eigen::Matrix< Eigen::Vector< real_t, Dim >, -1, -1 > FeValuesGrad
Definition fe_values.hpp:100
void setBasisScaling(real_t scaling)
Definition fe_values.hpp:150
double real_t
Definition fe_values.hpp:96
constexpr const Eigen::Vector< real_t, Dim > & getFaceNormal() const
Definition fe_values.hpp:135
void evalAndApplyMapping(const MappingType &mapping, UpdateFlagsType flags)
Update the local cache values on the physical element by passing the mapping and a flag signaling whi...
Definition fe_values.hpp:233
Definition fe_expr_base.hpp:58
Definition dof_policy.hpp:45
const auto normal(const FeSpace &)
Definition fe_expr_func.hpp:92
std::underlying_type_t< UpdateFlags > UpdateFlagsType
Definition fe_values.hpp:65
UpdateFlags
Flags that indicate which parts of FeValues shall be updated on each cell.
Definition fe_values.hpp:51
@ UpdateAll
Definition fe_values.hpp:63
@ UpdateNormals
Definition fe_values.hpp:59
@ UpdateWeights
Definition fe_values.hpp:57
@ UpdateNeighborCell
Definition fe_values.hpp:61
@ UpdateNothing
Definition fe_values.hpp:52
@ UpdateNeighborValues
Definition fe_values.hpp:62
@ UpdateValues
Definition fe_values.hpp:54
@ UpdateGradients
Definition fe_values.hpp:55
@ UpdateMapping
Definition fe_values.hpp:53
@ UpdateHessians
Definition fe_values.hpp:56
@ UpdateQuadraturePts
Definition fe_values.hpp:58
@ UpdateId
Definition fe_values.hpp:60
FeExpressionGradFunc< IndexBegin, IndexEnd, Dim, FeSpace, IsTest > grad(const FeExpressionFunc< IndexBegin, IndexEnd, Dim, FeSpace, IsTest > &w)
Definition fe_expr_basis.hpp:315
Definition monomial.hpp:39
V to(const U &src)
Converts a value of one pseudo-arithmetic type to another.
Definition vmath.hpp:321
constexpr U pow(U base, V exp, U result=U(1))
Computes the power of a number.
Definition vmath.hpp:171
Definition cell_manager.hpp:38
Reference-frame tables written by evalOnReferenceFrame.
Definition fe_values.hpp:198
FeValuesGrad grads
Definition fe_values.hpp:200
QuadtratureWeigths weights
Definition fe_values.hpp:202
FeValuesScalar shapes
Definition fe_values.hpp:199
const void * basis
Definition fe_values.hpp:203
PhysicalQPts qpts
Definition fe_values.hpp:201
True for a double SparsePolynomial with unscaled monomials.
Definition fe_values.hpp:70
Represents a quadrature rule consisting of a set of points and associated weights.
Definition qrule.hpp:69