feat(cpp-object-oriented-modular-refactoring): step 13 - element-definition-domain
This commit is contained in:
@@ -77,6 +77,19 @@ fesa::ModelDefinition MakeDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
fesa::ModelDefinition MakeMixedDefinition() {
|
||||
auto definition = MakeDefinition();
|
||||
const auto source = definition.source_path;
|
||||
definition.shell_sections = {{"ShellSection", 0.01, 1U, {source, 35U}}};
|
||||
definition.shell_elements = {{{"Shell-1", 5, "5"},
|
||||
fesa::ShellSourceElementType::kS4,
|
||||
{0U, 1U, 2U, 3U},
|
||||
1U,
|
||||
0U,
|
||||
{source, 45U}}};
|
||||
return definition;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(AnalysisModel, ClassifiesActiveEntitiesInStableOrder) {
|
||||
@@ -102,9 +115,9 @@ TEST(AnalysisModel, ReferencesWithoutCopyingOrMutatingDomain) {
|
||||
auto domain_result = fesa::Domain::Create(MakeDefinition());
|
||||
ASSERT_TRUE(domain_result.HasValue());
|
||||
const fesa::Domain& domain = domain_result.Value();
|
||||
const auto* const element_address = domain.Elements().data();
|
||||
const auto* const material_address = domain.Materials().data();
|
||||
const auto* const section_address = domain.Sections().data();
|
||||
const auto* const element_address = &domain.Elements()[0U];
|
||||
const auto* const material_address = &domain.Materials()[0U];
|
||||
const auto* const section_address = &domain.Sections()[0U];
|
||||
const std::string step_name = domain.Steps()[0].name;
|
||||
const double first_load_magnitude = domain.Steps()[0].loads[0].magnitude;
|
||||
|
||||
@@ -114,9 +127,9 @@ TEST(AnalysisModel, ReferencesWithoutCopyingOrMutatingDomain) {
|
||||
|
||||
EXPECT_EQ(&model.GetDomain(), &domain);
|
||||
EXPECT_EQ(&model.Step(), &domain.Steps()[0]);
|
||||
EXPECT_EQ(model.GetDomain().Elements().data(), element_address);
|
||||
EXPECT_EQ(model.GetDomain().Materials().data(), material_address);
|
||||
EXPECT_EQ(model.GetDomain().Sections().data(), section_address);
|
||||
EXPECT_EQ(&model.GetDomain().Elements()[0U], element_address);
|
||||
EXPECT_EQ(&model.GetDomain().Materials()[0U], material_address);
|
||||
EXPECT_EQ(&model.GetDomain().Sections()[0U], section_address);
|
||||
EXPECT_EQ(&model.GetDomain().Elements()[model.ActiveElements()[1]],
|
||||
&domain.Elements()[1]);
|
||||
EXPECT_EQ(&model.GetDomain().Materials()[model.ActiveMaterials()[2]],
|
||||
@@ -127,6 +140,31 @@ TEST(AnalysisModel, ReferencesWithoutCopyingOrMutatingDomain) {
|
||||
EXPECT_DOUBLE_EQ(domain.Steps()[0].loads[0].magnitude, first_load_magnitude);
|
||||
}
|
||||
|
||||
// C-MODEL-002
|
||||
TEST(AnalysisModel, KeepsNonOwningMixedDefinitionAndPropertyIndices) {
|
||||
auto domain_result = fesa::Domain::Create(MakeMixedDefinition());
|
||||
ASSERT_TRUE(domain_result.HasValue());
|
||||
const fesa::Domain& domain = domain_result.Value();
|
||||
|
||||
auto model_result = fesa::AnalysisModel::Create(domain);
|
||||
ASSERT_TRUE(model_result.HasValue());
|
||||
const fesa::AnalysisModel& model = model_result.Value();
|
||||
|
||||
EXPECT_EQ(&model.GetDomain(), &domain);
|
||||
EXPECT_EQ(model.ActiveElements(),
|
||||
(std::vector<fesa::EntityIndex>{0U, 1U, 2U, 3U, 4U}));
|
||||
EXPECT_EQ(model.ActiveMaterials(),
|
||||
(std::vector<fesa::EntityIndex>{0U, 1U, 2U}));
|
||||
EXPECT_EQ(model.ActiveProperties(),
|
||||
(std::vector<fesa::EntityIndex>{0U, 1U, 2U, 4U}));
|
||||
EXPECT_EQ(&model.GetDomain().Elements()[model.ActiveElements()[4U]],
|
||||
&domain.Elements()[4U]);
|
||||
EXPECT_EQ(&model.GetDomain().Materials()[model.ActiveMaterials()[1U]],
|
||||
&domain.Materials()[1U]);
|
||||
EXPECT_EQ(&model.GetDomain().Properties()[model.ActiveProperties()[3U]],
|
||||
&domain.Properties()[4U]);
|
||||
}
|
||||
|
||||
TEST(AnalysisModel, RejectsMissingOrMultipleStep) {
|
||||
auto missing_definition = MakeDefinition();
|
||||
missing_definition.steps.clear();
|
||||
|
||||
Reference in New Issue
Block a user