Files
FESADev/include/fesa/model/domain.h
T

299 lines
12 KiB
C++

#ifndef FESA_MODEL_DOMAIN_H_
#define FESA_MODEL_DOMAIN_H_
#include <cstddef>
#include <filesystem>
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include "fesa/constraints/boundary_condition.h"
#include "fesa/constraints/prescribed_displacement.h"
#include "fesa/core/status.h"
#include "fesa/loads/concentrated_nodal_load.h"
#include "fesa/loads/load.h"
#include "fesa/model/model_types.h"
namespace fesa {
class StepDefinition;
/// @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;
friend class StepDefinition;
/// @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 one immutable static or frequency-step semantic definition.
/// @note Loads retain source order and are owned polymorphically by unique
/// pointers.
class StepDefinition {
public:
StepDefinition(const StepDefinition&) = delete;
StepDefinition& operator=(const StepDefinition&) = delete;
StepDefinition(StepDefinition&&) noexcept = default;
StepDefinition& operator=(StepDefinition&&) noexcept = default;
/// @brief Returns the source step name.
const std::string& Name() const noexcept;
/// @brief Returns polymorphic boundaries in stable source/component order.
const BoundaryConditionView& BoundaryConditions() const noexcept;
/// @brief Returns prescribed displacements in stable source/component order.
const DomainCollectionView<PrescribedDisplacementBoundaryCondition>&
PrescribedDisplacements() const noexcept;
/// @brief Returns polymorphic loads in stable source order.
const LoadView& Loads() const noexcept;
/// @brief Returns current concentrated loads in stable source order.
const DomainCollectionView<ConcentratedNodalLoad>& ConcentratedLoads()
const noexcept;
/// @brief Returns additive surface pressure records in source order.
const std::vector<SurfacePressureLoadDefinition>& SurfacePressureLoads()
const noexcept;
/// @brief Returns the approved static procedure identity.
StaticProcedureKind ProcedureKind() const noexcept;
/// @brief Reports whether this step uses the nonlinear static procedure.
bool IsNonlinearStatic() const noexcept;
/// @brief Reports whether this step defines the frequency procedure.
bool IsFrequency() const noexcept;
/// @brief Reports whether this step defines the HHT dynamic procedure.
bool IsDynamic() const noexcept;
/// @brief Returns frequency source semantics when this is a frequency step.
const FrequencyStepDefinition* Frequency() const noexcept;
/// @brief Returns dynamic source semantics when this is a dynamic step.
const DynamicStepDefinition* Dynamic() const noexcept;
/// @brief Reports the source NLGEOM setting for this static step.
bool UsesNonlinearGeometry() const noexcept;
/// @brief Returns the static initial increment provenance value.
double InitialIncrement() const noexcept;
/// @brief Returns the static time-period provenance value.
double TimePeriod() const noexcept;
/// @brief Returns the static minimum-increment provenance value.
double MinimumIncrement() const noexcept;
/// @brief Returns the static maximum-increment provenance value.
double MaximumIncrement() const noexcept;
/// @brief Reports the source STATIC DIRECT fixed-schedule selection.
bool IsDirectStatic() const noexcept;
/// @brief Returns the fixed Solid static increment count, or zero otherwise.
std::uint32_t IncrementCount() const noexcept;
/// @brief Returns the source static INC limit.
std::uint32_t MaximumIncrements() const noexcept;
/// @brief Returns the source location of the step declaration.
const SourceLocation& Location() const noexcept;
private:
friend class Domain;
/// @brief Converts one parsed static-step record to owned semantic objects.
explicit StepDefinition(StaticStepDefinition definition);
/// @brief Converts one parsed frequency-step record to owned semantics.
explicit StepDefinition(FrequencyStepDefinition definition);
/// @brief Converts one parsed dynamic-step record to owned semantics.
explicit StepDefinition(DynamicStepDefinition definition);
std::string name_;
std::vector<std::unique_ptr<BoundaryCondition>> boundary_conditions_;
BoundaryConditionView boundary_conditions_view_;
DomainCollectionView<PrescribedDisplacementBoundaryCondition>
prescribed_displacements_view_;
std::vector<std::unique_ptr<Load>> loads_;
LoadView loads_view_;
DomainCollectionView<ConcentratedNodalLoad> concentrated_loads_view_;
std::vector<SurfacePressureLoadDefinition> surface_pressure_loads_;
StaticProcedureKind procedure_kind_;
bool nlgeom_;
double initial_increment_;
double time_period_;
double minimum_increment_;
double maximum_increment_;
SourceLocation location_;
std::optional<FrequencyStepDefinition> frequency_;
std::optional<DynamicStepDefinition> dynamic_;
bool direct_static_{false};
std::uint32_t increment_count_{0U};
std::uint32_t maximum_increments_{100U};
};
/// @brief Owns the complete immutable semantic model definition.
/// @note Collection positions remain stable internal indices after
/// construction.
class Domain {
public:
/// @brief Creates a Domain that owns a copy or moved model definition.
/// @param definition Complete parsed semantic records in declaration order.
/// @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 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 DomainCollectionView<Mitc4ShellDefinition>& ShellElements()
const noexcept;
/// @brief Returns C3D8 definitions in stable source order.
const DomainCollectionView<Hex8Definition>& SolidElements() const noexcept;
/// @brief Returns homogeneous Solid section assignments.
const DomainCollectionView<SolidSection>& SolidSections() const noexcept;
/// @brief Reports whether this model has exclusively Solid elements.
bool IsSolid() const noexcept;
/// @brief Returns immutable model-level amplitude curves in source order.
const std::vector<TabularAmplitudeDefinition>& Amplitudes() 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 thermal materials in stable thermal declaration order.
const DomainCollectionView<IsotropicThermalMaterial>& ThermalMaterials()
const noexcept;
/// @brief Returns DS4 definitions in stable thermal declaration order.
const DomainCollectionView<Ds4ThermalDefinition>& ThermalElements()
const noexcept;
/// @brief Returns centered thermal shell assignments in declaration order.
const std::vector<ThermalShellSectionDefinition>& ThermalSections()
const noexcept;
/// @brief Returns resolved initial temperatures in source order.
const std::vector<ThermalInitialConditionDefinition>&
ThermalInitialConditions() const noexcept;
/// @brief Returns model-level thermal boundary definitions in source order.
const std::vector<ThermalBoundaryConditionDefinition>&
ThermalModelBoundaries() const noexcept;
/// @brief Returns the sole thermal step, or null when the model is
/// structural.
const ThermalStepDefinition* ThermalStep() 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 DomainCollectionView<GeneralBeamSection>& Sections() const noexcept;
/// @brief Returns shell sections in stable declaration order.
const DomainCollectionView<ShellSection>& ShellSections() const noexcept;
/// @brief Returns preprocessed shell-node frames in stable node order.
const std::vector<ShellNodeInitialFrame>& ShellNodeInitialFrames()
const noexcept;
/// @brief Returns node sets in stable declaration order.
const std::vector<NodeSet>& NodeSets() const noexcept;
/// @brief Returns element sets in stable declaration order.
const std::vector<ElementSet>& ElementSets() const noexcept;
/// @brief Returns assembly element surfaces in stable declaration order.
const std::vector<ElementSurfaceDefinition>& ElementSurfaces() const noexcept;
/// @brief Returns procedure steps in stable declaration order.
const DomainCollectionView<StepDefinition>& Steps() const noexcept;
/// @brief Returns resolved density records in stable material-index order.
const std::vector<MaterialDensityDefinition>& Densities() const noexcept;
/// @brief Returns the sole frequency source definition when present.
const FrequencyStepDefinition* Frequency() const noexcept;
/// @brief Returns the sole dynamic source definition when present.
const DynamicStepDefinition* Dynamic() const noexcept;
/// @brief Returns sorted nonfatal mapping diagnostics.
const std::vector<Diagnostic>& Warnings() const noexcept;
/// @brief Returns the source input path associated with this model.
const std::filesystem::path& SourcePath() const noexcept;
/// @brief Returns the deterministic source-content identity.
const std::string& SourceContentIdentity() const noexcept;
private:
/// @brief Takes ownership of an already constructed model definition.
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_;
std::vector<std::unique_ptr<StepDefinition>> step_definitions_;
DomainCollectionView<ElementDefinition> elements_view_;
DomainCollectionView<EulerBeam3DDefinition> beam_elements_view_;
DomainCollectionView<Mitc4ShellDefinition> shell_elements_view_;
DomainCollectionView<Hex8Definition> solid_elements_view_;
DomainCollectionView<SolidSection> solid_sections_view_;
DomainCollectionView<ElementProperty> properties_view_;
DomainCollectionView<GeneralBeamSection> sections_view_;
DomainCollectionView<ShellSection> shell_sections_view_;
DomainCollectionView<Material> materials_view_;
DomainCollectionView<LinearElasticMaterial> linear_materials_view_;
DomainCollectionView<IsotropicThermalMaterial> thermal_materials_view_;
DomainCollectionView<Ds4ThermalDefinition> thermal_elements_view_;
DomainCollectionView<StepDefinition> steps_view_;
};
} // namespace fesa
#endif // FESA_MODEL_DOMAIN_H_