feat(cpp-object-oriented-modular-refactoring): step 15 - generic-dof-manager

This commit is contained in:
KOKO\Mimi
2026-08-16 10:07:02 +09:00
parent c8c32236de
commit 9e74398655
5 changed files with 527 additions and 218 deletions
+35 -9
View File
@@ -12,6 +12,8 @@
namespace fesa {
class DofManagerTestAccess;
/// @brief Stores the stable structural CSR pattern.
struct SparsePattern {
std::vector<std::size_t> row_offsets;
@@ -21,9 +23,22 @@ struct SparsePattern {
/// @brief Owns full/free/constrained numbering, scatter maps, and CSR pattern.
class DofManager {
public:
/// @brief Creates an empty candidate for atomic Build replacement.
DofManager() = default;
/// @brief Creates every equation-space mapping for an active model.
/// @note This compatibility entry point derives temporary semantic layouts;
/// the procedure-owned runtime element view supersedes it in Step 20.
static Result<DofManager> Create(const AnalysisModel& model);
/// @brief Builds mappings from runtime element layouts in supplied order.
/// @param analysis_model Non-owning active model view that outlives this
/// call.
/// @param elements Runtime elements in stable active source order.
/// @return Success after atomic replacement or a structured model failure.
Status Build(const AnalysisModel& analysis_model,
const ElementView& elements);
/// @brief Returns the full node-by-component DOF count.
std::size_t FullDofCount() const noexcept;
/// @brief Returns the free-equation count.
@@ -34,11 +49,16 @@ class DofManager {
std::size_t FullDof(EntityIndex node, DofComponent component) const;
/// @brief Returns the free equation for a full DOF when unconstrained.
std::optional<std::size_t> FreeEquation(std::size_t full_dof) const;
/// @brief Maps one declared runtime layout to stable full DOFs.
/// @return The declared node/component scatter or a layout failure.
Result<std::vector<std::size_t>> ElementScatter(
const ElementDofLayout& layout) const;
/// @brief Returns a beam scatter in endpoint/component order.
const std::array<std::size_t, 12>& ElementScatter(EntityIndex element) const;
/// @note This compatibility wrapper delegates to the generic stored layout.
std::array<std::size_t, 12> ElementScatter(EntityIndex element) const;
/// @brief Returns a shell scatter in node/component order.
const std::array<std::size_t, 24>& ShellElementScatter(
EntityIndex element) const;
/// @note This compatibility wrapper delegates to the generic stored layout.
std::array<std::size_t, 24> ShellElementScatter(EntityIndex element) const;
/// @brief Returns free full DOFs in stable increasing order.
const std::vector<std::size_t>& FreeDofs() const noexcept;
/// @brief Returns constrained full DOFs in stable increasing order.
@@ -47,24 +67,30 @@ class DofManager {
const Vector& PrescribedValues() const noexcept;
/// @brief Returns the full-space structural CSR pattern.
const SparsePattern& GetSparsePattern() const noexcept;
/// @brief Validates the complete owner-issued equation and pattern mapping.
Status ValidateInvariants() const;
private:
friend class DofManagerTestAccess;
/// @brief Builds from copied layouts after the caller fixes their order.
Status BuildLayouts(const AnalysisModel& analysis_model,
const std::vector<ElementDofLayout>& layouts);
/// @brief Takes ownership of fully validated stable equation mappings.
DofManager(std::size_t full_dof_count,
std::vector<std::optional<std::size_t>> free_equations,
std::vector<std::array<std::size_t, 12>> element_scatters,
std::vector<std::array<std::size_t, 24>> shell_element_scatters,
std::vector<std::vector<std::size_t>> element_scatters,
std::vector<std::size_t> free_dofs,
std::vector<std::size_t> constrained_dofs,
Vector prescribed_values, SparsePattern sparse_pattern);
std::size_t full_dof_count_;
std::size_t full_dof_count_{0U};
std::vector<std::optional<std::size_t>> free_equations_;
std::vector<std::array<std::size_t, 12>> element_scatters_;
std::vector<std::array<std::size_t, 24>> shell_element_scatters_;
std::vector<std::vector<std::size_t>> element_scatters_;
std::vector<std::size_t> free_dofs_;
std::vector<std::size_t> constrained_dofs_;
Vector prescribed_values_;
Vector prescribed_values_{0U};
SparsePattern sparse_pattern_;
};