feat(cpp-object-oriented-modular-refactoring): step 13 - element-definition-domain

This commit is contained in:
KOKO\Mimi
2026-08-16 09:10:38 +09:00
parent cf6fc6e1d9
commit 19ba02a6a4
26 changed files with 740 additions and 242 deletions
+9 -1
View File
@@ -23,12 +23,18 @@ class AnalysisModel {
/// @brief Returns the sole active static step.
const StaticStepDefinition& Step() const noexcept;
/// @brief Returns active beam element indices in stable internal order.
/// @brief Returns active element-definition indices in stable Domain order.
const std::vector<EntityIndex>& ActiveElements() const noexcept;
/// @brief Returns active B33 indices in their concrete compatibility view.
const std::vector<EntityIndex>& ActiveBeamElements() const noexcept;
/// @brief Returns reachable material indices in stable internal order.
const std::vector<EntityIndex>& ActiveMaterials() const noexcept;
/// @brief Returns reachable property indices in stable internal order.
const std::vector<EntityIndex>& ActiveProperties() const noexcept;
/// @brief Returns reachable beam-section indices in stable internal order.
const std::vector<EntityIndex>& ActiveSections() const noexcept;
@@ -44,7 +50,9 @@ class AnalysisModel {
const Domain* domain_;
std::vector<EntityIndex> active_elements_;
std::vector<EntityIndex> active_beam_elements_;
std::vector<EntityIndex> active_materials_;
std::vector<EntityIndex> active_properties_;
std::vector<EntityIndex> active_sections_;
std::vector<EntityIndex> active_boundary_conditions_;
std::vector<EntityIndex> active_loads_;
@@ -0,0 +1,42 @@
#ifndef FESA_ELEMENTS_ELEMENT_DEFINITION_H_
#define FESA_ELEMENTS_ELEMENT_DEFINITION_H_
#include <string_view>
#include <vector>
#include "fesa/core/source_identity.h"
namespace fesa {
/// @brief Identifies the supported semantic element-definition kinds.
enum class ElementDefinitionKind { kEulerBeam3D, kMitc4Shell };
/// @brief Provides immutable source identity and topology for one element.
/// @note Numerical stiffness, recovery, and equation ids are intentionally
/// excluded from this semantic interface.
class ElementDefinition {
public:
virtual ~ElementDefinition() = default;
/// @brief Returns the concrete semantic definition kind.
virtual ElementDefinitionKind Kind() const noexcept = 0;
/// @brief Returns the stable external source identity.
virtual const SourceEntityId& SourceId() const noexcept = 0;
/// @brief Returns the preserved source element type such as B33 or S4R.
virtual std::string_view SourceElementType() const noexcept = 0;
/// @brief Returns stable Domain node collection positions.
virtual const std::vector<EntityIndex>& NodeIndices() const noexcept = 0;
/// @brief Returns the stable Domain material collection position.
virtual EntityIndex MaterialIndex() const noexcept = 0;
/// @brief Returns the stable Domain property collection position.
virtual EntityIndex PropertyIndex() const noexcept = 0;
};
} // namespace fesa
#endif // FESA_ELEMENTS_ELEMENT_DEFINITION_H_
+38 -1
View File
@@ -4,15 +4,52 @@
#include <array>
#include <cstddef>
#include <string>
#include <string_view>
#include <vector>
#include "fesa/core/status.h"
#include "fesa/elements/element_definition.h"
#include "fesa/materials/isotropic_linear_elastic_material.h"
#include "fesa/math/matrix.h"
#include "fesa/math/vector.h"
#include "fesa/model/model_types.h"
#include "fesa/properties/general_beam_section.h"
namespace fesa {
class Domain;
struct Node;
/// @brief Defines one two-node B33 semantic element.
class EulerBeam3DDefinition final : public ElementDefinition {
public:
/// @brief Constructs a parser-validated semantic definition.
EulerBeam3DDefinition(SourceEntityId source_id,
std::array<EntityIndex, 2> node_indices,
EntityIndex material_index, EntityIndex section_index,
SourceLocation location);
ElementDefinitionKind Kind() const noexcept override;
const SourceEntityId& SourceId() const noexcept override;
std::string_view SourceElementType() const noexcept override;
const std::vector<EntityIndex>& NodeIndices() const noexcept override;
EntityIndex MaterialIndex() const noexcept override;
EntityIndex PropertyIndex() const noexcept override;
SourceEntityId source_id;
std::array<EntityIndex, 2> node_indices;
EntityIndex material_index;
EntityIndex section_index;
SourceLocation location;
private:
friend class Domain;
/// @brief Synchronizes the base view after parser-candidate construction.
void SynchronizeNodeIndices();
std::vector<EntityIndex> node_indices_view_;
};
/// @brief Stores constant line-load components in the beam local frame.
struct ConstantLocalLineLoad {
double px;
+51 -1
View File
@@ -3,15 +3,65 @@
#include <array>
#include <string>
#include <string_view>
#include <vector>
#include "fesa/core/status.h"
#include "fesa/elements/element_definition.h"
#include "fesa/materials/isotropic_linear_elastic_material.h"
#include "fesa/math/matrix.h"
#include "fesa/math/vector.h"
#include "fesa/math/vector3.h"
#include "fesa/model/model_types.h"
#include "fesa/properties/shell_section.h"
namespace fesa {
class Domain;
struct Node;
/// @brief Preserves the source shell type independently of formulation.
enum class ShellSourceElementType { kS4, kS4r };
/// @brief Names the internal shell formulation selected by S4 and S4R.
inline constexpr std::string_view kMitc4InternalFormulation{"FESA-MITC4"};
/// @brief Defines one four-node S4/S4R semantic element.
class Mitc4ShellDefinition final : public ElementDefinition {
public:
/// @brief Constructs a parser-validated semantic definition.
Mitc4ShellDefinition(SourceEntityId source_id,
ShellSourceElementType source_type,
std::array<EntityIndex, 4> node_indices,
EntityIndex material_index, EntityIndex section_index,
SourceLocation location);
ElementDefinitionKind Kind() const noexcept override;
const SourceEntityId& SourceId() const noexcept override;
std::string_view SourceElementType() const noexcept override;
const std::vector<EntityIndex>& NodeIndices() const noexcept override;
EntityIndex MaterialIndex() const noexcept override;
EntityIndex PropertyIndex() const noexcept override;
SourceEntityId source_id;
ShellSourceElementType source_type;
std::array<EntityIndex, 4> node_indices;
EntityIndex material_index;
EntityIndex section_index;
SourceLocation location;
private:
friend class Domain;
/// @brief Rebinds a shell-local section index to the unified property view.
void SetPropertyIndex(EntityIndex property_index) noexcept;
/// @brief Synchronizes the base view after parser-candidate construction.
void SynchronizeNodeIndices();
EntityIndex property_index_;
std::vector<EntityIndex> node_indices_view_;
};
/// @brief Stores bilinear shape values and natural-coordinate derivatives.
struct Mitc4ShapeFunctions {
std::array<double, 4> values;
@@ -63,6 +63,9 @@ class IsotropicLinearElasticMaterial final : public Material {
SourceEntityId source_id_;
};
/// @brief Preserves the approved V0 material spelling for current consumers.
using LinearElasticMaterial = IsotropicLinearElasticMaterial;
} // namespace fesa
#endif // FESA_MATERIALS_ISOTROPIC_LINEAR_ELASTIC_MATERIAL_H_
+65 -7
View File
@@ -1,7 +1,9 @@
#ifndef FESA_MODEL_DOMAIN_H_
#define FESA_MODEL_DOMAIN_H_
#include <cstddef>
#include <filesystem>
#include <memory>
#include <string>
#include <vector>
@@ -10,6 +12,34 @@
namespace fesa {
/// @brief Exposes immutable references without transferring Domain ownership.
/// @tparam T Base or concrete semantic type stored by the Domain.
template <class T>
class DomainCollectionView {
public:
/// @brief Returns the number of stable collection positions.
std::size_t Size() const noexcept { return entries_.size(); }
/// @brief Reports whether the collection has no entries.
bool Empty() const noexcept { return entries_.empty(); }
/// @brief Returns one immutable entry without bounds checking.
const T& operator[](const std::size_t index) const noexcept {
return *entries_[index];
}
/// @brief Returns one immutable entry with bounds checking.
const T& At(const std::size_t index) const { return *entries_.at(index); }
private:
friend class Domain;
/// @brief Adds one reference while the owning Domain candidate is built.
void Add(const T& entry) { entries_.push_back(&entry); }
std::vector<const T*> entries_;
};
/// @brief Owns the complete immutable semantic model definition.
/// @note Collection positions remain stable internal indices after
/// construction.
@@ -20,23 +50,40 @@ class Domain {
/// @return A successful owning Domain.
static Result<Domain> Create(ModelDefinition definition);
Domain(const Domain&) = delete;
Domain& operator=(const Domain&) = delete;
Domain(Domain&&) noexcept = default;
Domain& operator=(Domain&&) noexcept = default;
/// @brief Returns nodes in stable declaration order.
const std::vector<Node>& Nodes() const noexcept;
/// @brief Returns Euler beam definitions in stable declaration order.
const std::vector<EulerBeam3DDefinition>& Elements() const noexcept;
/// @brief Returns all element definitions in stable Domain index order.
const DomainCollectionView<ElementDefinition>& Elements() const noexcept;
/// @brief Returns B33 definitions in their stable concrete order.
const DomainCollectionView<EulerBeam3DDefinition>& BeamElements()
const noexcept;
/// @brief Returns MITC4 shell definitions in stable declaration order.
const std::vector<Mitc4ShellDefinition>& ShellElements() const noexcept;
const DomainCollectionView<Mitc4ShellDefinition>& ShellElements()
const noexcept;
/// @brief Returns materials in stable declaration order.
const std::vector<LinearElasticMaterial>& Materials() const noexcept;
/// @brief Returns all materials in stable Domain index order.
const DomainCollectionView<Material>& Materials() const noexcept;
/// @brief Returns current isotropic materials in stable concrete order.
const DomainCollectionView<LinearElasticMaterial>& LinearElasticMaterials()
const noexcept;
/// @brief Returns all properties in stable Domain index order.
const DomainCollectionView<ElementProperty>& Properties() const noexcept;
/// @brief Returns beam sections in stable declaration order.
const std::vector<GeneralBeamSection>& Sections() const noexcept;
const DomainCollectionView<GeneralBeamSection>& Sections() const noexcept;
/// @brief Returns shell sections in stable declaration order.
const std::vector<ShellSection>& ShellSections() const noexcept;
const DomainCollectionView<ShellSection>& ShellSections() const noexcept;
/// @brief Returns preprocessed shell-node frames in stable node order.
const std::vector<ShellNodeInitialFrame>& ShellNodeInitialFrames()
@@ -65,6 +112,17 @@ class Domain {
explicit Domain(ModelDefinition definition);
ModelDefinition definition_;
std::vector<std::unique_ptr<ElementDefinition>> element_definitions_;
std::vector<std::unique_ptr<ElementProperty>> element_properties_;
std::vector<std::unique_ptr<Material>> materials_;
DomainCollectionView<ElementDefinition> elements_view_;
DomainCollectionView<EulerBeam3DDefinition> beam_elements_view_;
DomainCollectionView<Mitc4ShellDefinition> shell_elements_view_;
DomainCollectionView<ElementProperty> properties_view_;
DomainCollectionView<GeneralBeamSection> sections_view_;
DomainCollectionView<ShellSection> shell_sections_view_;
DomainCollectionView<Material> materials_view_;
DomainCollectionView<LinearElasticMaterial> linear_materials_view_;
};
} // namespace fesa
+2 -29
View File
@@ -11,6 +11,8 @@
#include "fesa/core/diagnostic.h"
#include "fesa/core/source_identity.h"
#include "fesa/elements/euler_beam_3d.h"
#include "fesa/elements/mitc4_shell.h"
#include "fesa/materials/isotropic_linear_elastic_material.h"
#include "fesa/properties/general_beam_section.h"
#include "fesa/properties/shell_section.h"
@@ -24,26 +26,6 @@ struct Node {
SourceLocation location;
};
/// @brief Keeps the current material spelling during the hierarchy migration.
using LinearElasticMaterial = IsotropicLinearElasticMaterial;
/// @brief Preserves the source shell element label independently of
/// formulation.
enum class ShellSourceElementType { kS4, kS4r };
/// @brief Names the single internal shell formulation selected by S4 and S4R.
inline constexpr std::string_view kMitc4InternalFormulation{"FESA-MITC4"};
/// @brief Defines one four-node shell with stable semantic references.
struct Mitc4ShellDefinition {
SourceEntityId source_id;
ShellSourceElementType source_type;
std::array<EntityIndex, 4> node_indices;
EntityIndex material_index;
EntityIndex section_index;
SourceLocation location;
};
/// @brief Stores the deterministic initial director and tangent frame at a
/// node.
struct ShellNodeInitialFrame {
@@ -53,15 +35,6 @@ struct ShellNodeInitialFrame {
std::array<double, 3> tangent_b;
};
/// @brief Defines one two-node Euler beam with stable semantic references.
struct EulerBeam3DDefinition {
SourceEntityId source_id;
std::array<EntityIndex, 2> node_indices;
EntityIndex material_index;
EntityIndex section_index;
SourceLocation location;
};
/// @brief Stores one prescribed nodal degree-of-freedom range.
struct BoundaryCondition {
std::string target;