345 lines
12 KiB
C++
345 lines
12 KiB
C++
#include "fesa/model/domain.h"
|
|
|
|
#include <cstddef>
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <utility>
|
|
|
|
namespace fesa {
|
|
|
|
StepDefinition::StepDefinition(StaticStepDefinition definition)
|
|
: name_{std::move(definition.name)},
|
|
procedure_kind_{definition.procedure_kind},
|
|
nlgeom_{definition.nlgeom},
|
|
initial_increment_{definition.initial_increment},
|
|
time_period_{definition.time_period},
|
|
minimum_increment_{definition.minimum_increment},
|
|
maximum_increment_{definition.maximum_increment},
|
|
location_{std::move(definition.location)} {
|
|
for (auto& boundary : definition.boundaries) {
|
|
for (int source_dof = boundary.first_dof; source_dof <= boundary.last_dof;
|
|
++source_dof) {
|
|
const std::size_t source_order = boundary_conditions_.size();
|
|
auto owned = std::make_unique<PrescribedDisplacementBoundaryCondition>(
|
|
SourceTargetQuery{SourceEntityKind::kNode, "", boundary.target},
|
|
static_cast<DofComponent>(source_dof - 1), boundary.value,
|
|
source_order, boundary.location);
|
|
boundary_conditions_view_.push_back(std::cref(*owned));
|
|
prescribed_displacements_view_.Add(*owned);
|
|
boundary_conditions_.push_back(std::move(owned));
|
|
}
|
|
}
|
|
loads_.reserve(definition.loads.size());
|
|
loads_view_.reserve(definition.loads.size());
|
|
for (std::size_t source_order = 0U; source_order < definition.loads.size();
|
|
++source_order) {
|
|
auto& load = definition.loads[source_order];
|
|
auto owned = std::make_unique<ConcentratedNodalLoad>(
|
|
SourceTargetQuery{SourceEntityKind::kNode, "", load.target}, load.dof,
|
|
load.magnitude, source_order, std::move(load.location));
|
|
loads_view_.push_back(std::cref(*owned));
|
|
concentrated_loads_view_.Add(*owned);
|
|
loads_.push_back(std::move(owned));
|
|
}
|
|
surface_pressure_loads_ = std::move(definition.surface_pressure_loads);
|
|
}
|
|
|
|
StepDefinition::StepDefinition(FrequencyStepDefinition definition)
|
|
: name_{definition.source_step_name_raw},
|
|
procedure_kind_{StaticProcedureKind::kLinearSmallDisplacement},
|
|
nlgeom_{false},
|
|
initial_increment_{0.0},
|
|
time_period_{0.0},
|
|
minimum_increment_{0.0},
|
|
maximum_increment_{0.0},
|
|
location_{definition.step_location},
|
|
frequency_{std::move(definition)} {
|
|
for (const auto& boundary : frequency_->boundaries) {
|
|
for (int source_dof = boundary.first_dof; source_dof <= boundary.last_dof;
|
|
++source_dof) {
|
|
const std::size_t source_order = boundary_conditions_.size();
|
|
auto owned = std::make_unique<PrescribedDisplacementBoundaryCondition>(
|
|
SourceTargetQuery{SourceEntityKind::kNode, "", boundary.target},
|
|
static_cast<DofComponent>(source_dof - 1), boundary.value,
|
|
source_order, boundary.location);
|
|
boundary_conditions_view_.push_back(std::cref(*owned));
|
|
prescribed_displacements_view_.Add(*owned);
|
|
boundary_conditions_.push_back(std::move(owned));
|
|
}
|
|
}
|
|
}
|
|
|
|
StepDefinition::StepDefinition(DynamicStepDefinition definition)
|
|
: name_{definition.source_step_name_raw},
|
|
procedure_kind_{StaticProcedureKind::kNonlinearFullNewton},
|
|
nlgeom_{true},
|
|
initial_increment_{definition.initial_increment},
|
|
time_period_{definition.time_period},
|
|
minimum_increment_{definition.initial_increment},
|
|
maximum_increment_{definition.initial_increment},
|
|
location_{definition.step_location},
|
|
dynamic_{std::move(definition)} {
|
|
for (const auto& boundary : dynamic_->boundaries) {
|
|
for (int source_dof = boundary.first_dof; source_dof <= boundary.last_dof;
|
|
++source_dof) {
|
|
const std::size_t source_order = boundary_conditions_.size();
|
|
auto owned = std::make_unique<PrescribedDisplacementBoundaryCondition>(
|
|
SourceTargetQuery{SourceEntityKind::kNode, "", boundary.target},
|
|
static_cast<DofComponent>(source_dof - 1), boundary.value,
|
|
source_order, boundary.location);
|
|
boundary_conditions_view_.push_back(std::cref(*owned));
|
|
prescribed_displacements_view_.Add(*owned);
|
|
boundary_conditions_.push_back(std::move(owned));
|
|
}
|
|
}
|
|
loads_.reserve(dynamic_->loads.size());
|
|
loads_view_.reserve(dynamic_->loads.size());
|
|
for (std::size_t source_order = 0U; source_order < dynamic_->loads.size();
|
|
++source_order) {
|
|
auto& load = dynamic_->loads[source_order];
|
|
auto owned = std::make_unique<ConcentratedNodalLoad>(
|
|
SourceTargetQuery{SourceEntityKind::kNode, "", load.target}, load.dof,
|
|
load.magnitude, source_order, std::move(load.location));
|
|
loads_view_.push_back(std::cref(*owned));
|
|
concentrated_loads_view_.Add(*owned);
|
|
loads_.push_back(std::move(owned));
|
|
}
|
|
}
|
|
|
|
const std::string& StepDefinition::Name() const noexcept { return name_; }
|
|
|
|
const BoundaryConditionView& StepDefinition::BoundaryConditions()
|
|
const noexcept {
|
|
return boundary_conditions_view_;
|
|
}
|
|
|
|
const DomainCollectionView<PrescribedDisplacementBoundaryCondition>&
|
|
StepDefinition::PrescribedDisplacements() const noexcept {
|
|
return prescribed_displacements_view_;
|
|
}
|
|
|
|
const LoadView& StepDefinition::Loads() const noexcept { return loads_view_; }
|
|
|
|
const DomainCollectionView<ConcentratedNodalLoad>&
|
|
StepDefinition::ConcentratedLoads() const noexcept {
|
|
return concentrated_loads_view_;
|
|
}
|
|
|
|
const std::vector<SurfacePressureLoadDefinition>&
|
|
StepDefinition::SurfacePressureLoads() const noexcept {
|
|
return surface_pressure_loads_;
|
|
}
|
|
|
|
StaticProcedureKind StepDefinition::ProcedureKind() const noexcept {
|
|
return procedure_kind_;
|
|
}
|
|
|
|
bool StepDefinition::IsNonlinearStatic() const noexcept {
|
|
return !dynamic_ &&
|
|
procedure_kind_ == StaticProcedureKind::kNonlinearFullNewton;
|
|
}
|
|
|
|
bool StepDefinition::IsFrequency() const noexcept {
|
|
return frequency_.has_value();
|
|
}
|
|
|
|
bool StepDefinition::IsDynamic() const noexcept { return dynamic_.has_value(); }
|
|
|
|
const FrequencyStepDefinition* StepDefinition::Frequency() const noexcept {
|
|
return frequency_ ? &*frequency_ : nullptr;
|
|
}
|
|
|
|
const DynamicStepDefinition* StepDefinition::Dynamic() const noexcept {
|
|
return dynamic_ ? &*dynamic_ : nullptr;
|
|
}
|
|
|
|
bool StepDefinition::UsesNonlinearGeometry() const noexcept { return nlgeom_; }
|
|
|
|
double StepDefinition::InitialIncrement() const noexcept {
|
|
return initial_increment_;
|
|
}
|
|
|
|
double StepDefinition::TimePeriod() const noexcept { return time_period_; }
|
|
|
|
double StepDefinition::MinimumIncrement() const noexcept {
|
|
return minimum_increment_;
|
|
}
|
|
|
|
double StepDefinition::MaximumIncrement() const noexcept {
|
|
return maximum_increment_;
|
|
}
|
|
|
|
const SourceLocation& StepDefinition::Location() const noexcept {
|
|
return location_;
|
|
}
|
|
|
|
Result<Domain> Domain::Create(ModelDefinition definition) {
|
|
return Result<Domain>::Success(Domain{std::move(definition)});
|
|
}
|
|
|
|
const std::vector<Node>& Domain::Nodes() const noexcept {
|
|
return definition_.nodes;
|
|
}
|
|
|
|
const DomainCollectionView<ElementDefinition>& Domain::Elements()
|
|
const noexcept {
|
|
return elements_view_;
|
|
}
|
|
|
|
const DomainCollectionView<EulerBeam3DDefinition>& Domain::BeamElements()
|
|
const noexcept {
|
|
return beam_elements_view_;
|
|
}
|
|
|
|
const DomainCollectionView<Mitc4ShellDefinition>& Domain::ShellElements()
|
|
const noexcept {
|
|
return shell_elements_view_;
|
|
}
|
|
|
|
const DomainCollectionView<Material>& Domain::Materials() const noexcept {
|
|
return materials_view_;
|
|
}
|
|
|
|
const DomainCollectionView<LinearElasticMaterial>&
|
|
Domain::LinearElasticMaterials() const noexcept {
|
|
return linear_materials_view_;
|
|
}
|
|
|
|
const DomainCollectionView<ElementProperty>& Domain::Properties()
|
|
const noexcept {
|
|
return properties_view_;
|
|
}
|
|
|
|
const DomainCollectionView<GeneralBeamSection>& Domain::Sections()
|
|
const noexcept {
|
|
return sections_view_;
|
|
}
|
|
|
|
const DomainCollectionView<ShellSection>& Domain::ShellSections()
|
|
const noexcept {
|
|
return shell_sections_view_;
|
|
}
|
|
|
|
const std::vector<ShellNodeInitialFrame>& Domain::ShellNodeInitialFrames()
|
|
const noexcept {
|
|
return definition_.shell_node_initial_frames;
|
|
}
|
|
|
|
const std::vector<NodeSet>& Domain::NodeSets() const noexcept {
|
|
return definition_.node_sets;
|
|
}
|
|
|
|
const std::vector<ElementSet>& Domain::ElementSets() const noexcept {
|
|
return definition_.element_sets;
|
|
}
|
|
|
|
const std::vector<ElementSurfaceDefinition>& Domain::ElementSurfaces()
|
|
const noexcept {
|
|
return definition_.element_surfaces;
|
|
}
|
|
|
|
const DomainCollectionView<StepDefinition>& Domain::Steps() const noexcept {
|
|
return steps_view_;
|
|
}
|
|
|
|
const std::vector<MaterialDensityDefinition>& Domain::Densities()
|
|
const noexcept {
|
|
return definition_.densities;
|
|
}
|
|
|
|
const FrequencyStepDefinition* Domain::Frequency() const noexcept {
|
|
return steps_view_.Size() == 1U ? steps_view_[0U].Frequency() : nullptr;
|
|
}
|
|
|
|
const DynamicStepDefinition* Domain::Dynamic() const noexcept {
|
|
return steps_view_.Size() == 1U ? steps_view_[0U].Dynamic() : nullptr;
|
|
}
|
|
|
|
const std::vector<Diagnostic>& Domain::Warnings() const noexcept {
|
|
return definition_.warnings;
|
|
}
|
|
|
|
const std::filesystem::path& Domain::SourcePath() const noexcept {
|
|
return definition_.source_path;
|
|
}
|
|
|
|
const std::string& Domain::SourceContentIdentity() const noexcept {
|
|
return definition_.source_content_identity;
|
|
}
|
|
|
|
Domain::Domain(ModelDefinition definition)
|
|
: definition_{std::move(definition)} {
|
|
materials_.reserve(definition_.materials.size());
|
|
for (auto& material : definition_.materials) {
|
|
auto owned = std::make_unique<LinearElasticMaterial>(std::move(material));
|
|
materials_view_.Add(*owned);
|
|
linear_materials_view_.Add(*owned);
|
|
materials_.push_back(std::move(owned));
|
|
}
|
|
definition_.materials.clear();
|
|
|
|
element_properties_.reserve(definition_.sections.size() +
|
|
definition_.shell_sections.size());
|
|
for (auto& section : definition_.sections) {
|
|
auto owned = std::make_unique<GeneralBeamSection>(std::move(section));
|
|
properties_view_.Add(*owned);
|
|
sections_view_.Add(*owned);
|
|
element_properties_.push_back(std::move(owned));
|
|
}
|
|
const std::size_t beam_property_count = element_properties_.size();
|
|
definition_.sections.clear();
|
|
for (auto& section : definition_.shell_sections) {
|
|
auto owned = std::make_unique<ShellSection>(std::move(section));
|
|
properties_view_.Add(*owned);
|
|
shell_sections_view_.Add(*owned);
|
|
element_properties_.push_back(std::move(owned));
|
|
}
|
|
definition_.shell_sections.clear();
|
|
|
|
element_definitions_.reserve(definition_.elements.size() +
|
|
definition_.shell_elements.size());
|
|
for (auto& element : definition_.elements) {
|
|
element.SynchronizeNodeIndices();
|
|
auto owned = std::make_unique<EulerBeam3DDefinition>(std::move(element));
|
|
elements_view_.Add(*owned);
|
|
beam_elements_view_.Add(*owned);
|
|
element_definitions_.push_back(std::move(owned));
|
|
}
|
|
definition_.elements.clear();
|
|
for (auto& element : definition_.shell_elements) {
|
|
element.SynchronizeNodeIndices();
|
|
element.SetPropertyIndex(
|
|
static_cast<EntityIndex>(beam_property_count + element.section_index));
|
|
auto owned = std::make_unique<Mitc4ShellDefinition>(std::move(element));
|
|
elements_view_.Add(*owned);
|
|
shell_elements_view_.Add(*owned);
|
|
element_definitions_.push_back(std::move(owned));
|
|
}
|
|
definition_.shell_elements.clear();
|
|
|
|
step_definitions_.reserve(definition_.steps.size() +
|
|
(definition_.frequency_step ? 1U : 0U) +
|
|
(definition_.dynamic_step ? 1U : 0U));
|
|
for (auto& step : definition_.steps) {
|
|
auto owned =
|
|
std::unique_ptr<StepDefinition>(new StepDefinition(std::move(step)));
|
|
steps_view_.Add(*owned);
|
|
step_definitions_.push_back(std::move(owned));
|
|
}
|
|
definition_.steps.clear();
|
|
if (definition_.frequency_step) {
|
|
auto owned = std::unique_ptr<StepDefinition>(
|
|
new StepDefinition(std::move(*definition_.frequency_step)));
|
|
steps_view_.Add(*owned);
|
|
step_definitions_.push_back(std::move(owned));
|
|
}
|
|
if (definition_.dynamic_step) {
|
|
auto owned = std::unique_ptr<StepDefinition>(
|
|
new StepDefinition(std::move(*definition_.dynamic_step)));
|
|
steps_view_.Add(*owned);
|
|
step_definitions_.push_back(std::move(owned));
|
|
}
|
|
}
|
|
|
|
} // namespace fesa
|