feat(domain-and-input-skeleton): step 0 — semantic-domain-and-origin-types
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
#include <fesa/model/domain.hpp>
|
||||
|
||||
#include <span>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace {
|
||||
|
||||
static_assert(std::is_same_v<
|
||||
decltype(std::declval<const fesa::Domain&>().nodes()),
|
||||
std::span<const fesa::Node>>);
|
||||
static_assert(std::is_same_v<
|
||||
decltype(std::declval<const fesa::Domain&>().node(
|
||||
std::declval<fesa::NodeId>())),
|
||||
const fesa::Node&>);
|
||||
|
||||
TEST(EntityOrigin, UsesEmptyScopeNamesForFlatMeshEntities) {
|
||||
const fesa::EntityOrigin origin{"", "", 17};
|
||||
|
||||
EXPECT_TRUE(origin.part_name.empty());
|
||||
EXPECT_TRUE(origin.instance_name.empty());
|
||||
EXPECT_EQ(origin.local_label, 17);
|
||||
}
|
||||
|
||||
TEST(EntityOrigin, FindsHierarchicalNodeByCompositeOrigin) {
|
||||
const fesa::Node node{
|
||||
fesa::NodeId{0},
|
||||
fesa::EntityOrigin{"BeamPart", "Beam-1", 101},
|
||||
fesa::Vec3{1.0, 2.0, 3.0},
|
||||
};
|
||||
const fesa::Domain domain{
|
||||
std::vector<fesa::Node>{node},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
fesa::StepDefinition{"Load", {}, {}},
|
||||
};
|
||||
|
||||
const fesa::EntityOrigin lookup{"BeamPart", "Beam-1", 101};
|
||||
const fesa::Node& found_by_origin = domain.node(lookup);
|
||||
const fesa::Node& found_by_id = domain.node(fesa::NodeId{0});
|
||||
|
||||
EXPECT_EQ(&found_by_origin, &domain.nodes().front());
|
||||
EXPECT_EQ(&found_by_id, &domain.nodes().front());
|
||||
EXPECT_EQ(found_by_origin.origin.part_name, "BeamPart");
|
||||
EXPECT_EQ(found_by_origin.origin.instance_name, "Beam-1");
|
||||
EXPECT_EQ(found_by_origin.origin.local_label, 101);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user