SuperDex Physics C++ API
Loading...
Searching...
No Matches
material_params.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19// PLEASE DO NOT ADD OTHER INCLUDES HERE. This header is included in the mochi_physics public API.
32
33namespace superdex {
34
35// Public API alias.
37
38/** @brief Default material density [kg/m³]. */
39inline constexpr real kDefaultDensity = 1000_r;
40
41/**
42 * @brief Material parameters for soft body simulation.
43 *
44 * @details Contains the material type discriminant, one instance of each supported material model's
45 * parameters, and shared properties (density). The @ref type field selects which material model's
46 * parameters are active.
47 *
48 * @note Mochi uses the International System of Units (SI) by default. Other units can be used, but
49 * require overwriting all dimensional default parameters (material, contact, constraints, solver,
50 * etc.) to ensure consistency.
51 *
52 * @see SoftMaterialType
53 */
55 /** @brief Material constitutive model. */
57
58 /** @brief Parameters for the Neo-Hookean material model. */
60
61 /** @brief Parameters for the St. Venant-Kirchhoff material model. */
63
64 /** @brief Parameters for the Linear Elastic material model. */
66
67 /** @brief Parameters for the Active Neo-Hookean material model. */
69
70 /** @brief Parameters for the Active Shape Targeting ARAP material model. */
72
73 /** @brief Parameters for the ARAP material model. */
75
76 /** @brief Material density in the undeformed configuration [kg/m³]. Must be positive. */
78
79 /**
80 * @brief Mass damping coefficient [1/s]. Applies a velocity-proportional force `α·M·v`.
81 *
82 * @details Must be non-negative. Active only when the actor has inertia. A nonzero value with no
83 * inertia is valid but inactive (logged as a warning at actor initialization).
84 */
86
87 /**
88 * @brief Stiffness damping coefficient `β` [s]. Adds a strain-rate-proportional viscous stress.
89 *
90 * @details Must be non-negative. Active only when the actor has stress. A nonzero value with no
91 * stress is valid but inactive (logged as a warning at actor initialization).
92 *
93 * @details This is a total-Lagrangian variant of Kelvin–Voigt damping: it adds a viscous second
94 * Piola–Kirchhoff stress
95 * @code
96 * S_visc = β · C₀ : Ė
97 * @endcode
98 * where `Ė` is the material time derivative of the Green–Lagrange strain, and `C₀ = ∂²Ψ/∂E²` is
99 * the Lagrangian material stiffness evaluated at zero deformation.
100 *
101 * @note While the parameterization in terms of a timescale β is similar, this differs from
102 * standard Rayleigh damping using the global assembled stiffness matrix; it depends only on
103 * strain rate, therefore dissipating energy only during deformation.
104 */
106
107 /**
108 * @brief [Experimental] Include the geometric term in the stiffness-damping
109 * tangent. Defaults to `false`.
110 *
111 * @details Only affects the Jacobian for Newton iteration, not the energy, residual, or converged
112 * solution. When `false` (default), the viscous tangent uses a cheaper quasi-Newton
113 * approximation. When `true`, the Newton Jacobian includes a geometric term, which is
114 * proportional to the per-stage strain increment and may improve nonlinear solver convergence
115 * in certain scenarios.
116 *
117 * @warning This is an experimental feature. It may be changed or removed in the future. Use at
118 * your own risk.
119 */
121
122#if MOCHI_LANGUAGE_CPP20
123 bool operator==(SoftMaterialParams const&) const = default;
124#endif
125
126 // clang-format off
129 MOCHI_FIELD(neoHookean) MOCHI_ATTRIBUTE(PreviouslyKnownAs("stableNeoHookean"));
132 MOCHI_FIELD(activeNeoHookean) MOCHI_ATTRIBUTE(PreviouslyKnownAs("activeStableNeoHookean"));
135 MOCHI_FIELD(density) MOCHI_ATTRIBUTE(Units("kg/m^3"))
140 // clang-format on
141};
142
143// Forward
145
146/**
147 * @brief Per-element material parameters for a soft body in struct-of-arrays format.
148 *
149 * @see SoftMaterialParams, PerElementSoftMaterialDataView
150 */
153
154 /**
155 * @brief Copy from @ref PerElementSoftMaterialDataView.
156 *
157 * @param[in] other Source data.
158 */
160
161 /** @brief Material constitutive model. */
163
164 /** @brief Strategy for ensuring positive semi-definite Hessian matrices. */
166 DynamicArray<real> youngsModulus; ///< Young's modulus [Pa]. 1 per element.
167 DynamicArray<real> poissonRatio; ///< Poisson's ratio (dimensionless). 1 per element.
168 DynamicArray<real> anisoAlpha; ///< Anisotropic stiffness (α) [Pa]. 1 per element.
169 DynamicArray<real> anisoLength; ///< Anisotropic reference length (dimensionless). 1 per element.
170 DynamicArray<real> anisoTheta; ///< Fiber azimuthal angle (θ) [rad]. 1 per element.
171 DynamicArray<real> anisoPhi; ///< Fiber elevation angle (φ) [rad]. 1 per element.
172 DynamicArray<real> arapStiffness; ///< ARAP stiffness (μ) [Pa]. 1 per element.
173 /// Shape target tensor offset in flat symmetric upper-triangle layout. 6 values per element.
174 /// Defines S_t = I + [[s0, s1, s2], [s1, s3, s4], [s2, s4, s5]].
176
177 /**
178 * @brief Number of elements described by this per-element material field.
179 *
180 * @details Derived from the per-element array appropriate to @ref type "type": @ref
181 * arapStiffness for the ARAP-family materials (@ref SoftMaterialType::Arap and @ref
182 * SoftMaterialType::ActiveShapeTargetingArap), and @ref poissonRatio for the Lame-based
183 * materials.
184 *
185 * @return Number of elements.
186 */
187 [[nodiscard]] int GetNumElements() const;
188
189#if MOCHI_LANGUAGE_CPP20
190 bool operator==(PerElementSoftMaterialData const& other) const = default;
191 bool operator!=(PerElementSoftMaterialData const& other) const = default;
192#endif
193
202 MOCHI_FIELD(anisoPhi) MOCHI_ATTRIBUTE(Units("rad"));
206};
207
208/**
209 * @brief Non-owning view of per-element material parameters for a soft body, in struct-of-arrays
210 * format.
211 *
212 * @see SoftMaterialParams, PerElementSoftMaterialData
213 */
216
217 /**
218 * @brief Implicit conversion from @ref PerElementSoftMaterialData.
219 *
220 * @param[in] other Source data.
221 */
223
224 /** @brief Material constitutive model. */
226
227 /** @brief Strategy for ensuring positive semi-definite Hessian matrices. */
229 Span<real const> youngsModulus; ///< Young's modulus [Pa]. 1 per element.
230 Span<real const> poissonRatio; ///< Poisson's ratio (dimensionless). 1 per element.
231 Span<real const> anisoAlpha; ///< Anisotropic stiffness (α) [Pa]. 1 per element.
232 Span<real const> anisoLength; ///< Anisotropic reference length (dimensionless). 1 per element.
233 Span<real const> anisoTheta; ///< Fiber azimuthal angle (θ) [rad]. 1 per element.
234 Span<real const> anisoPhi; ///< Fiber elevation angle (φ) [rad]. 1 per element.
235 Span<real const> arapStiffness; ///< ARAP stiffness (μ) [Pa]. 1 per element.
236 /// Shape target tensor offset in flat symmetric upper-triangle layout. 6 values per element.
237 /// Defines S_t = I + [[s0, s1, s2], [s1, s3, s4], [s2, s4, s5]].
239
240#if MOCHI_LANGUAGE_CPP20
241 bool operator==(PerElementSoftMaterialDataView const& other) const = default;
242 bool operator!=(PerElementSoftMaterialDataView const& other) const = default;
243#endif
244};
245
246} // namespace superdex
247
248#include "material_params_inl.h"
A dynamically resizable array with syntax and behavior similar to std::pmr::vector.
SmithNeoHookeanMaterialParams NeoHookeanMaterialParams
SoftMaterialType
Material constitutive models for soft bodies.
@ NeoHookean
Neo-Hookean hyperelastic material.
MaterialPsdStrategy
Strategy for ensuring positive semi-definite (PSD) Hessian matrices in material models.
@ MaterialDefault
Use the material's default PSD strategy.
constexpr real kDefaultDensity
Default material density [kg/m³].
#define MOCHI_STRUCT_END()
Definition reflection.h:279
#define MOCHI_FIELD(name)
Definition reflection.h:293
#define MOCHI_STRUCT_BEGIN(name)
Definition reflection.h:278
#define MOCHI_ATTRIBUTE(...)
Definition reflection.h:298
Parameters for the Active Neo-Hookean composite material model.
Parameters for the Active Shape Targeting ARAP material model.
Parameters for the As-Rigid-As-Possible (ARAP) material model.
Definition arap_params.h:39
Parameters for the Linear Elastic (Hookean) material model.
Non-owning view of per-element material parameters for a soft body, in struct-of-arrays format.
Span< real const > arapStiffness
ARAP stiffness (μ) [Pa].
Span< real const > anisoLength
Anisotropic reference length (dimensionless). 1 per element.
Span< real const > youngsModulus
Young's modulus [Pa]. 1 per element.
SoftMaterialType type
Material constitutive model.
MaterialPsdStrategy psdStrategy
Strategy for ensuring positive semi-definite Hessian matrices.
bool operator!=(PerElementSoftMaterialDataView const &other) const =default
Span< real const > anisoTheta
Fiber azimuthal angle (θ) [rad]. 1 per element.
Span< real const > poissonRatio
Poisson's ratio (dimensionless). 1 per element.
Span< real const > anisoPhi
Fiber elevation angle (φ) [rad]. 1 per element.
bool operator==(PerElementSoftMaterialDataView const &other) const =default
Span< real const > anisoAlpha
Anisotropic stiffness (α) [Pa]. 1 per element.
Span< real const > shapeTargetTensor
Shape target tensor offset in flat symmetric upper-triangle layout.
Per-element material parameters for a soft body in struct-of-arrays format.
bool operator!=(PerElementSoftMaterialData const &other) const =default
DynamicArray< real > youngsModulus
Young's modulus [Pa]. 1 per element.
MaterialPsdStrategy psdStrategy
Strategy for ensuring positive semi-definite Hessian matrices.
DynamicArray< real > anisoPhi
Fiber elevation angle (φ) [rad]. 1 per element.
DynamicArray< real > anisoLength
Anisotropic reference length (dimensionless). 1 per element.
DynamicArray< real > anisoTheta
Fiber azimuthal angle (θ) [rad]. 1 per element.
DynamicArray< real > arapStiffness
ARAP stiffness (μ) [Pa].
SoftMaterialType type
Material constitutive model.
DynamicArray< real > anisoAlpha
Anisotropic stiffness (α) [Pa]. 1 per element.
int GetNumElements() const
Number of elements described by this per-element material field.
DynamicArray< real > shapeTargetTensor
Shape target tensor offset in flat symmetric upper-triangle layout.
DynamicArray< real > poissonRatio
Poisson's ratio (dimensionless). 1 per element.
bool operator==(PerElementSoftMaterialData const &other) const =default
Parameters for the stable Neo-Hookean hyperelastic material model by Smith et al.
Material parameters for soft body simulation.
ActiveShapeTargetingArapMaterialParams activeShapeTargetingArap
Parameters for the Active Shape Targeting ARAP material model.
ActiveNeoHookeanMaterialParams activeNeoHookean
Parameters for the Active Neo-Hookean material model.
real stiffnessDampingCoefficient
Stiffness damping coefficient β [s].
real density
Material density in the undeformed configuration [kg/m³].
bool operator==(SoftMaterialParams const &) const =default
SoftMaterialType type
Material constitutive model.
ArapMaterialParams arap
Parameters for the ARAP material model.
StVenantKirchhoffMaterialParams stVenantKirchhoff
Parameters for the St.
NeoHookeanMaterialParams neoHookean
Parameters for the Neo-Hookean material model.
LinearElasticMaterialParams linearElastic
Parameters for the Linear Elastic material model.
real massDampingCoefficient
Mass damping coefficient [1/s].
bool stiffnessDampingIncludeGeometricTerm
[Experimental] Include the geometric term in the stiffness-damping tangent.
Parameters for the Saint Venant-Kirchhoff (StVK) hyperelastic material model.