9#ifndef PBAT_FEM_MESHQUADRATURE_H
10#define PBAT_FEM_MESHQUADRATURE_H
19#include <fmt/format.h>
39template <CElement TElement,
int QuadratureOrder,
class TDerivedDetJe>
42 PBAT_PROFILE_NAMED_SCOPE(
"pbat.fem.ToMeshQuadratureWeights");
43 using ScalarType =
typename TDerivedDetJe::Scalar;
44 using QuadratureType =
typename TElement::template QuadratureType<QuadratureOrder, ScalarType>;
45 if (detJeThenWg.rows() != QuadratureType::kPoints)
47 throw std::invalid_argument(
49 "detJeThenWg must have {} rows, but has {}",
50 QuadratureType::kPoints,
54 detJeThenWg.array().colwise() *= wg.array();
74template <CElement TElement,
int QuadratureOrder,
class TDerivedE,
class TDerivedX>
76 Eigen::MatrixBase<TDerivedE>
const& E,
77 Eigen::MatrixBase<TDerivedX>
const& X)
79 typename TDerivedX::Scalar,
80 TElement::template QuadratureType<QuadratureOrder, typename TDerivedX::Scalar>::kPoints,
83 PBAT_PROFILE_NAMED_SCOPE(
"pbat.fem.MeshQuadratureWeights");
84 using ElementType = TElement;
104template <
int QuadratureOrder, CMesh TMesh>
106 typename TMesh::ScalarType,
107 TMesh::ElementType::template QuadratureType<QuadratureOrder, typename TMesh::ScalarType>::
124template <common::CIndex TIndex>
127 using IndexVectorType = Eigen::Vector<TIndex, Eigen::Dynamic>;
128 return IndexVectorType::LinSpaced(nElements, TIndex(0), nElements - 1)
129 .replicate(TIndex(1), nQuadPtsPerElement)
143template <common::CIndex TIndex,
class TDerivedwg>
146 bool const bAreDimensionsCorrect = (wg.size() % nElements) == 0;
147 if (not bAreDimensionsCorrect)
149 throw std::invalid_argument(
151 "nElements must match the number of columns in wg, or wg's flattened size must be "
152 "a multiple of nElements but got {} and {}",
156 auto const nQuadPtsPerElement = wg.size() / nElements;
169template <
class TDerivedE,
class TDerivedwg>
171 Eigen::DenseBase<TDerivedE>
const& E,
172 Eigen::DenseBase<TDerivedwg>
const& wg)
195 using QuadratureType =
typename TElement::template QuadratureType<QuadratureOrder, TScalar>;
197 common::ToEigen(QuadratureType::points).template bottomRows<QuadratureType::kDims>();
198 return Xi.replicate(1, nElements);
210template <
int QuadratureOrder, CMesh TMesh>
213 using ElementType =
typename TMesh::ElementType;
214 using ScalarType =
typename TMesh::ScalarType;
Functions to compute jacobians, their determinants, domain quadrature weights and mapping domain to r...
FEM shape functions and gradients.
Concepts for common types.
Concept for arithmetic types.
Definition Concepts.h:31
Concept for integral types.
Definition Concepts.h:45
auto ToEigen(R &&r) -> Eigen::Map< Eigen::Vector< std::ranges::range_value_t< R >, Eigen::Dynamic > const >
Map a range of scalars to an eigen vector of such scalars.
Definition Eigen.h:28
Finite Element Method (FEM)
Definition Concepts.h:19
auto MeshQuadratureElements(TIndex nElements, TIndex nQuadPtsPerElement)
Computes the element quadrature points indices for each quadrature point, given the number of element...
Definition MeshQuadrature.h:125
auto MeshQuadratureWeights(Eigen::MatrixBase< TDerivedE > const &E, Eigen::MatrixBase< TDerivedX > const &X) -> Eigen::Matrix< typename TDerivedX::Scalar, TElement::template QuadratureType< QuadratureOrder, typename TDerivedX::Scalar >::kPoints, Eigen::Dynamic >
Computes the inner product weights such that .
Definition MeshQuadrature.h:75
auto MeshReferenceQuadraturePoints(TIndex nElements)
Computes the element quadrature points in reference element space.
Definition MeshQuadrature.h:193
auto DeterminantOfJacobian(Eigen::MatrixBase< TDerived > const &J) -> typename TDerived::Scalar
Computes the determinant of a (potentially non-square) Jacobian matrix.
Definition Jacobian.h:68
void ToMeshQuadratureWeights(Eigen::MatrixBase< TDerivedDetJe > &detJeThenWg)
Computes the inner product weights such that .
Definition MeshQuadrature.h:40
std::ptrdiff_t Index
Index type.
Definition Aliases.h:17
double Scalar
Scalar type.
Definition Aliases.h:18