feat(cpp-object-oriented-modular-refactoring): step 5 - solver-workflow-google-style
This commit is contained in:
@@ -1,96 +1,90 @@
|
||||
#include "fesa/analysis/analysis_model.hpp"
|
||||
#include "fesa/analysis/analysis_model.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace fesa {
|
||||
|
||||
Result<AnalysisModel> AnalysisModel::create(const Domain& domain) {
|
||||
if (domain.Steps().empty()) {
|
||||
return Result<AnalysisModel>::Failure(Status::Failure(
|
||||
FailureCategory::kInput,
|
||||
{{Severity::kError,
|
||||
"invalid-model-cardinality",
|
||||
{domain.SourcePath(), 0U},
|
||||
"STEP",
|
||||
"0",
|
||||
"AnalysisModel requires exactly one static step."}}));
|
||||
}
|
||||
if (domain.Steps().size() > 1U) {
|
||||
const auto& secondStep = domain.Steps()[1];
|
||||
return Result<AnalysisModel>::Failure(Status::Failure(
|
||||
FailureCategory::kInput,
|
||||
{{Severity::kError,
|
||||
"unsupported-multiple-step",
|
||||
secondStep.location,
|
||||
"STEP",
|
||||
secondStep.name,
|
||||
"AnalysisModel does not support multiple steps."}}));
|
||||
}
|
||||
return Result<AnalysisModel>::Success(AnalysisModel{domain});
|
||||
Result<AnalysisModel> AnalysisModel::Create(const Domain& domain) {
|
||||
if (domain.Steps().empty()) {
|
||||
return Result<AnalysisModel>::Failure(
|
||||
Status::Failure(FailureCategory::kInput,
|
||||
{{Severity::kError,
|
||||
"invalid-model-cardinality",
|
||||
{domain.SourcePath(), 0U},
|
||||
"STEP",
|
||||
"0",
|
||||
"AnalysisModel requires exactly one static step."}}));
|
||||
}
|
||||
if (domain.Steps().size() > 1U) {
|
||||
const auto& second_step = domain.Steps()[1];
|
||||
return Result<AnalysisModel>::Failure(
|
||||
Status::Failure(FailureCategory::kInput,
|
||||
{{Severity::kError, "unsupported-multiple-step",
|
||||
second_step.location, "STEP", second_step.name,
|
||||
"AnalysisModel does not support multiple steps."}}));
|
||||
}
|
||||
return Result<AnalysisModel>::Success(AnalysisModel{domain});
|
||||
}
|
||||
|
||||
const Domain& AnalysisModel::domain() const noexcept {
|
||||
return *domain_;
|
||||
const Domain& AnalysisModel::GetDomain() const noexcept { return *domain_; }
|
||||
|
||||
const StaticStepDefinition& AnalysisModel::Step() const noexcept {
|
||||
return domain_->Steps().front();
|
||||
}
|
||||
|
||||
const StaticStepDefinition& AnalysisModel::step() const noexcept {
|
||||
return domain_->Steps().front();
|
||||
const std::vector<EntityIndex>& AnalysisModel::ActiveElements() const noexcept {
|
||||
return active_elements_;
|
||||
}
|
||||
|
||||
const std::vector<EntityIndex>& AnalysisModel::activeElements() const noexcept {
|
||||
return activeElements_;
|
||||
const std::vector<EntityIndex>& AnalysisModel::ActiveMaterials()
|
||||
const noexcept {
|
||||
return active_materials_;
|
||||
}
|
||||
|
||||
const std::vector<EntityIndex>& AnalysisModel::activeMaterials() const noexcept {
|
||||
return activeMaterials_;
|
||||
const std::vector<EntityIndex>& AnalysisModel::ActiveSections() const noexcept {
|
||||
return active_sections_;
|
||||
}
|
||||
|
||||
const std::vector<EntityIndex>& AnalysisModel::activeSections() const noexcept {
|
||||
return activeSections_;
|
||||
const std::vector<EntityIndex>& AnalysisModel::ActiveBoundaryConditions()
|
||||
const noexcept {
|
||||
return active_boundary_conditions_;
|
||||
}
|
||||
|
||||
const std::vector<EntityIndex>&
|
||||
AnalysisModel::activeBoundaryConditions() const noexcept {
|
||||
return activeBoundaryConditions_;
|
||||
}
|
||||
|
||||
const std::vector<EntityIndex>& AnalysisModel::activeLoads() const noexcept {
|
||||
return activeLoads_;
|
||||
const std::vector<EntityIndex>& AnalysisModel::ActiveLoads() const noexcept {
|
||||
return active_loads_;
|
||||
}
|
||||
|
||||
AnalysisModel::AnalysisModel(const Domain& domain) : domain_{&domain} {
|
||||
std::vector<bool> reachableMaterials(domain.Materials().size(), false);
|
||||
std::vector<bool> reachableSections(domain.Sections().size(), false);
|
||||
std::vector<bool> reachable_materials(domain.Materials().size(), false);
|
||||
std::vector<bool> reachable_sections(domain.Sections().size(), false);
|
||||
|
||||
for (std::size_t index = 0U; index < domain.Elements().size(); ++index) {
|
||||
const auto& element = domain.Elements()[index];
|
||||
activeElements_.push_back(static_cast<EntityIndex>(index));
|
||||
reachableMaterials[element.material_index] = true;
|
||||
reachableSections[element.section_index] = true;
|
||||
}
|
||||
for (std::size_t index = 0U; index < domain.Elements().size(); ++index) {
|
||||
const auto& element = domain.Elements()[index];
|
||||
active_elements_.push_back(static_cast<EntityIndex>(index));
|
||||
reachable_materials[element.material_index] = true;
|
||||
reachable_sections[element.section_index] = true;
|
||||
}
|
||||
|
||||
// Ascending vector positions are the stable internal order, independent
|
||||
// of first reachability or duplicate element assignments.
|
||||
for (std::size_t index = 0U; index < reachableMaterials.size(); ++index) {
|
||||
if (reachableMaterials[index]) {
|
||||
activeMaterials_.push_back(static_cast<EntityIndex>(index));
|
||||
}
|
||||
// Ascending vector positions are the stable internal order, independent
|
||||
// of first reachability or duplicate element assignments.
|
||||
for (std::size_t index = 0U; index < reachable_materials.size(); ++index) {
|
||||
if (reachable_materials[index]) {
|
||||
active_materials_.push_back(static_cast<EntityIndex>(index));
|
||||
}
|
||||
for (std::size_t index = 0U; index < reachableSections.size(); ++index) {
|
||||
if (reachableSections[index]) {
|
||||
activeSections_.push_back(static_cast<EntityIndex>(index));
|
||||
}
|
||||
}
|
||||
for (std::size_t index = 0U; index < reachable_sections.size(); ++index) {
|
||||
if (reachable_sections[index]) {
|
||||
active_sections_.push_back(static_cast<EntityIndex>(index));
|
||||
}
|
||||
}
|
||||
|
||||
for (std::size_t index = 0U;
|
||||
index < step().boundaries.size();
|
||||
++index) {
|
||||
activeBoundaryConditions_.push_back(static_cast<EntityIndex>(index));
|
||||
}
|
||||
for (std::size_t index = 0U; index < step().loads.size(); ++index) {
|
||||
activeLoads_.push_back(static_cast<EntityIndex>(index));
|
||||
}
|
||||
for (std::size_t index = 0U; index < Step().boundaries.size(); ++index) {
|
||||
active_boundary_conditions_.push_back(static_cast<EntityIndex>(index));
|
||||
}
|
||||
for (std::size_t index = 0U; index < Step().loads.size(); ++index) {
|
||||
active_loads_.push_back(static_cast<EntityIndex>(index));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace fesa
|
||||
} // namespace fesa
|
||||
|
||||
Reference in New Issue
Block a user