feat(cpp-object-oriented-modular-refactoring): step 4 - model-element-google-style
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
#include "fesa/assembly/parallel_for.hpp"
|
||||
#include "fesa/assembly/sparse_assembler.hpp"
|
||||
#include "fesa/fem/dof_manager.hpp"
|
||||
#include "fesa/model/domain.hpp"
|
||||
#include "fesa/model/domain.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
@@ -51,8 +51,8 @@ fesa::ModelDefinition makeDefinition(
|
||||
const bool nonzeroPrescription = true) {
|
||||
const std::filesystem::path source{"models/result-recovery.inp"};
|
||||
fesa::ModelDefinition definition{};
|
||||
definition.sourcePath = source;
|
||||
definition.sourceContentIdentity = "fnv1a64:0123456789abcdef";
|
||||
definition.source_path = source;
|
||||
definition.source_content_identity = "fnv1a64:0123456789abcdef";
|
||||
definition.nodes = {
|
||||
{{"Beam-1", 1, "1"}, {0.0, 0.0, 0.0}, {source, 10U}},
|
||||
{{"Beam-1", 2, "2"}, {kLength, 0.0, 0.0}, {source, 11U}}};
|
||||
@@ -110,7 +110,7 @@ RecoveryFixture makeFixture(
|
||||
const bool reverseSecond = false,
|
||||
const bool sectionJump = false,
|
||||
const bool nonzeroPrescription = true) {
|
||||
auto domainResult = fesa::Domain::create(makeDefinition(
|
||||
auto domainResult = fesa::Domain::Create(makeDefinition(
|
||||
twoElements,
|
||||
std::move(sectionPoints),
|
||||
std::move(loads),
|
||||
@@ -158,8 +158,8 @@ fesa::ModelDefinition makeShellDefinition(
|
||||
std::vector<fesa::NodalLoad> loads = {}) {
|
||||
const std::filesystem::path source{"models/shell-result-recovery.inp"};
|
||||
fesa::ModelDefinition definition{};
|
||||
definition.sourcePath = source;
|
||||
definition.sourceContentIdentity = "fnv1a64:fedcba9876543210";
|
||||
definition.source_path = source;
|
||||
definition.source_content_identity = "fnv1a64:fedcba9876543210";
|
||||
definition.nodes = {
|
||||
{{"Shell-1", 1, "1"}, {-1.0, -1.0, 0.0}, {source, 10U}},
|
||||
{{"Shell-1", 2, "2"}, {1.0, -1.0, 0.0}, {source, 11U}},
|
||||
@@ -175,26 +175,26 @@ fesa::ModelDefinition makeShellDefinition(
|
||||
}
|
||||
definition.materials = {
|
||||
{"Material", 120.0, 0.25, {source, 20U}}};
|
||||
definition.shellSections = {
|
||||
definition.shell_sections = {
|
||||
{"ShellSection", 2.0, 0U, {source, 30U}}};
|
||||
definition.shellElements = {{
|
||||
definition.shell_elements = {{
|
||||
{"Shell-1", 10, "10"},
|
||||
fesa::ShellSourceElementType::s4,
|
||||
fesa::ShellSourceElementType::kS4,
|
||||
{0U, 1U, twoElements ? 4U : 3U, twoElements ? 3U : 2U},
|
||||
0U,
|
||||
0U,
|
||||
{source, 40U}}};
|
||||
if (twoElements) {
|
||||
definition.shellElements.push_back({
|
||||
definition.shell_elements.push_back({
|
||||
{"Shell-1", 20, "20"},
|
||||
fesa::ShellSourceElementType::s4r,
|
||||
fesa::ShellSourceElementType::kS4r,
|
||||
{1U, 2U, 5U, 4U},
|
||||
0U,
|
||||
0U,
|
||||
{source, 41U}});
|
||||
}
|
||||
for (std::size_t node = 0U; node < definition.nodes.size(); ++node) {
|
||||
definition.shellNodeInitialFrames.push_back({
|
||||
definition.shell_node_initial_frames.push_back({
|
||||
static_cast<fesa::EntityIndex>(node),
|
||||
{0.0, 0.0, 1.0},
|
||||
{1.0, 0.0, 0.0},
|
||||
@@ -206,7 +206,7 @@ fesa::ModelDefinition makeShellDefinition(
|
||||
for (std::size_t node = 0U; node < definition.nodes.size(); ++node) {
|
||||
allNodes.push_back(static_cast<fesa::EntityIndex>(node));
|
||||
}
|
||||
definition.nodeSets.push_back(
|
||||
definition.node_sets.push_back(
|
||||
{"All", {}, std::move(allNodes), {source, 50U}});
|
||||
}
|
||||
definition.steps = {{
|
||||
@@ -225,7 +225,7 @@ fesa::ModelDefinition makeShellDefinition(
|
||||
}
|
||||
|
||||
ShellRecoveryFixture makeShellFixture(fesa::ModelDefinition definition) {
|
||||
auto domainResult = fesa::Domain::create(std::move(definition));
|
||||
auto domainResult = fesa::Domain::Create(std::move(definition));
|
||||
if (!domainResult.HasValue()) {
|
||||
throw std::runtime_error{
|
||||
"Shell recovery fixture Domain construction failed."};
|
||||
@@ -272,10 +272,10 @@ fesa::AnalysisState makeShellPhysicalState(
|
||||
auto state = fesa::AnalysisState::create(
|
||||
*fixture.dofs, {"Step-1", 0U});
|
||||
for (std::size_t node = 0U;
|
||||
node < fixture.domain->nodes().size();
|
||||
node < fixture.domain->Nodes().size();
|
||||
++node) {
|
||||
const double x = fixture.domain->nodes()[node].coordinates[0U];
|
||||
const double y = fixture.domain->nodes()[node].coordinates[1U];
|
||||
const double x = fixture.domain->Nodes()[node].coordinates[0U];
|
||||
const double y = fixture.domain->Nodes()[node].coordinates[1U];
|
||||
const std::size_t offset = 6U * node;
|
||||
state.displacement()[offset] =
|
||||
generalized[0U] * x + 0.5 * generalized[2U] * y;
|
||||
@@ -345,19 +345,19 @@ void expectScaledNear(
|
||||
|
||||
std::vector<fesa::EndpointResultRow> makeStationRows(
|
||||
const RecoveryFixture& fixture) {
|
||||
const auto& nodes = fixture.domain->nodes();
|
||||
const auto& elements = fixture.domain->elements();
|
||||
const auto& nodes = fixture.domain->Nodes();
|
||||
const auto& elements = fixture.domain->Elements();
|
||||
return {
|
||||
{0U, 0, nodes[elements[0U].nodeIndices[0U]].sourceId,
|
||||
{0U, 0, nodes[elements[0U].node_indices[0U]].source_id,
|
||||
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
|
||||
{1.0, 2.0, 3.0, 4.0}},
|
||||
{0U, 1, nodes[elements[0U].nodeIndices[1U]].sourceId,
|
||||
{0U, 1, nodes[elements[0U].node_indices[1U]].source_id,
|
||||
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
|
||||
{5.0, 6.0, 7.0, 8.0}},
|
||||
{1U, 0, nodes[elements[1U].nodeIndices[0U]].sourceId,
|
||||
{1U, 0, nodes[elements[1U].node_indices[0U]].source_id,
|
||||
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
|
||||
{5.0, 6.0, 7.0, 8.0}},
|
||||
{1U, 1, nodes[elements[1U].nodeIndices[1U]].sourceId,
|
||||
{1U, 1, nodes[elements[1U].node_indices[1U]].source_id,
|
||||
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
|
||||
{9.0, 10.0, 11.0, 12.0}}};
|
||||
}
|
||||
@@ -639,10 +639,10 @@ TEST(ResultRecovery, RecoversShellRowsInStableElementAndGpOrder) {
|
||||
auto state = fesa::AnalysisState::create(
|
||||
*fixture.dofs, {"Step-1", 0U});
|
||||
for (std::size_t node = 0U;
|
||||
node < fixture.domain->nodes().size();
|
||||
node < fixture.domain->Nodes().size();
|
||||
++node) {
|
||||
const double x = fixture.domain->nodes()[node].coordinates[0U];
|
||||
const double y = fixture.domain->nodes()[node].coordinates[1U];
|
||||
const double x = fixture.domain->Nodes()[node].coordinates[0U];
|
||||
const double y = fixture.domain->Nodes()[node].coordinates[1U];
|
||||
state.displacement()[node * 6U] = 0.1 * x + 0.1 * y;
|
||||
state.displacement()[node * 6U + 1U] = -0.05 * y + 0.1 * x;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user