Skip to content

Commit 02236ff

Browse files
committed
Document LoadVector
1 parent 1432612 commit 02236ff

File tree

3 files changed

+52
-22
lines changed

3 files changed

+52
-22
lines changed

source/pbat/fem/Gradient.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ namespace fem {
4949
* \f]
5050
*
5151
* where \f$ g \f$ is the number of evaluation points.
52+
*
53+
* @note Link to my higher-level FEM crash course doc.
5254
*
5355
* @tparam TMesh
5456
*/

source/pbat/fem/LaplacianMatrix.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace fem {
3030
* The precise definition of the Laplacian matrix's symmetric part is given by
3131
* \f$ \mathbf{L}_{ij} = \int_\Omega -\nabla \phi_i \cdot \nabla \phi_j d\Omega \f$.
3232
*
33-
* * @todo Explain the Laplacian matrix and its construction and link to my higher-level FEM crash
33+
* @todo Explain the Laplacian matrix and its construction and link to my higher-level FEM crash
3434
* course doc.
3535
*
3636
* This matrix-free Laplacian requires the following inputs:

source/pbat/fem/LoadVector.h

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/**
2+
* @file LoadVector.h
3+
* @author Quoc-Minh Ton-That ([email protected])
4+
* @brief LoadVector API and implementation.
5+
* @date 2025-02-11
6+
*
7+
* @copyright Copyright (c) 2025
8+
*
9+
*/
10+
111
#ifndef PBAT_FEM_LOAD_VECTOR_H
212
#define PBAT_FEM_LOAD_VECTOR_H
313

@@ -14,24 +24,38 @@
1424
namespace pbat {
1525
namespace fem {
1626

27+
/**
28+
* @brief A matrix-free representation of a finite element load vector \f$ \mathbf{f}_i =
29+
* \int_\Omega \mathbf{f}(X) \phi_i(X) \f$ under Galerkin projection.
30+
*
31+
* \note Assumes \f$ \mathbf{f}(X) \f$ is piecewise constant over the elements.
32+
*
33+
* \todo Link to my higher-level FEM crash course doc.
34+
*
35+
* @tparam TMesh Type satisfying concept CMesh
36+
* @tparam QuadratureOrder Quadrature order for integrating the load vector
37+
*/
1738
template <CMesh TMesh, int QuadratureOrder>
1839
struct LoadVector
1940
{
2041
public:
21-
using SelfType = LoadVector<TMesh, QuadratureOrder>;
22-
using MeshType = TMesh;
23-
using ElementType = typename TMesh::ElementType;
24-
using QuadratureRuleType = typename ElementType::template QuadratureType<QuadratureOrder>;
25-
static int constexpr kOrder = ElementType::kOrder;
26-
static int constexpr kQuadratureOrder = QuadratureOrder;
42+
using SelfType = LoadVector<TMesh, QuadratureOrder>; ///< Self type
43+
using MeshType = TMesh; ///< Mesh type
44+
using ElementType = typename TMesh::ElementType; ///< Element type
45+
using QuadratureRuleType =
46+
typename ElementType::template QuadratureType<QuadratureOrder>; ///< Quadrature rule type
47+
static int constexpr kOrder = ElementType::kOrder; ///< Polynomial order of the load vector
48+
static int constexpr kQuadratureOrder = QuadratureOrder; ///< Quadrature order
2749

2850
/**
29-
* @brief
30-
* @tparam TDerived
31-
* @param mesh
32-
* @param detJe |#quad.pts.|x|#elements| affine element jacobian determinants at quadrature
51+
* @brief Construct a new LoadVector object
52+
* @tparam TDerived Eigen dense expression type
53+
* @param mesh Finite element mesh
54+
* @param detJe `|# quad.pts.|x|# elements|` affine element jacobian determinants at quadrature
3355
* points
34-
* @param fe |dims|x|#elements| piecewise element constant load, or |dims|x1 constant load
56+
* @param fe `|dims|x|# elements|` piecewise element constant load, or `|dims|x1` constant load
57+
* @param dims Dimensionality of image of FEM function space
58+
* @pre `dims >= 1` and `fe.cols() == 1 || fe.cols() == mesh.E.cols()` and `fe.rows() == dims`
3559
*/
3660
template <class TDerived>
3761
LoadVector(
@@ -43,29 +67,33 @@ struct LoadVector
4367
SelfType& operator=(SelfType const&) = delete;
4468

4569
/**
46-
* @brief Transforms this matrix-free mass matrix representation into sparse compressed format.
47-
* @return
70+
* @brief Transforms this element-wise load vector representation into a global load vector.
71+
* @return VectorX Global load vector
4872
*/
4973
VectorX ToVector() const;
5074

5175
/**
52-
* @brief
53-
* @tparam TDerived
54-
* @param fe |dims|x|#elements| piecewise element constant load, or |dims|x1 constant load
76+
* @brief Set the external loading
77+
* @tparam TDerived Eigen dense expression type
78+
* @param fe `|dims|x|# elements|` piecewise element constant load, or `|dims|x1` constant load
5579
*/
5680
template <class TDerived>
5781
void SetLoad(Eigen::DenseBase<TDerived> const& fe);
5882

83+
/**
84+
* @brief Check if the state of this load vector is valid
85+
*/
5986
void CheckValidState() const;
6087

6188
MeshType const& mesh; ///< The finite element mesh
62-
MatrixX fe; ///< |dims|x|#elements| piecewise element constant load
63-
MatrixX N; ///< |ElementType::kNodes|x|#elements| integrated element shape functions. To
64-
///< obtain the element force vectors, compute Neint \kron I_{dims} * f
65-
Eigen::Ref<MatrixX const> detJe; ///< |# element quadrature points|x|#elements| matrix of
89+
MatrixX fe; ///< `|dims|x|# elements|` piecewise element constant load
90+
MatrixX N; ///< `|ElementType::kNodes|x|# elements|` integrated element shape functions. See
91+
///< (IntegratedShapeFunctions()).
92+
Eigen::Ref<MatrixX const> detJe; ///< `|# element quadrature points|x|# elements|` matrix of
6693
///< jacobian determinants at element quadrature points
6794
int dims; ///< Dimensionality of image of FEM function space, i.e. this load vector is
68-
///< actually f \kronecker 1_{dims \times dims}. Should be >= 1.
95+
///< actually \f$ \mathbf{f} \kronecker 1_{dims \times dims} \f$. Should have `dims >=
96+
///< 1`.
6997
};
7098

7199
template <CMesh TMesh, int QuadratureOrder>

0 commit comments

Comments
 (0)