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
+
1
11
#ifndef PBAT_FEM_LOAD_VECTOR_H
2
12
#define PBAT_FEM_LOAD_VECTOR_H
3
13
14
24
namespace pbat {
15
25
namespace fem {
16
26
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
+ */
17
38
template <CMesh TMesh, int QuadratureOrder>
18
39
struct LoadVector
19
40
{
20
41
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
27
49
28
50
/* *
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
33
55
* 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`
35
59
*/
36
60
template <class TDerived >
37
61
LoadVector (
@@ -43,29 +67,33 @@ struct LoadVector
43
67
SelfType& operator =(SelfType const &) = delete ;
44
68
45
69
/* *
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
48
72
*/
49
73
VectorX ToVector () const ;
50
74
51
75
/* *
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
55
79
*/
56
80
template <class TDerived >
57
81
void SetLoad (Eigen::DenseBase<TDerived> const & fe);
58
82
83
+ /* *
84
+ * @brief Check if the state of this load vector is valid
85
+ */
59
86
void CheckValidState () const ;
60
87
61
88
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
66
93
// /< jacobian determinants at element quadrature points
67
94
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`.
69
97
};
70
98
71
99
template <CMesh TMesh, int QuadratureOrder>
0 commit comments