From ba6264e22cce128d105d91b8587dbacec080d4f4 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Thu, 8 Oct 2026 10:30:03 -0400 Subject: [PATCH] feat(equations): added material centering equation this equation provides a residual that weakly enforces that some material point should remain at the origin --- src/include/serif/equations/centering.hpp | 50 +++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/include/serif/equations/centering.hpp diff --git a/src/include/serif/equations/centering.hpp b/src/include/serif/equations/centering.hpp new file mode 100644 index 00000000..47d63f48 --- /dev/null +++ b/src/include/serif/equations/centering.hpp @@ -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 +#include + +#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> { + using Operands = utils::types::TypeList; ///< 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 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 evaluate(const EquationPoint& point) { + PointLinearization result; + result.residual = point.fields.get(); + for (int axis = 0; axis < 3; ++axis) { + result.field_derivatives.get()[axis][axis] = 1.0; + } + return result; + } + }; +} // namespace serif::equations