25#ifndef VULPES_FE_FE_EXPRESSIONS_FE_EXPR_UNARY_HPP_
26#define VULPES_FE_FE_EXPRESSIONS_FE_EXPR_UNARY_HPP_
38template <std::
size_t Dim,
typename E>
47 template <std::
size_t J = 0, std::
size_t I = 0>
52 std::size_t q)
const {
55 if constexpr (std::is_same_v<TypeEval, void>) {
63 return m_expr.computeUpdateFlags();
72 std::size_t bj)
const {
73 return m_expr.evaluatePoly(fe_values, j, i, bi, bj);
77 const auto& fe_values,
79 std::size_t bj)
const {
80 using MatType = std::decay_t<
decltype(
m_expr.evaluatePolyCoef(
81 mapping, fe_values, bi, bj))>;
82 return MatType{-
m_expr.evaluatePolyCoef(mapping, fe_values, bi, bj)};
86 return m_expr.precompute(fe_values, cells);
90 typename std::conditional_t<E::is_leaf, const E&, const E>
m_expr;
131template <std::
size_t Dim,
typename E>
135 template <
typename T,
typename =
void>
139 template <
typename T>
140 struct FsTypeOf<T, std::void_t<typename T::FeSpaceType>> {
141 using type =
typename T::FeSpaceType;
162 typename = std::void_t<decltype(std::declval<const U&>().feSpace())>>
167 template <std::
size_t J = 0, std::
size_t I = 0>
172 std::size_t q)
const {
186 "fe::field_component requires a test/trial expression (IsLinearTest, "
187 "IsLinearTrial, or IsBilinear). For spatial component extraction "
189 "a coefficient use fe::spatial_component<K>.");
194 return m_expr.computeUpdateFlags();
200 return m_expr.precompute(fe_values, cells);
204 typename std::conditional_t<E::is_leaf, const E&, const E>
m_expr;
238template <std::
size_t K, std::
size_t Dim,
typename E>
242 template <
typename T,
typename =
void>
246 template <
typename T>
247 struct FsTypeOf<T, std::void_t<typename T::FeSpaceType>> {
248 using type =
typename T::FeSpaceType;
268 typename = std::void_t<decltype(std::declval<const U&>().feSpace())>>
273 template <std::
size_t J = 0, std::
size_t I = 0>
278 std::size_t q)
const {
281 if constexpr (std::is_same_v<EvalType, void>) {
289 return m_expr.computeUpdateFlags();
294 return m_expr.precompute(fe_values, cells);
298 std::conditional_t<E::is_leaf, const E&, const E>
m_expr;
312template <std::
size_t K, std::
size_t Dim,
typename E>
331template <std::
size_t Dim,
typename E>
339template <std::
size_t Dim,
typename E>
354 template <std::
size_t J = 0, std::
size_t I = 0>
359 std::size_t q)
const {
360 if constexpr (I == J) {
368 return m_expr.computeUpdateFlags();
377 std::size_t bj)
const {
378 return m_expr.evaluatePoly(fe_values, j, i, bi, bj);
382 const auto& fe_values,
384 std::size_t bj)
const {
385 return m_expr.evaluatePolyCoef(mapping, fe_values, bi, bj);
389 return m_expr.precompute(fe_values, cells);
393 typename std::conditional_t<E::is_leaf, const E&, const E>
m_expr;
396template <std::
size_t Dim,
typename E>
401template <std::
size_t Dim,
typename E>
409 template <std::
size_t J = 0, std::
size_t I = 0>
414 std::size_t q)
const {
416 if constexpr (std::is_same_v<RetType, void>) {
428 std::size_t bj)
const {
429 return m_e.evaluatePoly(fe_values, j, i, bi, bj);
434 const auto& fe_values,
436 std::size_t bj)
const {
438 static const bool warned = [] {
439 pcout <<
"Warning: abs is ignored by the qfree integrators, it is "
440 "applied only at the quadrature points"
445 return m_e.evaluatePolyCoef(mapping, fe_values, bi, bj);
451 return m_e.computeUpdateFlags();
456 return m_e.precompute(fe_values, cells);
460 std::conditional_t<E::is_leaf, const E&, const E>
m_e;
464template <std::
size_t Dim,
typename E>
481template <std::
size_t Dim,
typename E>
486 "fe::cached requires a coefficient expression (no test or trial "
492 using EvalType = std::decay_t<decltype(std::declval<const E&>().evaluate(
496 if constexpr (std::is_arithmetic_v<EvalType>) {
497 return std::type_identity<EvalType>{};
499 return std::type_identity<
500 std::decay_t<decltype(std::declval<EvalType>().eval())>>{};
506 template <std::
size_t J = 0, std::
size_t I = 0>
508 const FeValues<Dim>&, std::size_t, std::size_t, std::size_t q)
const {
513 return m_expr.computeUpdateFlags();
522 std::size_t bj)
const {
523 return m_expr.evaluatePoly(fe_values, j, i, bi, bj);
527 const auto& fe_values,
529 std::size_t bj)
const {
530 return m_expr.evaluatePolyCoef(mapping, fe_values, bi, bj);
534 if (!
m_expr.precompute(fe_values, cells)) {
537 const std::size_t nq = fe_values.
weights().size();
539 for (std::size_t q = 0; q < nq; ++q) {
546 typename std::conditional_t<E::is_leaf, const E&, const E>
m_expr;
554template <std::
size_t Dim,
typename E>
Definition fe_expr_unary.hpp:402
std::conditional_t< E::is_leaf, const E &, const E > m_e
Definition fe_expr_unary.hpp:460
constexpr std::size_t computeOrder() const
Definition fe_expr_unary.hpp:448
static constexpr uint8_t is_bilinear
Definition fe_expr_unary.hpp:405
decltype(auto) evaluatePolyCoef(const auto &mapping, const auto &fe_values, std::size_t bi, std::size_t bj) const
Definition fe_expr_unary.hpp:432
constexpr UpdateFlagsType computeUpdateFlags() const
Definition fe_expr_unary.hpp:450
decltype(auto) evaluatePoly(const FeValues< Dim > &fe_values, std::size_t j, std::size_t i, std::size_t bi, std::size_t bj) const
Definition fe_expr_unary.hpp:423
decltype(auto) evaluate(const FeValues< Dim > &fe_values, std::size_t j, std::size_t i, std::size_t q) const
Definition fe_expr_unary.hpp:410
static constexpr bool is_leaf
Definition fe_expr_unary.hpp:404
constexpr bool precompute(const FeValues< Dim > &fe_values, const CellsType< Dim > &cells) const
Definition fe_expr_unary.hpp:454
FeExpressionAbs(E const &e)
Definition fe_expr_unary.hpp:407
Base class for Finite Element Expressions.
Definition fe_expr_base.hpp:210
Definition fe_expr_unary.hpp:341
static constexpr uint8_t is_bilinear
Definition fe_expr_unary.hpp:344
constexpr UpdateFlagsType computeUpdateFlags() const
Definition fe_expr_unary.hpp:367
static constexpr std::size_t k_index_begin
Definition fe_expr_unary.hpp:347
constexpr FeExpressionDiagOnly(const E &expr)
Definition fe_expr_unary.hpp:350
constexpr bool precompute(const FeValues< Dim > &fe_values, const CellsType< Dim > &cells) const
Definition fe_expr_unary.hpp:387
decltype(auto) evaluatePoly(const FeValues< Dim > &fe_values, std::size_t j, std::size_t i, std::size_t bi, std::size_t bj) const
Definition fe_expr_unary.hpp:372
decltype(auto) evaluate(const FeValues< Dim > &fe_values, std::size_t j, std::size_t i, std::size_t q) const
Definition fe_expr_unary.hpp:355
typename E::FeSpaceType FeSpaceType
Definition fe_expr_unary.hpp:345
std::conditional_t< E::is_leaf, const E &, const E > m_expr
Definition fe_expr_unary.hpp:393
constexpr std::size_t computeOrder() const
Definition fe_expr_unary.hpp:370
static constexpr std::size_t k_index_end
Definition fe_expr_unary.hpp:348
static constexpr bool is_leaf
Definition fe_expr_unary.hpp:343
constexpr const auto & feSpace() const
Definition fe_expr_unary.hpp:352
decltype(auto) evaluatePolyCoef(const auto &mapping, const auto &fe_values, std::size_t bi, std::size_t bj) const
Definition fe_expr_unary.hpp:380
E::PolynomialType PolynomialType
Definition fe_expr_unary.hpp:346
Extract the field (block) component of a multi-component test/trial expression driven by the integrat...
Definition fe_expr_unary.hpp:133
constexpr UpdateFlagsType computeUpdateFlags() const
Definition fe_expr_unary.hpp:193
static constexpr bool is_leaf
Definition fe_expr_unary.hpp:147
static constexpr std::size_t k_index_begin
Definition fe_expr_unary.hpp:152
static constexpr std::size_t k_index_end
Definition fe_expr_unary.hpp:153
std::conditional_t< E::is_leaf, const E &, const E > m_expr
Definition fe_expr_unary.hpp:204
constexpr bool precompute(const FeValues< Dim > &fe_values, const CellsType< Dim > &cells) const
Definition fe_expr_unary.hpp:198
constexpr decltype(auto) feSpace() const
Definition fe_expr_unary.hpp:163
static constexpr uint8_t is_bilinear
Definition fe_expr_unary.hpp:148
typename FsTypeOf< E >::type FeSpaceType
Definition fe_expr_unary.hpp:146
double OutputType
Definition fe_expr_unary.hpp:145
constexpr FeExpressionFieldComponent(const E &expr)
Definition fe_expr_unary.hpp:155
decltype(auto) evaluate(const FeValues< Dim > &fe_values, std::size_t j, std::size_t i, std::size_t q) const
Definition fe_expr_unary.hpp:168
constexpr std::size_t computeOrder() const
Definition fe_expr_unary.hpp:196
Values of a coefficient expression (no test or trial function) stored at the quadrature points by pre...
Definition fe_expr_unary.hpp:483
bool precompute(const FeValues< Dim > &fe_values, const CellsType< Dim > &cells) const
Definition fe_expr_unary.hpp:532
static constexpr bool is_leaf
Definition fe_expr_unary.hpp:490
const OutputType & evaluate(const FeValues< Dim > &, std::size_t, std::size_t, std::size_t q) const
Definition fe_expr_unary.hpp:507
decltype(auto) evaluatePoly(const FeValues< Dim > &fe_values, std::size_t j, std::size_t i, std::size_t bi, std::size_t bj) const
Definition fe_expr_unary.hpp:517
FeExpressionQptsCache(const E &expr)
Definition fe_expr_unary.hpp:504
static constexpr uint8_t is_bilinear
Definition fe_expr_unary.hpp:491
std::vector< OutputType > m_values
Definition fe_expr_unary.hpp:547
constexpr UpdateFlagsType computeUpdateFlags() const
Definition fe_expr_unary.hpp:512
typename decltype([] { if constexpr(std::is_arithmetic_v< EvalType >) { return std::type_identity< EvalType >{}; } else { return std::type_identity< std::decay_t< decltype(std::declval< EvalType >().eval())> >{}; } }())::type OutputType
Definition fe_expr_unary.hpp:495
constexpr std::size_t computeOrder() const
Definition fe_expr_unary.hpp:515
decltype(auto) evaluatePolyCoef(const auto &mapping, const auto &fe_values, std::size_t bi, std::size_t bj) const
Definition fe_expr_unary.hpp:525
std::decay_t< decltype(std::declval< const E & >().evaluate( std::declval< const FeValues< Dim > & >(), 0, 0, 0))> EvalType
Definition fe_expr_unary.hpp:492
std::conditional_t< E::is_leaf, const E &, const E > m_expr
Definition fe_expr_unary.hpp:546
Extract a single scalar spatial component at compile-time index K from a vector-output FE expression.
Definition fe_expr_unary.hpp:240
static constexpr uint8_t is_bilinear
Definition fe_expr_unary.hpp:255
decltype(auto) evaluate(const FeValues< Dim > &fe_values, std::size_t j, std::size_t i, std::size_t q) const
Definition fe_expr_unary.hpp:274
constexpr UpdateFlagsType computeUpdateFlags() const
Definition fe_expr_unary.hpp:288
constexpr std::size_t computeOrder() const
Definition fe_expr_unary.hpp:291
static constexpr bool is_leaf
Definition fe_expr_unary.hpp:254
double OutputType
Definition fe_expr_unary.hpp:252
static constexpr std::size_t k_index_end
Definition fe_expr_unary.hpp:259
std::conditional_t< E::is_leaf, const E &, const E > m_expr
Definition fe_expr_unary.hpp:298
constexpr bool precompute(const FeValues< Dim > &fe_values, const CellsType< Dim > &cells) const
Definition fe_expr_unary.hpp:292
static constexpr std::size_t k_index_begin
Definition fe_expr_unary.hpp:258
constexpr FeExpressionSpatialComponent(const E &expr)
Definition fe_expr_unary.hpp:261
constexpr decltype(auto) feSpace() const
Definition fe_expr_unary.hpp:269
typename FsTypeOf< E >::type FeSpaceType
Definition fe_expr_unary.hpp:253
decltype(auto) evaluate(const FeValues< Dim > &fe_values, std::size_t j, std::size_t i, std::size_t q) const
Definition fe_expr_unary.hpp:48
constexpr std::size_t computeOrder() const
Definition fe_expr_unary.hpp:65
constexpr FeExpressionUnaryMinus(const E &expr)
Definition fe_expr_unary.hpp:45
static constexpr bool is_leaf
Definition fe_expr_unary.hpp:42
decltype(auto) evaluatePoly(const FeValues< Dim > &fe_values, std::size_t j, std::size_t i, std::size_t bi, std::size_t bj) const
Definition fe_expr_unary.hpp:67
std::conditional_t< E::is_leaf, const E &, const E > m_expr
Definition fe_expr_unary.hpp:90
constexpr UpdateFlagsType computeUpdateFlags() const
Definition fe_expr_unary.hpp:62
constexpr bool precompute(const FeValues< Dim > &fe_values, const CellsType< Dim > &cells) const
Definition fe_expr_unary.hpp:84
static constexpr uint8_t is_bilinear
Definition fe_expr_unary.hpp:43
decltype(auto) evaluatePolyCoef(const auto &mapping, const auto &fe_values, std::size_t bi, std::size_t bj) const
Definition fe_expr_unary.hpp:75
This class works as a cache table for computing efficiently the value of the basis function and its d...
Definition fe_values.hpp:94
constexpr const auto & weights() const
Definition fe_values.hpp:105
Definition dof_policy.hpp:45
FeExpressionDiagOnly< Dim, E > ondiag(const E &w)
Definition fe_expr_unary.hpp:397
std::underlying_type_t< UpdateFlags > UpdateFlagsType
Definition fe_values.hpp:65
std::vector< std::unique_ptr< CellType< Dim > > > CellsType
Definition fe_expr_base.hpp:44
FeExpressionSpatialComponent< K, Dim, E > spatial_component(const FeExpressionBase< Dim, E > &e)
Extract the K-th scalar spatial component of a vector-output FE expression at every quadrature point.
Definition fe_expr_unary.hpp:313
FeExpressionFieldComponent< Dim, E > field_component(const FeExpressionBase< Dim, E > &e)
Extract the block field component of a multi-component test/trial expression, driven by the integrati...
Definition fe_expr_unary.hpp:332
FeExpressionAbs< Dim, E > abs(const FeExpressionBase< Dim, E > &e)
Definition fe_expr_unary.hpp:465
@ IsLinearTest
Definition fe_expr_base.hpp:53
@ IsNothing
Definition fe_expr_base.hpp:52
@ IsLinearTrial
Definition fe_expr_base.hpp:54
@ IsBilinear
Definition fe_expr_base.hpp:55
FeExpressionQptsCache< Dim, E > cached(const FeExpressionBase< Dim, E > &e)
Coefficient expression evaluated once per quadrature point (see FeExpressionQptsCache).
Definition fe_expr_unary.hpp:555
Definition cell_manager.hpp:38
vulpes::utils::pcout_t & pcout
Definition pcout.hpp:160
typename T::FeSpaceType type
Definition fe_expr_unary.hpp:141
Definition fe_expr_unary.hpp:136
void type
Definition fe_expr_unary.hpp:137
typename T::FeSpaceType type
Definition fe_expr_unary.hpp:248
Definition fe_expr_unary.hpp:243
void type
Definition fe_expr_unary.hpp:244