![]() |
Vulpes
0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
|
Integrator that simplexifies cells and integrates weak forms on them. More...
#include <integrator_simplexify.hpp>
Classes | |
| struct | CellCache |
Public Types | |
| using | index_t = typename MeshType::index_t |
| Index type taken from the MeshType. | |
| using | WeakFormIntegratorBaseType |
| Base class alias. | |
| using | FeType = WeakFormIntegratorBaseType::FeType |
| Finite element type alias (from base). | |
| using | CellType = geometry::Cell<dim, double, index_t> |
| Cell type alias with compile-time dimension. | |
| using | MappingType = std::decay_t<decltype(FeType::getMapping(CellType{}))> |
| Mapping type deduced from the FE type's getMapping. | |
| using | FeExpressionTupleBilinear |
| using | FeExpressionTupleLinear |
| using | FeExpressionTupleFaceBilinear |
| using | FeExpressionTupleFaceLinear |
Public Member Functions | |
| WeakFormIntegratorSimplexify (const MeshType &mesh, CellManager< MeshType, FeType > &cell_manager, const FeExpressionTuple &fe_expression, const FeExpressionFaceTuple &fe_expression_face=FeExpressionFaceTuple{}) | |
| Construct the simplexifying integrator. | |
| void | integrate (index_t cell_id) override |
| Perform integration for a single cell. | |
| void | setCellCache (bool enable) |
| void | computeUpdateFlags () |
| Compute the update flags indicating the values to be updated for each cell in the FEValues. | |
| void | computeMaxOrder () |
| Compute the maximum polynomial order among all finite element expressions. | |
| const CellType & | getCell (index_t cell_id, bool update_mapping=false) |
| Get the cell object for a given cell id. | |
| void | preallocate (index_t cell_id) |
| Resize the internal storage of local integrals (matrices) to fit the number of finite element expressions taking into account which expressions are computed on the faces and which in the volume, and which expressions are bilinear or linear. | |
| void | findCellNeigh () |
| Find the neighboring cell across the current (local) face (m_face_id) and set up the ids for the neighbor FEValues if needed. | |
| void | applyBasisScaling () |
| Apply the basis scaling to the integrals and right-hand side contributions if needed. | |
| Eigen::Map< Eigen::MatrixXd > | getCurrFaceIntegral (const auto &expr, Eigen::Index expr_id) |
| Get a map to the data corresponding to the face integral for the current cell and face being integrated. The data is a raw buffer that points to the correct location in the internal storage. | |
| Eigen::Map< Eigen::VectorXd > | getCurrFaceRhs (const auto &expr, Eigen::Index expr_id) |
| Get a map to the rhs vector for the current face and expression. | |
| void | buildWeakFormPointerTable () |
| Build a lookup table that maps finite element expression pointers to their corresponding data storage locations for integrals and right-hand side contributions. | |
| const auto & | getIntegrals () const |
| Get a const reference to the (bilinear) volume integrals buffer. | |
| const auto & | getRhsIntegrals () const |
| Get a const reference to the (linear) volume right-hand side buffer. | |
| const auto & | getFaceIntegrals () const |
| Get a const reference to the (bilinear) face integrals buffer where both basis functions belong to this cell. | |
| const auto & | getRhsFaceIntegrals () const |
| Get a const reference to the (linear) face right-hand side buffer. | |
| const auto & | getFaceIntegralsNeigh () const |
| Get a const reference to the (bilinear) face integrals buffer where one basis function belongs to the neighboring cell. | |
| const auto & | getRhsFaceIntegralsNeigh () const |
| Get a const reference to the (linear) face rhs buffer where the test function belongs to the neighboring cell. | |
| auto | getIntegral (auto wf_ptr, index_t loc_neigh_id=-1) const |
| Get the integral (matrix or vector) for the current cell. | |
Static Public Attributes | |
| static constexpr std::size_t | dim = MeshType::self_dim |
| Spatial dimension of the mesh (compile-time). | |
| static constexpr index_t | s_n_expr |
| Number of expressions (compile-time constants forwarded from base). | |
| static constexpr index_t | s_n_face_expr |
| static constexpr index_t | s_n_expr_bilinear |
| static constexpr index_t | s_n_expr_linear |
| static constexpr index_t | s_n_face_expr_bilinear |
| static constexpr index_t | s_n_face_expr_linear |
| static constexpr index_t | s_n_blocks |
| static constexpr uint32_t | nblocks |
| Number of vector blocks in the system, e.g. for a scalar problem is 1, for an elasticity problem is dim (2 or 3). | |
Protected Types | |
| using | CellNeighInfo |
Protected Member Functions | |
| template<typename QRule> | |
| void | evalReferenceFrame (fe::FeValues< dim > &fe_values, const QRule &qrule) |
| template<typename SimplexMatrixType, typename VertexMatrixType> | |
| void | mapQuadraturePointsToSimplex (const SimplexMatrixType &simplexes, const VertexMatrixType &vertexes, int32_t k) |
| Map quadrature nodes from the reference simplex to physical simplex k. | |
| void | integrateVolumeCell () |
| Integrate the volume (cell interior) over the currently mapped simplex. | |
| template<typename FaceSubsimplexMatrix, typename SimplexPtsMatrix> | |
| void | updateQptsAndMappingForThisAndNeigh (const FaceSubsimplexMatrix &face_subsimplexes, const SimplexPtsMatrix &simplexification_pts, index_t k) |
| Update boundary quadrature points & mappings for the current face subsimplex. | |
| void | integrateSurfaceSubcell () |
| Integrate the boundary contribution on the currently mapped face subsimplex. | |
Protected Attributes | |
| bool | m_cell_cache_enabled = false |
| std::vector< CellCache > | m_cell_cache |
| CellCache * | m_curr_cache = nullptr |
| std::size_t | m_table_slot = 0 |
| std::shared_ptr< qrule::QuadratureRule< double, dim > > | m_qrule_d_ref = nullptr |
| Shared pointer to the (volume) quadrature rule reference (cached). | |
| qrule::QuadratureRule< double, dim > | m_qrule_d |
| Quadrature rule object for volume integrals (mutable, per-simplex). | |
| std::shared_ptr< qrule::QuadratureRule< double, dim - 1 > > | m_qrule_bndry_d_ref |
| Shared pointer to the boundary quadrature rule (reference). | |
| qrule::QuadratureRule< double, dim > | m_qrule_bndry_d |
| Quadrature rule object used for face/sub-simplex integration. | |
| const MeshType & | m_mesh |
| A reference to the underlying mesh. | |
| CellManager< MeshType, FeType > & | m_cell_manager |
| The cell manager. | |
| FeExpressionTuple | m_fe_expression |
| A tuple of pointers to the finite element expressions to compute the volume integrals. | |
| std::tuple<> | m_fe_expression_face |
| A tuple of pointers to the finite element expressions to compute the face integrals. | |
| const FeType & | m_fe_space |
| A reference to the finite element space. | |
| std::size_t | m_order |
| The maximum polynomial order of the finite element expressions integrated in the volume. | |
| std::size_t | m_order_face |
| The maximum polynomial order of the finite element expressions integrated on the faces. | |
| std::unordered_map< void *, double * > | m_wf_ptr_table |
| A map from finite element expression pointers to their corresponding data storage locations. | |
| std::unordered_map< void *, Eigen::MatrixXd > | m_neigh_sum_scratch |
| Scratch buffers reused by getIntegral to accumulate the sum-over-neighbors case without a fresh heap allocation per call, keyed per weak-form pointer so two different neigh-summed forms queried on the same integrator cannot alias each other's result. | |
| fe::UpdateFlagsType | m_update_flags |
| Update flags indicating which values to update in FEValues for the volume integrals. | |
| fe::UpdateFlagsType | m_update_flags_face |
| Update flags indicating which values to update in FEValues for the face integrals. | |
| Eigen::Tensor< double, 3 > | m_integrals |
| Tensor to store the bilinear volume integrals. | |
| Eigen::MatrixXd | m_rhs |
| Matrix to store the linear volume right-hand side contributions. | |
| Eigen::Tensor< double, 3 > | m_face_integrals |
| Tensor to store the bilinear face integrals where both basis functions belong to this cell. | |
| Eigen::MatrixXd | m_face_rhs |
| Matrix to store the linear face right-hand side contributions. | |
| Eigen::Tensor< double, 4 > | m_face_integrals_neigh |
| Tensor to store the bilinear face integrals where one basis function belongs to the neighboring cell. | |
| Eigen::Tensor< double, 3 > | m_face_rhs_neigh |
| Tensor to store the linear face rhs contributions where the test function belongs to the neighboring cell; shape (nrows, s_n_face_expr, n_max_neigh) – dim1 uses s_n_face_expr (total) so getIntegral's slice_neigh_size = nrows * 1 * s_n_face_expr matches the tensor stride. | |
| fe::FeValues< dim > | m_fe_values |
| The FEValues object to cache ids, normals and the evaluation of shape functions and their derivatives. | |
| bool | m_need_neigh_cell |
| Flags indicating whether neighboring cell information is needed. | |
| bool | m_need_neigh_values |
| Flags indicating whether neighboring cell values are needed, a subset of the above, so if this is true the above is true too. | |
| index_t | m_cell_id |
| Current cell id being integrated, in mesh MPI local enumeration. | |
| index_t | m_face_id |
| Current face id being integrated, local to the cell. | |
| CellNeighInfo | m_cell_neigh_info |
| Information about the neighboring cell across the current face it might be empty if the neighbor is not needed or does not exist. | |
| const MappingType * | m_mapping |
| Pointer to the mapping of the current cell being integrated. | |
Integrator that simplexifies cells and integrates weak forms on them.
The WeakFormIntegratorSimplexify class extends WeakFormIntegratorBase and provides an integration algorithm that:
The strategy avoids requiring the mesh cells themselves to be simplexes by working on the simplex subdivision explicitly. Boundary integrals are handled similarly by subdividing faces into lower-dimensional simplexes (edges in 2D, triangles in 3D).
The integrator therefore:
| MeshType | mesh type providing index_t, self_dim, cells, etc. |
| FeExpressionTuple | tuple of expressions for volume integrals. |
| FeExpressionFaceTuple | tuple of expressions for face integrals. |
|
protectedinherited |
| using vulpes::assemble::WeakFormIntegratorSimplexify< MeshType, FeExpressionTuple, FeExpressionFaceTuple >::CellType = geometry::Cell<dim, double, index_t> |
Cell type alias with compile-time dimension.
|
inherited |
|
inherited |
|
inherited |
|
inherited |
| using vulpes::assemble::WeakFormIntegratorSimplexify< MeshType, FeExpressionTuple, FeExpressionFaceTuple >::FeType = WeakFormIntegratorBaseType::FeType |
Finite element type alias (from base).
| using vulpes::assemble::WeakFormIntegratorSimplexify< MeshType, FeExpressionTuple, FeExpressionFaceTuple >::index_t = typename MeshType::index_t |
Index type taken from the MeshType.
| using vulpes::assemble::WeakFormIntegratorSimplexify< MeshType, FeExpressionTuple, FeExpressionFaceTuple >::MappingType = std::decay_t<decltype(FeType::getMapping(CellType{}))> |
Mapping type deduced from the FE type's getMapping.
| using vulpes::assemble::WeakFormIntegratorSimplexify< MeshType, FeExpressionTuple, FeExpressionFaceTuple >::WeakFormIntegratorBaseType |
Base class alias.
| vulpes::assemble::WeakFormIntegratorSimplexify< MeshType, FeExpressionTuple, FeExpressionFaceTuple >::WeakFormIntegratorSimplexify | ( | const MeshType & | mesh, |
| CellManager< MeshType, FeType > & | cell_manager, | ||
| const FeExpressionTuple & | fe_expression, | ||
| const FeExpressionFaceTuple & | fe_expression_face = FeExpressionFaceTuple{} ) |
Construct the simplexifying integrator.
Caches quadrature rules (volume and boundary) for the requested orders.
| mesh | Mesh (const ref) used by the base integrator. |
| cell_manager | CellManager instance managing cell mappings. |
| fe_expression | Tuple of FE expressions for volume integrals. |
| fe_expression_face | Tuple of FE expressions for face integrals (optional). |
|
inlineinherited |
Apply the basis scaling to the integrals and right-hand side contributions if needed.
This method checks if the finite element type requires basis scaling. If so, it computes the scaling factors based on the Jacobian determinant of the mapping and applies them to the stored integrals and right-hand side contributions.
|
inlineinherited |
Build a lookup table that maps finite element expression pointers to their corresponding data storage locations for integrals and right-hand side contributions.
This method populates an unordered map that associates each finite element expression pointer with a pointer to its corresponding data storage location in the internal tensors and matrices. It ensures that each expression is uniquely mapped and checks for duplicates, reporting an error if the same expression is used more than once.
|
inlineinherited |
Compute the maximum polynomial order among all finite element expressions.
|
inlineinherited |
Compute the update flags indicating the values to be updated for each cell in the FEValues.
|
inlineprotected |
|
inlineinherited |
Find the neighboring cell across the current (local) face (m_face_id) and set up the ids for the neighbor FEValues if needed.
|
inlineinherited |
Get the cell object for a given cell id.
| cell_id | Cell id of the considered cell in mesh (local MPI) enumeration |
| update_mapping | If true, update the internal mapping pointer to the mapping of the current cell |
|
inlineinherited |
Get a map to the data corresponding to the face integral for the current cell and face being integrated. The data is a raw buffer that points to the correct location in the internal storage.
This method returns an Eigen::Map to the face integral matrix for the current cell and face being integrated. It takes into account whether the finite element expression requires neighbor values and whether a neighbor cell exists.
| expr | Pointer to the finite element expression for which to get the face integral. |
| expr_id | Index of the finite element expression in the tuple. |
|
inlineinherited |
Get a map to the rhs vector for the current face and expression.
Returns a writable Eigen::Map into the correct per-neighbor slot of m_face_rhs_neigh (when the expression uses fe::neigh values) or into the flat m_face_rhs column (otherwise). Returns a null map (size 0) when a neighbor is required but absent, or when precompute() rejects this face.
| expr | Pointer to the linear face expression. |
| expr_id | Index of this expression in the linear face tuple. |
|
inlineinherited |
Get a const reference to the (bilinear) face integrals buffer where both basis functions belong to this cell.
|
inlineinherited |
Get a const reference to the (bilinear) face integrals buffer where one basis function belongs to the neighboring cell.
|
inlineinherited |
Get the integral (matrix or vector) for the current cell.
| wf_ptr | Pointer to the finite element expression. |
| loc_neigh_id | Local neighbor index (>= 0) to retrieve a single per-neighbor slice. Pass the default (-1) to obtain the sum over all neighbors for neigh-test forms, or the flat result for non-neigh forms. |
|
inlineinherited |
Get a const reference to the (bilinear) volume integrals buffer.
|
inlineinherited |
Get a const reference to the (linear) face right-hand side buffer.
|
inlineinherited |
Get a const reference to the (linear) face rhs buffer where the test function belongs to the neighboring cell.
|
inlineinherited |
Get a const reference to the (linear) volume right-hand side buffer.
|
overridevirtual |
Perform integration for a single cell.
This method:
| cell_id | local id of the cell to integrate. |
Implements vulpes::assemble::WeakFormIntegratorBase< MeshType, FeExpressionTuple, std::tuple<> >.
|
protected |
Integrate the boundary contribution on the currently mapped face subsimplex.
Uses m_fe_values on the face-sub-simplex mapping to evaluate expressions and to accumulate face bilinear contributions into local face integrals and linear contributions into m_face_rhs.
|
protected |
Integrate the volume (cell interior) over the currently mapped simplex.
This method:
The method relies on this->m_fe_values to hold the FE basis evaluations and mapping information for the current simplex mapping.
|
protected |
Map quadrature nodes from the reference simplex to physical simplex k.
Computes the affine transformation for simplex k using the provided vertexes and simplexes index array and writes mapped points & rescaled weights into m_qrule_d.
| SimplexMatrixType | matrix-like container type for simplex indices (rows = dim+1). |
| VertexMatrixType | matrix-like container type for vertex coordinates (cols = npoints). |
| simplexes | column-major container with simplex vertex indices (dim+1 x nSimplexes). |
| vertexes | coordinates of points (dim x nPoints). |
| k | index of the simplex to map. |
|
inlineinherited |
Resize the internal storage of local integrals (matrices) to fit the number of finite element expressions taking into account which expressions are computed on the faces and which in the volume, and which expressions are bilinear or linear.
|
inline |
Keeps, per local cell, the simplexification and the reference-frame tables of its quadrature (sub)simplexes, so that integrating a cell again skips their computation. Memory grows with the cells integrated. Tables that do not match the current basis or quadrature size are rebuilt, but a moved or changed mesh is not detected: call again to drop the cache.
|
protected |
Update boundary quadrature points & mappings for the current face subsimplex.
Builds the transformation from reference (sub)simplex to the physical subsimplex and updates m_qrule_bndry_d, m_fe_values, and - if needed - neighbour evaluations (m_fe_values.neighValues()).
It also applies the Nanson rule to convert reference face measures into physical measures and rescales quadrature weights accordingly.
| FaceSubsimplexMatrix | matrix-like type holding subsimplex vertex indices. |
| SimplexPtsMatrix | matrix-like type holding simplexification points. |
| face_subsimplexes | matrix whose columns define subsimplexes on the face. |
| simplexification_pts | point list used to define subsimplex coordinates. |
| k | index of the subsimplex for the face. |
|
inlinestaticconstexpr |
Spatial dimension of the mesh (compile-time).
|
protected |
|
protected |
|
protectedinherited |
Current cell id being integrated, in mesh MPI local enumeration.
|
protectedinherited |
The cell manager.
|
protectedinherited |
Information about the neighboring cell across the current face it might be empty if the neighbor is not needed or does not exist.
|
protected |
|
protectedinherited |
Current face id being integrated, local to the cell.
|
protectedinherited |
Tensor to store the bilinear face integrals where both basis functions belong to this cell.
|
protectedinherited |
Tensor to store the bilinear face integrals where one basis function belongs to the neighboring cell.
|
protectedinherited |
Matrix to store the linear face right-hand side contributions.
|
protectedinherited |
Tensor to store the linear face rhs contributions where the test function belongs to the neighboring cell; shape (nrows, s_n_face_expr, n_max_neigh) – dim1 uses s_n_face_expr (total) so getIntegral's slice_neigh_size = nrows * 1 * s_n_face_expr matches the tensor stride.
|
protectedinherited |
A tuple of pointers to the finite element expressions to compute the volume integrals.
|
protectedinherited |
A tuple of pointers to the finite element expressions to compute the face integrals.
|
protectedinherited |
A reference to the finite element space.
|
protectedinherited |
The FEValues object to cache ids, normals and the evaluation of shape functions and their derivatives.
|
protectedinherited |
Tensor to store the bilinear volume integrals.
|
protectedinherited |
Pointer to the mapping of the current cell being integrated.
|
protectedinherited |
A reference to the underlying mesh.
|
protectedinherited |
Flags indicating whether neighboring cell information is needed.
|
protectedinherited |
Flags indicating whether neighboring cell values are needed, a subset of the above, so if this is true the above is true too.
|
mutableprotectedinherited |
Scratch buffers reused by getIntegral to accumulate the sum-over-neighbors case without a fresh heap allocation per call, keyed per weak-form pointer so two different neigh-summed forms queried on the same integrator cannot alias each other's result.
|
protectedinherited |
The maximum polynomial order of the finite element expressions integrated in the volume.
|
protectedinherited |
The maximum polynomial order of the finite element expressions integrated on the faces.
|
protected |
Quadrature rule object used for face/sub-simplex integration.
Although declared as qrule::QuadratureRule<double, dim> for uniform storage semantics, it is populated with (dim-1)-dimensional mapped points.
|
protected |
Shared pointer to the boundary quadrature rule (reference).
This points to the reference rule on a (dim-1)-simplex used to integrate faces.
|
protected |
Quadrature rule object for volume integrals (mutable, per-simplex).
This stores the mapped nodes & weights for the currently active simplex.
|
protected |
Shared pointer to the (volume) quadrature rule reference (cached).
Points reflect the quadrature nodes on the reference simplex; weights are scaled for each simplex when mapping.
|
protectedinherited |
Matrix to store the linear volume right-hand side contributions.
|
protected |
|
protectedinherited |
Update flags indicating which values to update in FEValues for the volume integrals.
|
protectedinherited |
Update flags indicating which values to update in FEValues for the face integrals.
|
protectedinherited |
A map from finite element expression pointers to their corresponding data storage locations.
|
inlinestaticconstexprinherited |
Number of vector blocks in the system, e.g. for a scalar problem is 1, for an elasticity problem is dim (2 or 3).
|
inlinestaticconstexpr |
Number of blocks used by the FE space (used for assembling block matrices).
|
inlinestaticconstexpr |
Number of expressions (compile-time constants forwarded from base).
|
inlinestaticconstexpr |
|
inlinestaticconstexpr |
|
inlinestaticconstexpr |
|
inlinestaticconstexpr |
|
inlinestaticconstexpr |