feat: add domain model foundation
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#include "fesa/core/BoundaryCondition.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
int require(bool condition) {
|
||||
return condition ? 0 : 1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int run_boundary_condition_tests() {
|
||||
const fesa::core::BoundaryCondition condition{1, fesa::core::Dof::UR3, 0.25};
|
||||
|
||||
if (const int result = require(condition.nodeId() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(condition.dof() == fesa::core::Dof::UR3); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(condition.value() == 0.25); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
int run_boundary_condition_tests();
|
||||
int run_domain_storage_tests();
|
||||
int run_element_definition_tests();
|
||||
int run_load_definition_tests();
|
||||
int run_material_definition_tests();
|
||||
int run_model_types_tests();
|
||||
int run_node_tests();
|
||||
int run_property_definition_tests();
|
||||
int run_step_definition_tests();
|
||||
|
||||
int main() {
|
||||
if (const int result = run_model_types_tests(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = run_node_tests(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = run_element_definition_tests(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = run_material_definition_tests(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = run_property_definition_tests(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = run_boundary_condition_tests(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = run_load_definition_tests(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = run_step_definition_tests(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = run_domain_storage_tests(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,655 @@
|
||||
#include "fesa/core/BoundaryCondition.hpp"
|
||||
#include "fesa/core/Domain.hpp"
|
||||
#include "fesa/core/ElementDefinition.hpp"
|
||||
#include "fesa/core/LoadDefinition.hpp"
|
||||
#include "fesa/core/MaterialDefinition.hpp"
|
||||
#include "fesa/core/Node.hpp"
|
||||
#include "fesa/core/PropertyDefinition.hpp"
|
||||
#include "fesa/core/StepDefinition.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
|
||||
namespace {
|
||||
|
||||
int require(bool condition) {
|
||||
return condition ? 0 : 1;
|
||||
}
|
||||
|
||||
template <typename Exception, typename Function>
|
||||
int require_throws(Function&& function) {
|
||||
try {
|
||||
function();
|
||||
} catch (const Exception&) {
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int add_and_retrieve_node_by_id() {
|
||||
fesa::core::Domain domain;
|
||||
|
||||
domain.addNode(fesa::core::Node{10, 1.0, 2.0, 3.0});
|
||||
|
||||
if (const int result = require(domain.nodeCount() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const fesa::core::Node* found = domain.findNode(10);
|
||||
if (const int result = require(found != nullptr); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(found->id() == 10); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(found->x() == 1.0); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(found->y() == 2.0); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(found->z() == 3.0); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const fesa::core::Node& direct = domain.node(10);
|
||||
if (const int result = require(direct.id() == 10); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int missing_node_lookup_contracts() {
|
||||
const fesa::core::Domain domain;
|
||||
|
||||
if (const int result = require(domain.findNode(99) == nullptr); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return require_throws<std::out_of_range>([&domain]() {
|
||||
(void)domain.node(99);
|
||||
});
|
||||
}
|
||||
|
||||
int duplicate_node_id_throws() {
|
||||
fesa::core::Domain domain;
|
||||
domain.addNode(fesa::core::Node{10, 0.0, 0.0, 0.0});
|
||||
|
||||
return require_throws<std::invalid_argument>([&domain]() {
|
||||
domain.addNode(fesa::core::Node{10, 1.0, 0.0, 0.0});
|
||||
});
|
||||
}
|
||||
|
||||
void add_four_nodes(fesa::core::Domain& domain) {
|
||||
domain.addNode(fesa::core::Node{1, 0.0, 0.0, 0.0});
|
||||
domain.addNode(fesa::core::Node{2, 1.0, 0.0, 0.0});
|
||||
domain.addNode(fesa::core::Node{3, 1.0, 1.0, 0.0});
|
||||
domain.addNode(fesa::core::Node{4, 0.0, 1.0, 0.0});
|
||||
}
|
||||
|
||||
int add_and_retrieve_element_by_id() {
|
||||
fesa::core::Domain domain;
|
||||
add_four_nodes(domain);
|
||||
|
||||
domain.addElement(fesa::core::ElementDefinition{
|
||||
100,
|
||||
fesa::core::ElementType::Mitc4,
|
||||
{1, 2, 3, 4},
|
||||
500});
|
||||
|
||||
if (const int result = require(domain.elementCount() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const fesa::core::ElementDefinition* found = domain.findElement(100);
|
||||
if (const int result = require(found != nullptr); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(found->id() == 100); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(found->type() == fesa::core::ElementType::Mitc4); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(found->propertyId() == 500); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(found->connectivity()[0] == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(found->connectivity()[1] == 2); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(found->connectivity()[2] == 3); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(found->connectivity()[3] == 4); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const fesa::core::ElementDefinition& direct = domain.element(100);
|
||||
return require(direct.id() == 100);
|
||||
}
|
||||
|
||||
int duplicate_element_id_throws() {
|
||||
fesa::core::Domain domain;
|
||||
add_four_nodes(domain);
|
||||
domain.addElement(fesa::core::ElementDefinition{
|
||||
100,
|
||||
fesa::core::ElementType::Mitc4,
|
||||
{1, 2, 3, 4},
|
||||
500});
|
||||
|
||||
return require_throws<std::invalid_argument>([&domain]() {
|
||||
domain.addElement(fesa::core::ElementDefinition{
|
||||
100,
|
||||
fesa::core::ElementType::Mitc4,
|
||||
{1, 2, 3, 4},
|
||||
500});
|
||||
});
|
||||
}
|
||||
|
||||
int element_referencing_missing_node_throws() {
|
||||
fesa::core::Domain domain;
|
||||
domain.addNode(fesa::core::Node{1, 0.0, 0.0, 0.0});
|
||||
domain.addNode(fesa::core::Node{2, 1.0, 0.0, 0.0});
|
||||
domain.addNode(fesa::core::Node{3, 1.0, 1.0, 0.0});
|
||||
|
||||
return require_throws<std::invalid_argument>([&domain]() {
|
||||
domain.addElement(fesa::core::ElementDefinition{
|
||||
100,
|
||||
fesa::core::ElementType::Mitc4,
|
||||
{1, 2, 3, 4},
|
||||
500});
|
||||
});
|
||||
}
|
||||
|
||||
int missing_element_lookup_contracts() {
|
||||
const fesa::core::Domain domain;
|
||||
|
||||
if (const int result = require(domain.findElement(404) == nullptr); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return require_throws<std::out_of_range>([&domain]() {
|
||||
(void)domain.element(404);
|
||||
});
|
||||
}
|
||||
|
||||
void add_material_and_property(fesa::core::Domain& domain) {
|
||||
domain.addMaterial(fesa::core::LinearElasticMaterialDefinition{700, 210.0, 0.3});
|
||||
domain.addShellProperty(fesa::core::ShellPropertyDefinition{500, 700, 0.01});
|
||||
}
|
||||
|
||||
int add_and_retrieve_material_and_property() {
|
||||
fesa::core::Domain domain;
|
||||
|
||||
add_material_and_property(domain);
|
||||
|
||||
if (const int result = require(domain.materialCount() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(domain.shellPropertyCount() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const fesa::core::LinearElasticMaterialDefinition* material = domain.findMaterial(700);
|
||||
if (const int result = require(material != nullptr); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(material->youngModulus() == 210.0); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(material->poissonRatio() == 0.3); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const fesa::core::ShellPropertyDefinition* property = domain.findShellProperty(500);
|
||||
if (const int result = require(property != nullptr); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(property->materialId() == 700); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(property->thickness() == 0.01); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (const int result = require(domain.material(700).id() == 700); result != 0) {
|
||||
return result;
|
||||
}
|
||||
return require(domain.shellProperty(500).id() == 500);
|
||||
}
|
||||
|
||||
int duplicate_material_and_property_ids_throw() {
|
||||
fesa::core::Domain domain;
|
||||
add_material_and_property(domain);
|
||||
|
||||
if (const int result = require_throws<std::invalid_argument>([&domain]() {
|
||||
domain.addMaterial(fesa::core::LinearElasticMaterialDefinition{700, 100.0, 0.25});
|
||||
});
|
||||
result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return require_throws<std::invalid_argument>([&domain]() {
|
||||
domain.addShellProperty(fesa::core::ShellPropertyDefinition{500, 700, 0.02});
|
||||
});
|
||||
}
|
||||
|
||||
int shell_property_referencing_missing_material_throws() {
|
||||
fesa::core::Domain domain;
|
||||
|
||||
return require_throws<std::invalid_argument>([&domain]() {
|
||||
domain.addShellProperty(fesa::core::ShellPropertyDefinition{500, 700, 0.01});
|
||||
});
|
||||
}
|
||||
|
||||
int add_and_retrieve_sets() {
|
||||
fesa::core::Domain domain;
|
||||
add_four_nodes(domain);
|
||||
domain.addElement(fesa::core::ElementDefinition{
|
||||
100,
|
||||
fesa::core::ElementType::Mitc4,
|
||||
{1, 2, 3, 4},
|
||||
500});
|
||||
|
||||
domain.addNodeSet("left-edge", {1, 4});
|
||||
domain.addElementSet("shells", {100});
|
||||
|
||||
const auto* node_set = domain.findNodeSet("left-edge");
|
||||
if (const int result = require(node_set != nullptr); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(node_set->size() == 2); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require((*node_set)[0] == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require((*node_set)[1] == 4); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const auto* element_set = domain.findElementSet("shells");
|
||||
if (const int result = require(element_set != nullptr); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(element_set->size() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require((*element_set)[0] == 100); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (const int result = require(domain.nodeSetCount() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
return require(domain.elementSetCount() == 1);
|
||||
}
|
||||
|
||||
int duplicate_set_names_throw() {
|
||||
fesa::core::Domain domain;
|
||||
add_four_nodes(domain);
|
||||
domain.addElement(fesa::core::ElementDefinition{
|
||||
100,
|
||||
fesa::core::ElementType::Mitc4,
|
||||
{1, 2, 3, 4},
|
||||
500});
|
||||
domain.addNodeSet("left-edge", {1, 4});
|
||||
domain.addElementSet("shells", {100});
|
||||
|
||||
if (const int result = require_throws<std::invalid_argument>([&domain]() {
|
||||
domain.addNodeSet("left-edge", {1});
|
||||
});
|
||||
result != 0) {
|
||||
return result;
|
||||
}
|
||||
return require_throws<std::invalid_argument>([&domain]() {
|
||||
domain.addElementSet("shells", {100});
|
||||
});
|
||||
}
|
||||
|
||||
int sets_referencing_missing_ids_throw() {
|
||||
fesa::core::Domain domain;
|
||||
add_four_nodes(domain);
|
||||
domain.addElement(fesa::core::ElementDefinition{
|
||||
100,
|
||||
fesa::core::ElementType::Mitc4,
|
||||
{1, 2, 3, 4},
|
||||
500});
|
||||
|
||||
if (const int result = require_throws<std::invalid_argument>([&domain]() {
|
||||
domain.addNodeSet("bad-nodes", {1, 99});
|
||||
});
|
||||
result != 0) {
|
||||
return result;
|
||||
}
|
||||
return require_throws<std::invalid_argument>([&domain]() {
|
||||
domain.addElementSet("bad-elements", {100, 404});
|
||||
});
|
||||
}
|
||||
|
||||
int add_and_retrieve_boundary_condition() {
|
||||
fesa::core::Domain domain;
|
||||
domain.addNode(fesa::core::Node{1, 0.0, 0.0, 0.0});
|
||||
|
||||
const std::size_t index = domain.addBoundaryCondition(
|
||||
fesa::core::BoundaryCondition{1, fesa::core::Dof::U1, 0.0});
|
||||
|
||||
if (const int result = require(index == 0); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(domain.boundaryConditionCount() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const fesa::core::BoundaryCondition& condition = domain.boundaryCondition(index);
|
||||
if (const int result = require(condition.nodeId() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(condition.dof() == fesa::core::Dof::U1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
return require(condition.value() == 0.0);
|
||||
}
|
||||
|
||||
int add_and_retrieve_nodal_load() {
|
||||
fesa::core::Domain domain;
|
||||
domain.addNode(fesa::core::Node{1, 0.0, 0.0, 0.0});
|
||||
|
||||
const std::size_t index = domain.addNodalLoad(
|
||||
fesa::core::NodalLoadDefinition{1, fesa::core::Dof::U3, -100.0});
|
||||
|
||||
if (const int result = require(index == 0); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(domain.nodalLoadCount() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const fesa::core::NodalLoadDefinition& load = domain.nodalLoad(index);
|
||||
if (const int result = require(load.nodeId() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(load.dof() == fesa::core::Dof::U3); result != 0) {
|
||||
return result;
|
||||
}
|
||||
return require(load.value() == -100.0);
|
||||
}
|
||||
|
||||
int missing_node_boundary_condition_and_load_throw() {
|
||||
fesa::core::Domain domain;
|
||||
|
||||
if (const int result = require_throws<std::invalid_argument>([&domain]() {
|
||||
(void)domain.addBoundaryCondition(
|
||||
fesa::core::BoundaryCondition{99, fesa::core::Dof::U1, 0.0});
|
||||
});
|
||||
result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return require_throws<std::invalid_argument>([&domain]() {
|
||||
(void)domain.addNodalLoad(
|
||||
fesa::core::NodalLoadDefinition{99, fesa::core::Dof::U3, -100.0});
|
||||
});
|
||||
}
|
||||
|
||||
int add_and_retrieve_linear_static_step() {
|
||||
fesa::core::Domain domain;
|
||||
domain.addNode(fesa::core::Node{1, 0.0, 0.0, 0.0});
|
||||
const std::size_t bc = domain.addBoundaryCondition(
|
||||
fesa::core::BoundaryCondition{1, fesa::core::Dof::U1, 0.0});
|
||||
const std::size_t load = domain.addNodalLoad(
|
||||
fesa::core::NodalLoadDefinition{1, fesa::core::Dof::U3, -100.0});
|
||||
|
||||
domain.addStep(fesa::core::LinearStaticStepDefinition{1, "load-step", {bc}, {load}});
|
||||
|
||||
if (const int result = require(domain.stepCount() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const fesa::core::LinearStaticStepDefinition* found = domain.findStep(1);
|
||||
if (const int result = require(found != nullptr); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(found->id() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(found->name() == "load-step"); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(found->boundaryConditionIndices().size() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(found->boundaryConditionIndices()[0] == bc); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(found->loadIndices().size() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
return require(found->loadIndices()[0] == load);
|
||||
}
|
||||
|
||||
int duplicate_and_invalid_step_references_throw() {
|
||||
fesa::core::Domain domain;
|
||||
domain.addNode(fesa::core::Node{1, 0.0, 0.0, 0.0});
|
||||
const std::size_t bc = domain.addBoundaryCondition(
|
||||
fesa::core::BoundaryCondition{1, fesa::core::Dof::U1, 0.0});
|
||||
const std::size_t load = domain.addNodalLoad(
|
||||
fesa::core::NodalLoadDefinition{1, fesa::core::Dof::U3, -100.0});
|
||||
|
||||
domain.addStep(fesa::core::LinearStaticStepDefinition{1, "load-step", {bc}, {load}});
|
||||
|
||||
if (const int result = require_throws<std::invalid_argument>([&domain, bc, load]() {
|
||||
domain.addStep(fesa::core::LinearStaticStepDefinition{1, "duplicate", {bc}, {load}});
|
||||
});
|
||||
result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require_throws<std::invalid_argument>([&domain, load]() {
|
||||
domain.addStep(fesa::core::LinearStaticStepDefinition{2, "bad-bc", {99}, {load}});
|
||||
});
|
||||
result != 0) {
|
||||
return result;
|
||||
}
|
||||
return require_throws<std::invalid_argument>([&domain, bc]() {
|
||||
domain.addStep(fesa::core::LinearStaticStepDefinition{2, "bad-load", {bc}, {99}});
|
||||
});
|
||||
}
|
||||
|
||||
int const_domain_retrieval_returns_const_model_data() {
|
||||
fesa::core::Domain domain;
|
||||
add_four_nodes(domain);
|
||||
domain.addMaterial(fesa::core::LinearElasticMaterialDefinition{700, 210.0, 0.3});
|
||||
domain.addShellProperty(fesa::core::ShellPropertyDefinition{500, 700, 0.01});
|
||||
domain.addElement(fesa::core::ElementDefinition{
|
||||
100,
|
||||
fesa::core::ElementType::Mitc4,
|
||||
{1, 2, 3, 4},
|
||||
500});
|
||||
domain.addNodeSet("left-edge", {1, 4});
|
||||
domain.addElementSet("shells", {100});
|
||||
const std::size_t bc = domain.addBoundaryCondition(
|
||||
fesa::core::BoundaryCondition{1, fesa::core::Dof::U1, 0.0});
|
||||
const std::size_t load = domain.addNodalLoad(
|
||||
fesa::core::NodalLoadDefinition{1, fesa::core::Dof::U3, -100.0});
|
||||
domain.addStep(fesa::core::LinearStaticStepDefinition{1, "load-step", {bc}, {load}});
|
||||
|
||||
const fesa::core::Domain& const_domain = domain;
|
||||
|
||||
if (const int result = require((std::is_same<decltype(const_domain.node(1)), const fesa::core::Node&>::value));
|
||||
result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require((std::is_same<decltype(const_domain.element(100)), const fesa::core::ElementDefinition&>::value));
|
||||
result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require((std::is_same<decltype(const_domain.material(700)), const fesa::core::LinearElasticMaterialDefinition&>::value));
|
||||
result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require((std::is_same<decltype(const_domain.shellProperty(500)), const fesa::core::ShellPropertyDefinition&>::value));
|
||||
result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require((std::is_same<decltype(const_domain.nodeSet("left-edge")), const std::vector<fesa::core::NodeId>&>::value));
|
||||
result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require((std::is_same<decltype(const_domain.elementSet("shells")), const std::vector<fesa::core::ElementId>&>::value));
|
||||
result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require((std::is_same<decltype(const_domain.boundaryCondition(0)), const fesa::core::BoundaryCondition&>::value));
|
||||
result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require((std::is_same<decltype(const_domain.nodalLoad(0)), const fesa::core::NodalLoadDefinition&>::value));
|
||||
result != 0) {
|
||||
return result;
|
||||
}
|
||||
return require((std::is_same<decltype(const_domain.step(1)), const fesa::core::LinearStaticStepDefinition&>::value));
|
||||
}
|
||||
|
||||
int failed_inserts_do_not_mutate_counts() {
|
||||
fesa::core::Domain domain;
|
||||
add_four_nodes(domain);
|
||||
domain.addMaterial(fesa::core::LinearElasticMaterialDefinition{700, 210.0, 0.3});
|
||||
domain.addShellProperty(fesa::core::ShellPropertyDefinition{500, 700, 0.01});
|
||||
domain.addElement(fesa::core::ElementDefinition{
|
||||
100,
|
||||
fesa::core::ElementType::Mitc4,
|
||||
{1, 2, 3, 4},
|
||||
500});
|
||||
domain.addNodeSet("left-edge", {1, 4});
|
||||
domain.addElementSet("shells", {100});
|
||||
const std::size_t bc = domain.addBoundaryCondition(
|
||||
fesa::core::BoundaryCondition{1, fesa::core::Dof::U1, 0.0});
|
||||
const std::size_t load = domain.addNodalLoad(
|
||||
fesa::core::NodalLoadDefinition{1, fesa::core::Dof::U3, -100.0});
|
||||
domain.addStep(fesa::core::LinearStaticStepDefinition{1, "load-step", {bc}, {load}});
|
||||
|
||||
if (const int result = require_throws<std::invalid_argument>([&domain]() {
|
||||
domain.addElement(fesa::core::ElementDefinition{
|
||||
101,
|
||||
fesa::core::ElementType::Mitc4,
|
||||
{1, 2, 3, 99},
|
||||
500});
|
||||
});
|
||||
result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(domain.elementCount() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (const int result = require_throws<std::invalid_argument>([&domain]() {
|
||||
domain.addShellProperty(fesa::core::ShellPropertyDefinition{501, 404, 0.01});
|
||||
});
|
||||
result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(domain.shellPropertyCount() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (const int result = require_throws<std::invalid_argument>([&domain]() {
|
||||
domain.addNodeSet("bad-nodes", {1, 99});
|
||||
});
|
||||
result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(domain.nodeSetCount() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (const int result = require_throws<std::invalid_argument>([&domain]() {
|
||||
(void)domain.addBoundaryCondition(
|
||||
fesa::core::BoundaryCondition{99, fesa::core::Dof::U1, 0.0});
|
||||
});
|
||||
result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(domain.boundaryConditionCount() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (const int result = require_throws<std::invalid_argument>([&domain, bc]() {
|
||||
domain.addStep(fesa::core::LinearStaticStepDefinition{2, "bad-load", {bc}, {99}});
|
||||
});
|
||||
result != 0) {
|
||||
return result;
|
||||
}
|
||||
return require(domain.stepCount() == 1);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int run_domain_storage_tests() {
|
||||
if (const int result = add_and_retrieve_node_by_id(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = missing_node_lookup_contracts(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = duplicate_node_id_throws(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = add_and_retrieve_element_by_id(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = duplicate_element_id_throws(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = element_referencing_missing_node_throws(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = missing_element_lookup_contracts(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = add_and_retrieve_material_and_property(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = duplicate_material_and_property_ids_throw(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = shell_property_referencing_missing_material_throws(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = add_and_retrieve_sets(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = duplicate_set_names_throw(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = sets_referencing_missing_ids_throw(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = add_and_retrieve_boundary_condition(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = add_and_retrieve_nodal_load(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = missing_node_boundary_condition_and_load_throw(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = add_and_retrieve_linear_static_step(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = duplicate_and_invalid_step_references_throw(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = const_domain_retrieval_returns_const_model_data(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = failed_inserts_do_not_mutate_counts(); result != 0) {
|
||||
return result;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "fesa/core/ElementDefinition.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
int require(bool condition) {
|
||||
return condition ? 0 : 1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int run_element_definition_tests() {
|
||||
const fesa::core::ElementDefinition element{
|
||||
100,
|
||||
fesa::core::ElementType::Mitc4,
|
||||
{1, 2, 3, 4},
|
||||
500};
|
||||
|
||||
if (const int result = require(element.id() == 100); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(element.type() == fesa::core::ElementType::Mitc4); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(element.connectivity()[0] == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(element.connectivity()[1] == 2); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(element.connectivity()[2] == 3); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(element.connectivity()[3] == 4); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(element.propertyId() == 500); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#include "fesa/core/LoadDefinition.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
int require(bool condition) {
|
||||
return condition ? 0 : 1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int run_load_definition_tests() {
|
||||
const fesa::core::NodalLoadDefinition load{1, fesa::core::Dof::U3, -100.0};
|
||||
|
||||
if (const int result = require(load.nodeId() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(load.dof() == fesa::core::Dof::U3); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(load.value() == -100.0); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#include "fesa/core/MaterialDefinition.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
int require(bool condition) {
|
||||
return condition ? 0 : 1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int run_material_definition_tests() {
|
||||
const fesa::core::LinearElasticMaterialDefinition material{700, 210.0, 0.3};
|
||||
|
||||
if (const int result = require(material.id() == 700); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(material.youngModulus() == 210.0); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(material.poissonRatio() == 0.3); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#include "fesa/core/ModelTypes.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
|
||||
namespace {
|
||||
|
||||
int require(bool condition) {
|
||||
return condition ? 0 : 1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int run_model_types_tests() {
|
||||
using namespace fesa::core;
|
||||
|
||||
if (const int result = require(sizeof(Id) == 8); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(std::is_same<Id, std::int64_t>::value); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(kDofPerNode == 6); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(static_cast<int>(Dof::U1) == 0); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(static_cast<int>(Dof::U2) == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(static_cast<int>(Dof::U3) == 2); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(static_cast<int>(Dof::UR1) == 3); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(static_cast<int>(Dof::UR2) == 4); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(static_cast<int>(Dof::UR3) == 5); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "fesa/core/Node.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
int require(bool condition) {
|
||||
return condition ? 0 : 1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int run_node_tests() {
|
||||
const fesa::core::Node node{42, 1.0, 2.0, 3.0};
|
||||
|
||||
if (const int result = require(node.id() == 42); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(node.x() == 1.0); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(node.y() == 2.0); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(node.z() == 3.0); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(node.coordinates()[0] == 1.0); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(node.coordinates()[1] == 2.0); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(node.coordinates()[2] == 3.0); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#include "fesa/core/PropertyDefinition.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
int require(bool condition) {
|
||||
return condition ? 0 : 1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int run_property_definition_tests() {
|
||||
const fesa::core::ShellPropertyDefinition property{500, 700, 0.01};
|
||||
|
||||
if (const int result = require(property.id() == 500); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(property.materialId() == 700); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(property.thickness() == 0.01); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "fesa/core/StepDefinition.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
int require(bool condition) {
|
||||
return condition ? 0 : 1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int run_step_definition_tests() {
|
||||
const fesa::core::LinearStaticStepDefinition step{1, "load-step", {0, 2}, {1}};
|
||||
|
||||
if (const int result = require(step.id() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(step.name() == "load-step"); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(step.boundaryConditionIndices().size() == 2); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(step.boundaryConditionIndices()[0] == 0); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(step.boundaryConditionIndices()[1] == 2); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(step.loadIndices().size() == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
if (const int result = require(step.loadIndices()[0] == 1); result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user