feat(cpp-object-oriented-modular-refactoring): step 4 - model-element-google-style
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
#ifndef FESA_MODEL_DOMAIN_H_
|
||||
#define FESA_MODEL_DOMAIN_H_
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "fesa/core/status.h"
|
||||
#include "fesa/model/model_types.h"
|
||||
|
||||
namespace fesa {
|
||||
|
||||
/// @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);
|
||||
|
||||
/// @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 MITC4 shell definitions in stable declaration order.
|
||||
const std::vector<Mitc4ShellDefinition>& ShellElements() const noexcept;
|
||||
|
||||
/// @brief Returns materials in stable declaration order.
|
||||
const std::vector<LinearElasticMaterial>& Materials() const noexcept;
|
||||
|
||||
/// @brief Returns beam sections in stable declaration order.
|
||||
const std::vector<GeneralBeamSection>& Sections() const noexcept;
|
||||
|
||||
/// @brief Returns shell sections in stable declaration order.
|
||||
const std::vector<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 static steps in stable declaration order.
|
||||
const std::vector<StaticStepDefinition>& Steps() 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_;
|
||||
};
|
||||
|
||||
} // namespace fesa
|
||||
|
||||
#endif // FESA_MODEL_DOMAIN_H_
|
||||
@@ -1,38 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "fesa/core/status.h"
|
||||
#include "fesa/model/model_types.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace fesa {
|
||||
|
||||
// Owns the complete semantic definition. Public access remains const so a
|
||||
// vector position can serve as a stable internal index after construction.
|
||||
class Domain {
|
||||
public:
|
||||
static Result<Domain> create(ModelDefinition definition);
|
||||
|
||||
const std::vector<Node>& nodes() const noexcept;
|
||||
const std::vector<EulerBeam3DDefinition>& elements() const noexcept;
|
||||
const std::vector<Mitc4ShellDefinition>& shellElements() const noexcept;
|
||||
const std::vector<LinearElasticMaterial>& materials() const noexcept;
|
||||
const std::vector<GeneralBeamSection>& sections() const noexcept;
|
||||
const std::vector<ShellSection>& shellSections() const noexcept;
|
||||
const std::vector<ShellNodeInitialFrame>& shellNodeInitialFrames() const noexcept;
|
||||
const std::vector<NodeSet>& nodeSets() const noexcept;
|
||||
const std::vector<ElementSet>& elementSets() const noexcept;
|
||||
const std::vector<StaticStepDefinition>& steps() const noexcept;
|
||||
const std::vector<Diagnostic>& warnings() const noexcept;
|
||||
const std::filesystem::path& sourcePath() const noexcept;
|
||||
const std::string& sourceContentIdentity() const noexcept;
|
||||
|
||||
private:
|
||||
explicit Domain(ModelDefinition definition);
|
||||
|
||||
ModelDefinition definition_;
|
||||
};
|
||||
|
||||
} // namespace fesa
|
||||
@@ -0,0 +1,185 @@
|
||||
#ifndef FESA_MODEL_MODEL_TYPES_H_
|
||||
#define FESA_MODEL_MODEL_TYPES_H_
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "fesa/core/diagnostic.h"
|
||||
#include "fesa/core/source_identity.h"
|
||||
|
||||
namespace fesa {
|
||||
|
||||
/// @brief Identifies a semantic entity by its stable collection position.
|
||||
using EntityIndex = std::uint32_t;
|
||||
|
||||
/// @brief Stores one source node and its global coordinates.
|
||||
struct Node {
|
||||
SourceEntityId source_id;
|
||||
std::array<double, 3> coordinates;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
/// @brief Stores the supported homogeneous isotropic elastic properties.
|
||||
struct LinearElasticMaterial {
|
||||
std::string name;
|
||||
double youngs_modulus;
|
||||
double poisson_ratio;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
/// @brief Stores the supported general Euler beam section properties.
|
||||
struct GeneralBeamSection {
|
||||
std::string name;
|
||||
double area;
|
||||
double i11;
|
||||
double i12;
|
||||
double i22;
|
||||
double torsional_constant;
|
||||
std::array<double, 3> first_axis;
|
||||
std::vector<std::array<double, 2>> section_points;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
/// @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 Stores a centered constant-thickness shell section assignment.
|
||||
struct ShellSection {
|
||||
std::string name;
|
||||
double thickness;
|
||||
EntityIndex material_index;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
/// @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 {
|
||||
EntityIndex node_index;
|
||||
std::array<double, 3> director;
|
||||
std::array<double, 3> tangent_a;
|
||||
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;
|
||||
int first_dof;
|
||||
int last_dof;
|
||||
double value;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
/// @brief Stores one concentrated nodal load component.
|
||||
struct NodalLoad {
|
||||
std::string target;
|
||||
int dof;
|
||||
double magnitude;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
/// @brief Stores the approved single linear-static step definition.
|
||||
struct StaticStepDefinition {
|
||||
std::string name;
|
||||
std::vector<BoundaryCondition> boundaries;
|
||||
std::vector<NodalLoad> loads;
|
||||
double initial_increment;
|
||||
double time_period;
|
||||
double minimum_increment;
|
||||
double maximum_increment;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
/// @brief Stores a stable resolved node-set membership list.
|
||||
struct NodeSet {
|
||||
std::string name;
|
||||
std::optional<std::string> instance_name;
|
||||
std::vector<EntityIndex> node_indices;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
/// @brief Stores a stable resolved element-set membership list.
|
||||
struct ElementSet {
|
||||
std::string name;
|
||||
std::optional<std::string> instance_name;
|
||||
std::vector<EntityIndex> element_indices;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
/// @brief Preserves source identities declared inside one part.
|
||||
struct PartDefinition {
|
||||
std::string name;
|
||||
std::vector<std::int64_t> node_source_labels;
|
||||
std::vector<std::int64_t> element_source_labels;
|
||||
std::vector<std::string> node_set_names;
|
||||
std::vector<std::string> element_set_names;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
/// @brief Maps one source label to a stable internal entity index.
|
||||
struct SourceIndexMapping {
|
||||
std::int64_t source_label;
|
||||
EntityIndex internal_index;
|
||||
};
|
||||
|
||||
/// @brief Preserves one identity instance and its deterministic source
|
||||
/// mappings.
|
||||
struct InstanceDefinition {
|
||||
std::string name;
|
||||
std::string part_name;
|
||||
std::vector<SourceIndexMapping> node_mappings;
|
||||
std::vector<SourceIndexMapping> element_mappings;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
/// @brief Owns every parsed semantic record before immutable Domain
|
||||
/// construction.
|
||||
struct ModelDefinition {
|
||||
std::filesystem::path source_path;
|
||||
std::string source_content_identity;
|
||||
std::string heading;
|
||||
std::vector<Node> nodes;
|
||||
std::vector<EulerBeam3DDefinition> elements;
|
||||
std::vector<Mitc4ShellDefinition> shell_elements;
|
||||
std::vector<LinearElasticMaterial> materials;
|
||||
std::vector<GeneralBeamSection> sections;
|
||||
std::vector<ShellSection> shell_sections;
|
||||
std::vector<ShellNodeInitialFrame> shell_node_initial_frames;
|
||||
std::vector<NodeSet> node_sets;
|
||||
std::vector<ElementSet> element_sets;
|
||||
std::vector<PartDefinition> parts;
|
||||
std::vector<InstanceDefinition> instances;
|
||||
std::vector<StaticStepDefinition> steps;
|
||||
std::vector<Diagnostic> warnings;
|
||||
};
|
||||
|
||||
} // namespace fesa
|
||||
|
||||
#endif // FESA_MODEL_MODEL_TYPES_H_
|
||||
@@ -1,165 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "fesa/core/diagnostic.h"
|
||||
#include "fesa/core/source_identity.h"
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace fesa {
|
||||
|
||||
// Stable internal identities are vector positions assigned in declaration order.
|
||||
using EntityIndex = std::uint32_t;
|
||||
|
||||
struct Node {
|
||||
SourceEntityId sourceId;
|
||||
std::array<double, 3> coordinates;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
struct LinearElasticMaterial {
|
||||
std::string name;
|
||||
double youngsModulus;
|
||||
double poissonRatio;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
struct GeneralBeamSection {
|
||||
std::string name;
|
||||
double area;
|
||||
double i11;
|
||||
double i12;
|
||||
double i22;
|
||||
double torsionalConstant;
|
||||
std::array<double, 3> firstAxis;
|
||||
std::vector<std::array<double, 2>> sectionPoints;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
enum class ShellSourceElementType {
|
||||
s4,
|
||||
s4r
|
||||
};
|
||||
|
||||
inline constexpr std::string_view kMitc4InternalFormulation{"FESA-MITC4"};
|
||||
|
||||
struct ShellSection {
|
||||
std::string name;
|
||||
double thickness;
|
||||
EntityIndex materialIndex;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
struct Mitc4ShellDefinition {
|
||||
SourceEntityId sourceId;
|
||||
ShellSourceElementType sourceType;
|
||||
std::array<EntityIndex, 4> nodeIndices;
|
||||
EntityIndex materialIndex;
|
||||
EntityIndex sectionIndex;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
struct ShellNodeInitialFrame {
|
||||
EntityIndex nodeIndex;
|
||||
std::array<double, 3> director;
|
||||
std::array<double, 3> tangentA;
|
||||
std::array<double, 3> tangentB;
|
||||
};
|
||||
|
||||
struct EulerBeam3DDefinition {
|
||||
SourceEntityId sourceId;
|
||||
std::array<EntityIndex, 2> nodeIndices;
|
||||
EntityIndex materialIndex;
|
||||
EntityIndex sectionIndex;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
struct BoundaryCondition {
|
||||
std::string target;
|
||||
int firstDof;
|
||||
int lastDof;
|
||||
double value;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
struct NodalLoad {
|
||||
std::string target;
|
||||
int dof;
|
||||
double magnitude;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
struct StaticStepDefinition {
|
||||
std::string name;
|
||||
std::vector<BoundaryCondition> boundaries;
|
||||
std::vector<NodalLoad> loads;
|
||||
double initialIncrement;
|
||||
double timePeriod;
|
||||
double minimumIncrement;
|
||||
double maximumIncrement;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
struct NodeSet {
|
||||
std::string name;
|
||||
std::optional<std::string> instanceName;
|
||||
std::vector<EntityIndex> nodeIndices;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
struct ElementSet {
|
||||
std::string name;
|
||||
std::optional<std::string> instanceName;
|
||||
std::vector<EntityIndex> elementIndices;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
struct PartDefinition {
|
||||
std::string name;
|
||||
std::vector<std::int64_t> nodeSourceLabels;
|
||||
std::vector<std::int64_t> elementSourceLabels;
|
||||
std::vector<std::string> nodeSetNames;
|
||||
std::vector<std::string> elementSetNames;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
struct SourceIndexMapping {
|
||||
std::int64_t sourceLabel;
|
||||
EntityIndex internalIndex;
|
||||
};
|
||||
|
||||
struct InstanceDefinition {
|
||||
std::string name;
|
||||
std::string partName;
|
||||
std::vector<SourceIndexMapping> nodeMappings;
|
||||
std::vector<SourceIndexMapping> elementMappings;
|
||||
SourceLocation location;
|
||||
};
|
||||
|
||||
// This construction-boundary value owns every parsed semantic record before
|
||||
// it is finalized into an immutable Domain.
|
||||
struct ModelDefinition {
|
||||
std::filesystem::path sourcePath;
|
||||
std::string sourceContentIdentity;
|
||||
std::string heading;
|
||||
std::vector<Node> nodes;
|
||||
std::vector<EulerBeam3DDefinition> elements;
|
||||
std::vector<Mitc4ShellDefinition> shellElements;
|
||||
std::vector<LinearElasticMaterial> materials;
|
||||
std::vector<GeneralBeamSection> sections;
|
||||
std::vector<ShellSection> shellSections;
|
||||
std::vector<ShellNodeInitialFrame> shellNodeInitialFrames;
|
||||
std::vector<NodeSet> nodeSets;
|
||||
std::vector<ElementSet> elementSets;
|
||||
std::vector<PartDefinition> parts;
|
||||
std::vector<InstanceDefinition> instances;
|
||||
std::vector<StaticStepDefinition> steps;
|
||||
std::vector<Diagnostic> warnings;
|
||||
};
|
||||
|
||||
} // namespace fesa
|
||||
@@ -0,0 +1,53 @@
|
||||
#ifndef FESA_MODEL_SHELL_GEOMETRY_H_
|
||||
#define FESA_MODEL_SHELL_GEOMETRY_H_
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
#include "fesa/core/status.h"
|
||||
#include "fesa/model/model_types.h"
|
||||
|
||||
namespace fesa {
|
||||
|
||||
/// @brief Classifies a mandatory shell-geometry validation location.
|
||||
enum class ShellGeometryPointKind { kCenter, kStiffness, kTying, kRecovery };
|
||||
|
||||
/// @brief Identifies one deterministic shell-geometry validation point.
|
||||
struct ShellGeometryValidationPoint {
|
||||
ShellGeometryPointKind kind;
|
||||
std::size_t location_index;
|
||||
std::array<double, 3> natural_coordinates;
|
||||
};
|
||||
|
||||
/// @brief Stores deterministic preprocessing data for one shell element.
|
||||
struct ShellElementGeometryData {
|
||||
EntityIndex element_index;
|
||||
std::array<double, 3> normal_candidate;
|
||||
double surface_area_weight;
|
||||
};
|
||||
|
||||
/// @brief Owns preprocessed shell node frames and element geometry data.
|
||||
struct ShellGeometry {
|
||||
std::vector<ShellNodeInitialFrame> nodal_frames;
|
||||
std::vector<ShellElementGeometryData> element_data;
|
||||
};
|
||||
|
||||
/// @brief Returns the complete fixed validation-point inventory.
|
||||
/// @note Ordering is center, stiffness, tying, then recovery identity.
|
||||
const std::array<ShellGeometryValidationPoint, 17>&
|
||||
ShellGeometryValidationPoints() noexcept;
|
||||
|
||||
/// @brief Builds deterministic nodal frames and validates shell geometry.
|
||||
/// @param nodes Source nodes indexed by stable EntityIndex.
|
||||
/// @param elements Shell definitions in stable source order.
|
||||
/// @param sections Shell sections used for thickness validation.
|
||||
/// @return Validated geometry or a structured model failure.
|
||||
Result<ShellGeometry> PreprocessShellGeometry(
|
||||
const std::vector<Node>& nodes,
|
||||
const std::vector<Mitc4ShellDefinition>& elements,
|
||||
const std::vector<ShellSection>& sections);
|
||||
|
||||
} // namespace fesa
|
||||
|
||||
#endif // FESA_MODEL_SHELL_GEOMETRY_H_
|
||||
@@ -1,44 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "fesa/core/status.h"
|
||||
#include "fesa/model/model_types.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
namespace fesa {
|
||||
|
||||
enum class ShellGeometryPointKind {
|
||||
center,
|
||||
stiffness,
|
||||
tying,
|
||||
recovery
|
||||
};
|
||||
|
||||
struct ShellGeometryValidationPoint {
|
||||
ShellGeometryPointKind kind;
|
||||
std::size_t locationIndex;
|
||||
std::array<double, 3> naturalCoordinates;
|
||||
};
|
||||
|
||||
struct ShellElementGeometryData {
|
||||
EntityIndex elementIndex;
|
||||
std::array<double, 3> normalCandidate;
|
||||
double surfaceAreaWeight;
|
||||
};
|
||||
|
||||
struct ShellGeometry {
|
||||
std::vector<ShellNodeInitialFrame> nodalFrames;
|
||||
std::vector<ShellElementGeometryData> elementData;
|
||||
};
|
||||
|
||||
const std::array<ShellGeometryValidationPoint, 17>&
|
||||
shellGeometryValidationPoints() noexcept;
|
||||
|
||||
Result<ShellGeometry> preprocessShellGeometry(
|
||||
const std::vector<Node>& nodes,
|
||||
const std::vector<Mitc4ShellDefinition>& elements,
|
||||
const std::vector<ShellSection>& sections);
|
||||
|
||||
} // namespace fesa
|
||||
Reference in New Issue
Block a user