Back
Components Decomposer
Overview
The Components decomposer breaks down vectors, matrices, and tensors into their individual
scalar components. It uses physics-aware naming conventions for stress/strain tensors and numeric
indexing for generic matrices.
Include
#include <dataframe/attributes/Components.h>
Class Definition
Components API
namespace df::attributes {
class Components : public GenDecomposer<Components> {
public:
Strings names(
const Dataframe& dataframe,
DecompDimension targetDim,
const SerieBase& serie,
const String& name) const override;
Serie<double> serie(
const Dataframe& dataframe,
DecompDimension targetDim,
const std::string& name) const override;
};
}
Naming Conventions
The naming pattern depends on the data type and the decomposition dimension.
Scalar Decomposition
| Type | Generated Names |
|---|---|
Vector2D | {name}x, {name}y |
Vector3D | {name}x, {name}y, {name}z |
Vector4D | {name}x, {name}y, {name}z, {name}w |
Stress2D / Strain2D | {name}xx, {name}xy, {name}yy |
Stress3D / Strain3D | {name}xx, {name}xy, {name}xz, {name}yy, {name}yz, {name}zz |
Matrix2D | {name}11, {name}12, {name}21, {name}22 |
Matrix3D | {name}11, {name}12, ..., {name}33 |
Matrix4D | {name}11, {name}12, ..., {name}44 |
Vector Decomposition
Groups components into vectors: {name}_1, {name}_2, etc.
Matrix Decomposition
Groups components into matrix rows: {name}_11, {name}_12, etc.
Supported Types
| Category | Types |
|---|---|
| Vectors | Vector2D, Vector3D, Vector4D |
| Full Matrices | Matrix2D, Matrix3D, Matrix4D |
| Symmetric Matrices | SMatrix2D, SMatrix3D, SMatrix4D |
| Physics Tensors | Stress2D, Stress3D, Strain2D, Strain3D |
Examples
Decomposing Vectors
using namespace df;
Serie<Vector3D> displacements = {{1,2,3}, {4,5,6}, {7,8,9}};
Dataframe df;
df.add("U", displacements);
attributes::Manager mgr(df);
mgr.addDecomposer(attributes::Components());
// Get scalar names: "Ux", "Uy", "Uz"
auto names = mgr.getNames(attributes::DecompDimension::Scalar);
// Extract individual components
auto ux = mgr.getSerie<double>("Ux"); // {1, 4, 7}
auto uy = mgr.getSerie<double>("Uy"); // {2, 5, 8}
auto uz = mgr.getSerie<double>("Uz"); // {3, 6, 9}
Decomposing Stress Tensors
using namespace df;
// Symmetric 3D stress tensor (6 unique components: xx, xy, xz, yy, yz, zz)
Serie<Stress3D> stresses = {
{100, 20, 10, 80, 15, 60}, // node 0
{110, 25, 12, 85, 18, 65} // node 1
};
Dataframe df;
df.add("S", stresses);
attributes::Manager mgr(df);
mgr.addDecomposer(attributes::Components());
// Get all scalar names
auto names = mgr.getNames(attributes::DecompDimension::Scalar);
// -> "Sxx", "Sxy", "Sxz", "Syy", "Syz", "Szz"
// Extract shear stress component
auto sxy = mgr.getSerie<double>("Sxy"); // {20, 25}
Decomposing Generic Matrices
using namespace df;
Serie<Matrix3D> transforms = {
{1,0,0, 0,1,0, 0,0,1}, // identity
{2,0,0, 0,2,0, 0,0,2} // scale by 2
};
Dataframe df;
df.add("M", transforms);
attributes::Manager mgr(df);
mgr.addDecomposer(attributes::Components());
// Scalar names: "M11", "M12", "M13", "M21", ..., "M33"
auto m11 = mgr.getSerie<double>("M11"); // {1, 2}
auto m12 = mgr.getSerie<double>("M12"); // {0, 0}