feat: add property model foundation

This commit is contained in:
김경종
2026-06-09 11:56:42 +09:00
parent f4196efb10
commit 7ea08441ed
23 changed files with 661 additions and 25 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ fesa::core::Domain populated_domain() {
domain.addNode(fesa::core::Node{3, 1.0, 1.0, 0.0});
domain.addNode(fesa::core::Node{4, 0.0, 1.0, 0.0});
domain.addMaterial(std::make_unique<fesa::material::LinearElasticMaterial>(700, 210.0, 0.3));
domain.addShellProperty(fesa::property::ShellProperty{500, 700, 0.01});
domain.addShellProperty(std::make_unique<fesa::property::ShellProperty>(500, 700, 0.01));
return domain;
}
+31 -8
View File
@@ -39,7 +39,7 @@ void add_four_nodes(fesa::core::Domain& domain) {
void add_material_and_property(fesa::core::Domain& domain) {
domain.addMaterial(std::make_unique<fesa::material::LinearElasticMaterial>(700, 210.0, 0.3));
domain.addShellProperty(fesa::property::ShellProperty{500, 700, 0.01});
domain.addShellProperty(std::make_unique<fesa::property::ShellProperty>(500, 700, 0.01));
}
void add_element(fesa::core::Domain& domain) {
@@ -215,21 +215,29 @@ int add_and_retrieve_material_and_property() {
return result;
}
const fesa::property::ShellProperty* property = domain.findShellProperty(500);
const fesa::property::Property* property = domain.findProperty(500);
if (const int result = require(property != nullptr); result != 0) {
return result;
}
if (const int result = require(property->materialId() == 700); result != 0) {
if (const int result = require(property->kind() == fesa::property::PropertyKind::Shell); result != 0) {
return result;
}
if (const int result = require(property->thickness() == 0.01); result != 0) {
const fesa::property::ShellProperty* shell_property = domain.findShellProperty(500);
if (const int result = require(shell_property != nullptr); result != 0) {
return result;
}
if (const int result = require(shell_property->materialId() == 700); result != 0) {
return result;
}
if (const int result = require(shell_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);
return require(domain.property(500).id() == 500);
}
int duplicate_material_and_property_ids_throw() {
@@ -244,7 +252,7 @@ int duplicate_material_and_property_ids_throw() {
}
return require_throws<std::invalid_argument>([&domain]() {
domain.addShellProperty(fesa::property::ShellProperty{500, 700, 0.02});
domain.addShellProperty(std::make_unique<fesa::property::ShellProperty>(500, 700, 0.02));
});
}
@@ -252,7 +260,15 @@ int shell_property_referencing_missing_material_throws() {
fesa::core::Domain domain;
return require_throws<std::invalid_argument>([&domain]() {
domain.addShellProperty(fesa::property::ShellProperty{500, 700, 0.01});
domain.addShellProperty(std::make_unique<fesa::property::ShellProperty>(500, 700, 0.01));
});
}
int null_property_rejected() {
fesa::core::Domain domain;
return require_throws<std::invalid_argument>([&domain]() {
domain.addProperty(nullptr);
});
}
@@ -517,6 +533,10 @@ int const_domain_retrieval_returns_const_runtime_model_data() {
result != 0) {
return result;
}
if (const int result = require((std::is_same<decltype(const_domain.property(500)), const fesa::property::Property&>::value));
result != 0) {
return result;
}
if (const int result = require((std::is_same<decltype(const_domain.shellProperty(500)), const fesa::property::ShellProperty&>::value));
result != 0) {
return result;
@@ -567,7 +587,7 @@ int failed_inserts_do_not_mutate_counts() {
}
if (const int result = require_throws<std::invalid_argument>([&domain]() {
domain.addShellProperty(fesa::property::ShellProperty{501, 404, 0.01});
domain.addShellProperty(std::make_unique<fesa::property::ShellProperty>(501, 404, 0.01));
});
result != 0) {
return result;
@@ -642,6 +662,9 @@ int run_domain_storage_tests() {
if (const int result = shell_property_referencing_missing_material_throws(); result != 0) {
return result;
}
if (const int result = null_property_rejected(); result != 0) {
return result;
}
if (const int result = add_and_retrieve_sets(); result != 0) {
return result;
}
+44
View File
@@ -0,0 +1,44 @@
#include "fesa/io/Hdf5ResultWriter.hpp"
#include <stdexcept>
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 construct_writer_preserves_output_path() {
const fesa::io::Hdf5ResultWriter writer{"results.h5"};
return require(writer.filePath() == "results.h5");
}
int empty_output_path_throws() {
return require_throws<std::invalid_argument>([]() {
(void)fesa::io::Hdf5ResultWriter{""};
});
}
} // namespace
int main() {
if (const int result = construct_writer_preserves_output_path(); result != 0) {
return result;
}
if (const int result = empty_output_path_throws(); result != 0) {
return result;
}
return 0;
}
+4
View File
@@ -3,6 +3,7 @@ int run_element_base_tests();
int run_load_base_tests();
int run_material_base_tests();
int run_mitc4_element_model_tests();
int run_property_base_tests();
int run_shell_property_tests();
int main() {
@@ -18,6 +19,9 @@ int main() {
if (const int result = run_material_base_tests(); result != 0) {
return result;
}
if (const int result = run_property_base_tests(); result != 0) {
return result;
}
if (const int result = run_shell_property_tests(); result != 0) {
return result;
}
+37
View File
@@ -0,0 +1,37 @@
#include "fesa/property/Property.hpp"
#include <memory>
namespace {
int require(bool condition) {
return condition ? 0 : 1;
}
class TestProperty final : public fesa::property::Property {
public:
explicit TestProperty(fesa::core::PropertyId id) : id_(id) {}
fesa::core::PropertyId id() const noexcept override {
return id_;
}
fesa::property::PropertyKind kind() const noexcept override {
return fesa::property::PropertyKind::Shell;
}
private:
fesa::core::PropertyId id_;
};
} // namespace
int run_property_base_tests() {
std::unique_ptr<fesa::property::Property> owned = std::make_unique<TestProperty>(500);
const fesa::property::Property& property = *owned;
if (const int result = require(property.id() == 500); result != 0) {
return result;
}
return require(property.kind() == fesa::property::PropertyKind::Shell);
}
+8
View File
@@ -1,4 +1,5 @@
#include "fesa/property/ShellProperty.hpp"
#include "fesa/property/Property.hpp"
#include <stdexcept>
@@ -24,10 +25,17 @@ int require_throws(Function&& function) {
int run_shell_property_tests() {
const fesa::property::ShellProperty property{500, 700, 0.01};
const fesa::property::Property& base = property;
if (const int result = require(property.id() == 500); result != 0) {
return result;
}
if (const int result = require(base.id() == 500); result != 0) {
return result;
}
if (const int result = require(base.kind() == fesa::property::PropertyKind::Shell); result != 0) {
return result;
}
if (const int result = require(property.materialId() == 700); result != 0) {
return result;
}