feat(cpp-object-oriented-modular-refactoring): step 5 - solver-workflow-google-style

This commit is contained in:
KOKO\Mimi
2026-08-16 06:20:08 +09:00
parent e1c0e357dd
commit 24f006fe4a
52 changed files with 5817 additions and 6369 deletions
+83
View File
@@ -0,0 +1,83 @@
#ifndef FESA_FEM_DOF_MANAGER_H_
#define FESA_FEM_DOF_MANAGER_H_
#include <array>
#include <cstddef>
#include <cstdint>
#include <optional>
#include <vector>
#include "fesa/analysis/analysis_model.h"
#include "fesa/math/vector.h"
namespace fesa {
/// @brief Identifies one component in the stable six-DOF node layout.
enum class DofComponent : std::uint8_t {
kUx,
kUy,
kUz,
kUrx,
kUry,
kUrz,
};
/// @brief Stores the stable structural CSR pattern.
struct SparsePattern {
std::vector<std::size_t> row_offsets;
std::vector<std::size_t> column_indices;
};
/// @brief Owns full/free/constrained numbering, scatter maps, and CSR pattern.
class DofManager {
public:
/// @brief Creates every equation-space mapping for an active model.
static Result<DofManager> Create(const AnalysisModel& model);
/// @brief Returns the full node-by-component DOF count.
std::size_t FullDofCount() const noexcept;
/// @brief Returns the free-equation count.
std::size_t FreeDofCount() const noexcept;
/// @brief Returns the prescribed-DOF count.
std::size_t ConstrainedDofCount() const noexcept;
/// @brief Maps a stable node index and component to a full DOF.
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 Returns a beam scatter in endpoint/component order.
const 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;
/// @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.
const std::vector<std::size_t>& ConstrainedDofs() const noexcept;
/// @brief Returns dc in constrained-DOF order.
const Vector& PrescribedValues() const noexcept;
/// @brief Returns the full-space structural CSR pattern.
const SparsePattern& GetSparsePattern() const noexcept;
private:
/// @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::size_t> free_dofs,
std::vector<std::size_t> constrained_dofs,
Vector prescribed_values, SparsePattern sparse_pattern);
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::size_t> free_dofs_;
std::vector<std::size_t> constrained_dofs_;
Vector prescribed_values_;
SparsePattern sparse_pattern_;
};
} // namespace fesa
#endif // FESA_FEM_DOF_MANAGER_H_
-69
View File
@@ -1,69 +0,0 @@
#pragma once
#include "fesa/analysis/analysis_model.hpp"
#include "fesa/math/vector.h"
#include <array>
#include <cstddef>
#include <cstdint>
#include <optional>
#include <vector>
namespace fesa {
enum class DofComponent : std::uint8_t {
ux,
uy,
uz,
urx,
ury,
urz
};
struct SparsePattern {
std::vector<std::size_t> rowOffsets;
std::vector<std::size_t> columnIndices;
};
// Owns every equation-space mapping so semantic model objects remain free of
// analysis-specific equation IDs.
class DofManager {
public:
static Result<DofManager> create(const AnalysisModel& model);
std::size_t fullDofCount() const noexcept;
std::size_t freeDofCount() const noexcept;
std::size_t constrainedDofCount() const noexcept;
std::size_t fullDof(EntityIndex node, DofComponent component) const;
std::optional<std::size_t> freeEquation(std::size_t fullDof) const;
const std::array<std::size_t, 12>& elementScatter(
EntityIndex element) const;
const std::array<std::size_t, 24>& shellElementScatter(
EntityIndex element) const;
const std::vector<std::size_t>& freeDofs() const noexcept;
const std::vector<std::size_t>& constrainedDofs() const noexcept;
const Vector& prescribedValues() const noexcept;
const SparsePattern& sparsePattern() const noexcept;
private:
DofManager(
std::size_t fullDofCount,
std::vector<std::optional<std::size_t>> freeEquations,
std::vector<std::array<std::size_t, 12>> elementScatters,
std::vector<std::array<std::size_t, 24>> shellElementScatters,
std::vector<std::size_t> freeDofs,
std::vector<std::size_t> constrainedDofs,
Vector prescribedValues,
SparsePattern sparsePattern);
std::size_t fullDofCount_;
std::vector<std::optional<std::size_t>> freeEquations_;
std::vector<std::array<std::size_t, 12>> elementScatters_;
std::vector<std::array<std::size_t, 24>> shellElementScatters_;
std::vector<std::size_t> freeDofs_;
std::vector<std::size_t> constrainedDofs_;
Vector prescribedValues_;
SparsePattern sparsePattern_;
};
} // namespace fesa