feat(equations): added material centering equation
this equation provides a residual that weakly enforces that some material point should remain at the origin
This commit is contained in:
50
src/include/serif/equations/centering.hpp
Normal file
50
src/include/serif/equations/centering.hpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file centering.hpp
|
||||
* @author Emily M. Boudreaux
|
||||
*
|
||||
* @brief File containing the CenteringConstraint equation, which fixes the material point at the computational origin.
|
||||
*
|
||||
* @note This is probably the simplest equation we have right now and therefore may serve as a useful example to learn from.
|
||||
*/
|
||||
|
||||
#include <array>
|
||||
#include <string_view>
|
||||
|
||||
#include "serif/equations/contributions.hpp"
|
||||
#include "serif/equations/point.hpp"
|
||||
|
||||
namespace serif::equations {
|
||||
/**
|
||||
* @brief Equation that fixes the material point at the computational origin.
|
||||
*
|
||||
* @contribution Residuals to the global displacement vector.
|
||||
*
|
||||
* @note This is a translational gauge, not a center-of-mass constraint.
|
||||
*/
|
||||
struct CenteringConstraint final : Contribution<discretization::forms::Operand<discretization::blocks::displacement::vector>> {
|
||||
using Operands = utils::types::TypeList<TestOperand>; ///< The list of operands for the centering constraint equation.
|
||||
static constexpr std::string_view name = "centering constraint"; ///< Compile time name for the centering constraint equation, used for debugging and logging.
|
||||
static constexpr bool position_independent = true; ///< A centering constraint is position independent, as it does not depend on the spatial location of the material point. This member is only used for compile-time checks.
|
||||
static constexpr std::array<double, 3> reference_position{}; ///< The reference position for the centering constraint equation, which is the origin (0, 0, 0). This member is only used for compile-time checks.
|
||||
|
||||
|
||||
/**
|
||||
* @brief Evaluate the centering constraint equation at a given point. Fundamentally all this this is doing is
|
||||
* returning the displacement of the material point at the origin since to center that the displacement of that point should be zero.
|
||||
* The derivative of the residual with respect to displacement along each axis is then just the identity matrix.
|
||||
*
|
||||
* @param point The point at which to evaluate the centering constraint equation.
|
||||
* @return A PointLinearization object containing the residual and field derivatives for the centering constraint equation at the given point.
|
||||
*/
|
||||
[[nodiscard]] static PointLinearization<Operands, discretization::forms::VectorValue> evaluate(const EquationPoint<Operands>& point) {
|
||||
PointLinearization<Operands, discretization::forms::VectorValue> result;
|
||||
result.residual = point.fields.get<Test>();
|
||||
for (int axis = 0; axis < 3; ++axis) {
|
||||
result.field_derivatives.get<Test>()[axis][axis] = 1.0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
} // namespace serif::equations
|
||||
Reference in New Issue
Block a user