feat(cpp-object-oriented-modular-refactoring): step 13 - element-definition-domain

This commit is contained in:
KOKO\Mimi
2026-08-16 09:10:38 +09:00
parent cf6fc6e1d9
commit 19ba02a6a4
26 changed files with 740 additions and 242 deletions
+43 -28
View File
@@ -13,6 +13,7 @@
#include <utility>
#include <vector>
#include "fesa/elements/element_definition.h"
#include "fesa/io/abaqus/input_reader.h"
#include "fesa/math/vector3.h"
@@ -242,6 +243,7 @@ RootAssembly, 6, -12.5
} // namespace
// C-DUP-002
// C-MODEL-002
TEST(InpDomainMapping, MapsEverySupportedKeywordAndLegacyDeck) {
auto result = MapText("supported-inventory", SupportedInventoryDeck(true));
ASSERT_TRUE(result.HasValue());
@@ -254,17 +256,23 @@ TEST(InpDomainMapping, MapsEverySupportedKeywordAndLegacyDeck) {
EXPECT_EQ(domain.Nodes()[1].source_id.source_label_text, "0002");
EXPECT_DOUBLE_EQ(domain.Nodes()[1].coordinates[0], 2.0);
ASSERT_EQ(domain.Elements().size(), 1U);
EXPECT_EQ(domain.Elements()[0].source_id.source_label_text, "0007");
EXPECT_EQ(domain.Elements()[0].node_indices[0], 0U);
EXPECT_EQ(domain.Elements()[0].node_indices[1], 1U);
ASSERT_EQ(domain.Elements().Size(), 1U);
const fesa::ElementDefinition& element = domain.Elements()[0U];
EXPECT_EQ(element.Kind(), fesa::ElementDefinitionKind::kEulerBeam3D);
EXPECT_EQ(element.SourceId().source_label_text, "0007");
EXPECT_EQ(element.SourceElementType(), "B33");
EXPECT_EQ(element.NodeIndices(), (std::vector<fesa::EntityIndex>{0U, 1U}));
EXPECT_EQ(&element, &domain.BeamElements()[0U]);
ASSERT_EQ(domain.Materials().size(), 1U);
EXPECT_EQ(domain.Materials()[0].name, "Steel");
EXPECT_DOUBLE_EQ(domain.Materials()[0].youngs_modulus, 210000.0);
EXPECT_DOUBLE_EQ(domain.Materials()[0].poisson_ratio, 0.75);
ASSERT_EQ(domain.Materials().Size(), 1U);
EXPECT_EQ(domain.Materials()[0U].Kind(),
fesa::MaterialKind::kIsotropicLinearElastic);
EXPECT_EQ(domain.LinearElasticMaterials()[0U].name, "Steel");
EXPECT_DOUBLE_EQ(domain.LinearElasticMaterials()[0U].youngs_modulus,
210000.0);
EXPECT_DOUBLE_EQ(domain.LinearElasticMaterials()[0U].poisson_ratio, 0.75);
ASSERT_EQ(domain.Sections().size(), 1U);
ASSERT_EQ(domain.Sections().Size(), 1U);
const auto& section = domain.Sections()[0];
EXPECT_DOUBLE_EQ(section.area, 2.0);
EXPECT_DOUBLE_EQ(section.i11, 3.0);
@@ -274,8 +282,8 @@ TEST(InpDomainMapping, MapsEverySupportedKeywordAndLegacyDeck) {
EXPECT_EQ(section.first_axis, (std::array<double, 3>{0.0, 1.0, 0.0}));
EXPECT_EQ(section.section_points,
(std::vector<std::array<double, 2>>{{-0.5, 0.25}, {0.5, -0.25}}));
EXPECT_EQ(domain.Elements()[0].material_index, 0U);
EXPECT_EQ(domain.Elements()[0].section_index, 0U);
EXPECT_EQ(domain.BeamElements()[0U].material_index, 0U);
EXPECT_EQ(domain.BeamElements()[0U].section_index, 0U);
ASSERT_EQ(domain.Steps().size(), 1U);
const auto& step = domain.Steps()[0];
@@ -305,9 +313,9 @@ TEST(InpDomainMapping, MapsEverySupportedKeywordAndLegacyDeck) {
auto legacy = fesa::AbaqusDomainMapper{}.Map(parsed_legacy.Value());
ASSERT_TRUE(legacy.HasValue());
EXPECT_EQ(legacy.Value().Nodes().size(), 11U);
EXPECT_EQ(legacy.Value().Elements().size(), 10U);
EXPECT_EQ(legacy.Value().Materials().size(), 1U);
EXPECT_EQ(legacy.Value().Sections().size(), 1U);
EXPECT_EQ(legacy.Value().Elements().Size(), 10U);
EXPECT_EQ(legacy.Value().Materials().Size(), 1U);
EXPECT_EQ(legacy.Value().Sections().Size(), 1U);
EXPECT_EQ(legacy.Value().Steps().size(), 1U);
EXPECT_EQ(legacy.Value().Warnings().size(), 7U);
EXPECT_EQ(ReadExactBytes(legacy_path), bytes_before);
@@ -367,12 +375,12 @@ OnlySecond, 2, 5.
EXPECT_EQ(domain.Nodes()[3].source_id.instance_name, "Second");
EXPECT_EQ(domain.Nodes()[3].source_id.source_label, 20);
ASSERT_EQ(domain.Elements().size(), 2U);
EXPECT_EQ(domain.Elements()[0].source_id.instance_name, "First");
EXPECT_EQ(domain.Elements()[0].node_indices,
ASSERT_EQ(domain.BeamElements().Size(), 2U);
EXPECT_EQ(domain.BeamElements()[0].source_id.instance_name, "First");
EXPECT_EQ(domain.BeamElements()[0].node_indices,
(std::array<fesa::EntityIndex, 2>{0U, 1U}));
EXPECT_EQ(domain.Elements()[1].source_id.instance_name, "Second");
EXPECT_EQ(domain.Elements()[1].node_indices,
EXPECT_EQ(domain.BeamElements()[1].source_id.instance_name, "Second");
EXPECT_EQ(domain.BeamElements()[1].node_indices,
(std::array<fesa::EntityIndex, 2>{2U, 3U}));
ASSERT_EQ(domain.NodeSets().size(), 3U);
@@ -525,12 +533,12 @@ TEST(InpDomainMapping, NoOpAllowlistWarnsWithoutSemanticEffect) {
}
EXPECT_EQ(with_no_ops.Value().Nodes().size(), plain.Value().Nodes().size());
EXPECT_EQ(with_no_ops.Value().Elements().size(),
plain.Value().Elements().size());
EXPECT_EQ(with_no_ops.Value().Materials().size(),
plain.Value().Materials().size());
EXPECT_EQ(with_no_ops.Value().Sections().size(),
plain.Value().Sections().size());
EXPECT_EQ(with_no_ops.Value().Elements().Size(),
plain.Value().Elements().Size());
EXPECT_EQ(with_no_ops.Value().Materials().Size(),
plain.Value().Materials().Size());
EXPECT_EQ(with_no_ops.Value().Sections().Size(),
plain.Value().Sections().Size());
EXPECT_EQ(with_no_ops.Value().NodeSets().size(),
plain.Value().NodeSets().size());
EXPECT_EQ(with_no_ops.Value().ElementSets().size(),
@@ -543,13 +551,20 @@ TEST(InpDomainMapping, NoOpAllowlistWarnsWithoutSemanticEffect) {
}
// MITC4-MAP-001
// C-MODEL-002
TEST(InpDomainMapping, MapsS4AndS4rThroughOneMitc4Identity) {
auto result = MapText("mitc4-map-001", ShellDeck());
ASSERT_TRUE(result.HasValue());
const fesa::Domain& domain = result.Value();
EXPECT_TRUE(domain.Elements().empty());
ASSERT_EQ(domain.ShellElements().size(), 4U);
EXPECT_TRUE(domain.BeamElements().Empty());
ASSERT_EQ(domain.Elements().Size(), 4U);
EXPECT_EQ(domain.Elements()[0U].Kind(),
fesa::ElementDefinitionKind::kMitc4Shell);
EXPECT_EQ(domain.Elements()[0U].SourceElementType(), "S4");
EXPECT_EQ(domain.Elements()[1U].SourceElementType(), "S4R");
EXPECT_EQ(&domain.Elements()[0U], &domain.ShellElements()[0U]);
ASSERT_EQ(domain.ShellElements().Size(), 4U);
EXPECT_EQ(domain.ShellElements()[0].source_id.instance_name, "First");
EXPECT_EQ(domain.ShellElements()[0].source_id.source_label_text, "0010");
EXPECT_EQ(domain.ShellElements()[0].source_type,
@@ -573,7 +588,7 @@ TEST(InpDomainMapping, MapsS4AndS4rThroughOneMitc4Identity) {
EXPECT_EQ(domain.ShellElements()[3].source_id.instance_name, "Second");
EXPECT_EQ(fesa::kMitc4InternalFormulation, std::string_view{"FESA-MITC4"});
ASSERT_EQ(domain.ShellSections().size(), 2U);
ASSERT_EQ(domain.ShellSections().Size(), 2U);
EXPECT_EQ(domain.ShellSections()[0].name, "ShellS4");
EXPECT_DOUBLE_EQ(domain.ShellSections()[0].thickness, 0.1);
EXPECT_EQ(domain.ShellSections()[0].material_index, 0U);