feat(cpp-object-oriented-modular-refactoring): step 13 - element-definition-domain
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user