feat: add property model foundation
This commit is contained in:
+41
-12
@@ -172,8 +172,8 @@ void Domain::addElement(std::unique_ptr<fesa::element::Element> element) {
|
||||
throw std::invalid_argument("element references missing node id");
|
||||
}
|
||||
}
|
||||
if (findShellProperty(element->propertyId()) == nullptr) {
|
||||
throw std::invalid_argument("element references missing shell property id");
|
||||
if (findProperty(element->propertyId()) == nullptr) {
|
||||
throw std::invalid_argument("element references missing property id");
|
||||
}
|
||||
elements_.emplace(id, std::move(element));
|
||||
}
|
||||
@@ -189,15 +189,28 @@ void Domain::addMaterial(std::unique_ptr<fesa::material::Material> material) {
|
||||
}
|
||||
}
|
||||
|
||||
void Domain::addShellProperty(fesa::property::ShellProperty property) {
|
||||
const PropertyId id = property.id();
|
||||
if (shell_properties_.find(id) != shell_properties_.end()) {
|
||||
throw std::invalid_argument("duplicate shell property id");
|
||||
void Domain::addProperty(std::unique_ptr<fesa::property::Property> property) {
|
||||
if (!property) {
|
||||
throw std::invalid_argument("property is null");
|
||||
}
|
||||
if (findMaterial(property.materialId()) == nullptr) {
|
||||
throw std::invalid_argument("shell property references missing material id");
|
||||
const PropertyId id = property->id();
|
||||
if (properties_.find(id) != properties_.end()) {
|
||||
throw std::invalid_argument("duplicate property id");
|
||||
}
|
||||
shell_properties_.emplace(id, std::move(property));
|
||||
if (property->kind() == fesa::property::PropertyKind::Shell) {
|
||||
const auto* shell_property = dynamic_cast<const fesa::property::ShellProperty*>(property.get());
|
||||
if (shell_property == nullptr) {
|
||||
throw std::invalid_argument("shell property kind does not match shell property type");
|
||||
}
|
||||
if (findMaterial(shell_property->materialId()) == nullptr) {
|
||||
throw std::invalid_argument("shell property references missing material id");
|
||||
}
|
||||
}
|
||||
properties_.emplace(id, std::move(property));
|
||||
}
|
||||
|
||||
void Domain::addShellProperty(std::unique_ptr<fesa::property::ShellProperty> property) {
|
||||
addProperty(std::move(property));
|
||||
}
|
||||
|
||||
void Domain::addNodeSet(std::string name, std::vector<NodeId> node_ids) {
|
||||
@@ -338,9 +351,25 @@ std::size_t Domain::materialCount() const noexcept {
|
||||
return materials_.size();
|
||||
}
|
||||
|
||||
const fesa::property::Property* Domain::findProperty(PropertyId id) const noexcept {
|
||||
const auto it = properties_.find(id);
|
||||
return it == properties_.end() ? nullptr : it->second.get();
|
||||
}
|
||||
|
||||
const fesa::property::Property& Domain::property(PropertyId id) const {
|
||||
const fesa::property::Property* found = findProperty(id);
|
||||
if (found == nullptr) {
|
||||
throw std::out_of_range("property id not found");
|
||||
}
|
||||
return *found;
|
||||
}
|
||||
|
||||
std::size_t Domain::propertyCount() const noexcept {
|
||||
return properties_.size();
|
||||
}
|
||||
|
||||
const fesa::property::ShellProperty* Domain::findShellProperty(PropertyId id) const noexcept {
|
||||
const auto it = shell_properties_.find(id);
|
||||
return it == shell_properties_.end() ? nullptr : &it->second;
|
||||
return dynamic_cast<const fesa::property::ShellProperty*>(findProperty(id));
|
||||
}
|
||||
|
||||
const fesa::property::ShellProperty& Domain::shellProperty(PropertyId id) const {
|
||||
@@ -352,7 +381,7 @@ const fesa::property::ShellProperty& Domain::shellProperty(PropertyId id) const
|
||||
}
|
||||
|
||||
std::size_t Domain::shellPropertyCount() const noexcept {
|
||||
return shell_properties_.size();
|
||||
return properties_.size();
|
||||
}
|
||||
|
||||
const std::vector<NodeId>* Domain::findNodeSet(const std::string& name) const noexcept {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "fesa/io/Hdf5ResultWriter.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
namespace fesa::io {
|
||||
|
||||
Hdf5ResultWriter::Hdf5ResultWriter(std::string file_path)
|
||||
: file_path_(std::move(file_path)) {
|
||||
if (file_path_.empty()) {
|
||||
throw std::invalid_argument("HDF5 result writer path must not be empty");
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& Hdf5ResultWriter::filePath() const noexcept {
|
||||
return file_path_;
|
||||
}
|
||||
|
||||
} // namespace fesa::io
|
||||
@@ -15,6 +15,10 @@ PropertyId ShellProperty::id() const noexcept {
|
||||
return id_;
|
||||
}
|
||||
|
||||
PropertyKind ShellProperty::kind() const noexcept {
|
||||
return PropertyKind::Shell;
|
||||
}
|
||||
|
||||
MaterialId ShellProperty::materialId() const noexcept {
|
||||
return material_id_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user