feat(cpp-object-oriented-modular-refactoring): step 4 - model-element-google-style
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#include "fesa/analysis/analysis_model.hpp"
|
||||
#include "fesa/assembly/parallel_for.hpp"
|
||||
#include "fesa/assembly/sparse_assembler.hpp"
|
||||
#include "fesa/elements/mitc4_shell.hpp"
|
||||
#include "fesa/elements/mitc4_shell.h"
|
||||
#include "fesa/fem/dof_manager.hpp"
|
||||
#include "fesa/model/domain.hpp"
|
||||
#include "fesa/model/domain.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace {
|
||||
fesa::ModelDefinition makeDefinition() {
|
||||
const std::filesystem::path source{"models/sparse-assembly.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"}, {2.0, 0.0, 0.0}, {source, 11U}},
|
||||
@@ -50,8 +50,8 @@ fesa::ModelDefinition makeShellDefinition(
|
||||
const bool twoElements = false) {
|
||||
const std::filesystem::path source{"models/shell-sparse-assembly.inp"};
|
||||
fesa::ModelDefinition definition{};
|
||||
definition.sourcePath = source;
|
||||
definition.sourceContentIdentity = "fnv1a64:fedcba9876543210";
|
||||
definition.source_path = source;
|
||||
definition.source_content_identity = "fnv1a64:fedcba9876543210";
|
||||
if (twoElements) {
|
||||
definition.nodes = {
|
||||
{{"Shell-1", 1, "1"}, {0.0, 0.0, 0.0}, {source, 10U}},
|
||||
@@ -61,13 +61,13 @@ fesa::ModelDefinition makeShellDefinition(
|
||||
{{"Shell-1", 5, "5"}, {1.0, 1.0, 0.0}, {source, 14U}},
|
||||
{{"Shell-1", 6, "6"}, {2.0, 1.0, 0.0}, {source, 15U}}};
|
||||
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},
|
||||
{0.0, 1.0, 0.0}});
|
||||
}
|
||||
definition.shellElements = {
|
||||
definition.shell_elements = {
|
||||
{{"Shell-1", 10, "10"}, sourceType, {0U, 1U, 4U, 3U},
|
||||
0U, 0U, {source, 40U}},
|
||||
{{"Shell-1", 20, "20"}, sourceType, {1U, 2U, 5U, 4U},
|
||||
@@ -80,19 +80,19 @@ fesa::ModelDefinition makeShellDefinition(
|
||||
{{"Shell-1", 3, "3"}, {0.0, 1.0, 1.0}, {source, 12U}},
|
||||
{{"Shell-1", 4, "4"}, {0.0, 0.0, 1.0}, {source, 13U}}};
|
||||
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),
|
||||
{1.0, 0.0, 0.0},
|
||||
{0.0, 1.0, 0.0},
|
||||
{0.0, 0.0, 1.0}});
|
||||
}
|
||||
definition.shellElements = {{
|
||||
definition.shell_elements = {{
|
||||
{"Shell-1", 10, "10"}, sourceType, {0U, 1U, 2U, 3U},
|
||||
0U, 0U, {source, 40U}}};
|
||||
}
|
||||
definition.materials = {
|
||||
{"Material", 120.0, 0.25, {source, 20U}}};
|
||||
definition.shellSections = {
|
||||
definition.shell_sections = {
|
||||
{"ShellSection", 0.2, 0U, {source, 30U}}};
|
||||
definition.steps = {{
|
||||
"Step-1", {}, {}, 0.1, 1.0, 0.01, 1.0, {source, 50U}}};
|
||||
@@ -102,30 +102,30 @@ fesa::ModelDefinition makeShellDefinition(
|
||||
fesa::Result<fesa::Mitc4Stiffness> directShellStiffness(
|
||||
const fesa::Domain& domain,
|
||||
const fesa::EntityIndex elementIndex) {
|
||||
const auto& definition = domain.shellElements().at(elementIndex);
|
||||
const auto& definition = domain.ShellElements().at(elementIndex);
|
||||
std::array<const fesa::Node*, 4> nodes{};
|
||||
std::array<std::array<double, 3>, 4> directors{};
|
||||
for (std::size_t node = 0U; node < definition.nodeIndices.size(); ++node) {
|
||||
const fesa::EntityIndex nodeIndex = definition.nodeIndices[node];
|
||||
nodes[node] = &domain.nodes().at(nodeIndex);
|
||||
directors[node] = domain.shellNodeInitialFrames().at(nodeIndex).director;
|
||||
for (std::size_t node = 0U; node < definition.node_indices.size(); ++node) {
|
||||
const fesa::EntityIndex nodeIndex = definition.node_indices[node];
|
||||
nodes[node] = &domain.Nodes().at(nodeIndex);
|
||||
directors[node] = domain.ShellNodeInitialFrames().at(nodeIndex).director;
|
||||
}
|
||||
auto shell = fesa::Mitc4Shell::create(
|
||||
auto shell = fesa::Mitc4Shell::Create(
|
||||
nodes,
|
||||
directors,
|
||||
domain.shellSections().at(definition.sectionIndex),
|
||||
domain.materials().at(definition.materialIndex));
|
||||
domain.ShellSections().at(definition.section_index),
|
||||
domain.Materials().at(definition.material_index));
|
||||
if (!shell.HasValue()) {
|
||||
return fesa::Result<fesa::Mitc4Stiffness>::Failure(shell.GetStatus());
|
||||
}
|
||||
return shell.Value().stiffness();
|
||||
return shell.Value().Stiffness();
|
||||
}
|
||||
|
||||
fesa::Result<fesa::SparseMatrix> assembleShell(
|
||||
const fesa::ShellSourceElementType sourceType,
|
||||
const fesa::ParallelFor& parallelFor,
|
||||
const bool twoElements = false) {
|
||||
auto domain = fesa::Domain::create(
|
||||
auto domain = fesa::Domain::Create(
|
||||
makeShellDefinition(sourceType, twoElements));
|
||||
if (!domain.HasValue()) {
|
||||
return fesa::Result<fesa::SparseMatrix>::Failure(domain.GetStatus());
|
||||
@@ -198,7 +198,7 @@ void expectByteIdentical(
|
||||
}
|
||||
|
||||
TEST(SparseAssembly, SerialTbbAndRepeatedRunsAreByteIdentical) {
|
||||
auto domainResult = fesa::Domain::create(makeDefinition());
|
||||
auto domainResult = fesa::Domain::Create(makeDefinition());
|
||||
ASSERT_TRUE(domainResult.HasValue());
|
||||
auto modelResult = fesa::AnalysisModel::create(domainResult.Value());
|
||||
ASSERT_TRUE(modelResult.HasValue());
|
||||
@@ -257,8 +257,8 @@ TEST(SparseAssembly, SerialTbbAndRepeatedRunsAreByteIdentical) {
|
||||
TEST(
|
||||
SparseAssembly,
|
||||
AssemblesFourNodeTwentyFourDofKernelAndPreservesDiagonalSlots) {
|
||||
auto domain = fesa::Domain::create(
|
||||
makeShellDefinition(fesa::ShellSourceElementType::s4));
|
||||
auto domain = fesa::Domain::Create(
|
||||
makeShellDefinition(fesa::ShellSourceElementType::kS4));
|
||||
ASSERT_TRUE(domain.HasValue());
|
||||
auto model = fesa::AnalysisModel::create(domain.Value());
|
||||
ASSERT_TRUE(model.HasValue());
|
||||
@@ -290,7 +290,7 @@ TEST(
|
||||
for (std::size_t column = 0U; column < 24U; ++column) {
|
||||
EXPECT_DOUBLE_EQ(
|
||||
entry(assembled.Value(), row, column),
|
||||
expected.Value().stabilizedGlobal24(row, column));
|
||||
expected.Value().stabilized_global24(row, column));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -300,11 +300,11 @@ TEST(SparseAssembly, ShellSerialTbbReverseAndRepeatedRunsAreByteIdentical) {
|
||||
fesa::TbbParallelFor tbbExecutor;
|
||||
ReverseParallelFor reverseExecutor;
|
||||
auto serial = assembleShell(
|
||||
fesa::ShellSourceElementType::s4, serialExecutor, true);
|
||||
fesa::ShellSourceElementType::kS4, serialExecutor, true);
|
||||
auto tbb = assembleShell(
|
||||
fesa::ShellSourceElementType::s4, tbbExecutor, true);
|
||||
fesa::ShellSourceElementType::kS4, tbbExecutor, true);
|
||||
auto reversed = assembleShell(
|
||||
fesa::ShellSourceElementType::s4, reverseExecutor, true);
|
||||
fesa::ShellSourceElementType::kS4, reverseExecutor, true);
|
||||
ASSERT_TRUE(serial.HasValue());
|
||||
ASSERT_TRUE(tbb.HasValue());
|
||||
ASSERT_TRUE(reversed.HasValue());
|
||||
@@ -315,7 +315,7 @@ TEST(SparseAssembly, ShellSerialTbbReverseAndRepeatedRunsAreByteIdentical) {
|
||||
expectByteIdentical(reversed.Value(), serial.Value());
|
||||
for (std::size_t repetition = 0U; repetition < 8U; ++repetition) {
|
||||
auto repeated = assembleShell(
|
||||
fesa::ShellSourceElementType::s4, tbbExecutor, true);
|
||||
fesa::ShellSourceElementType::kS4, tbbExecutor, true);
|
||||
ASSERT_TRUE(repeated.HasValue());
|
||||
expectByteIdentical(repeated.Value(), serial.Value());
|
||||
}
|
||||
@@ -324,9 +324,9 @@ TEST(SparseAssembly, ShellSerialTbbReverseAndRepeatedRunsAreByteIdentical) {
|
||||
TEST(SparseAssembly, S4AndS4rSemanticFixturesAssembleIdenticalStiffness) {
|
||||
fesa::SerialParallelFor serialExecutor;
|
||||
auto s4 = assembleShell(
|
||||
fesa::ShellSourceElementType::s4, serialExecutor);
|
||||
fesa::ShellSourceElementType::kS4, serialExecutor);
|
||||
auto s4r = assembleShell(
|
||||
fesa::ShellSourceElementType::s4r, serialExecutor);
|
||||
fesa::ShellSourceElementType::kS4r, serialExecutor);
|
||||
ASSERT_TRUE(s4.HasValue());
|
||||
ASSERT_TRUE(s4r.HasValue());
|
||||
EXPECT_TRUE(std::any_of(
|
||||
|
||||
Reference in New Issue
Block a user