81 lines
2.0 KiB
C++
81 lines
2.0 KiB
C++
#include <fesa/io/abaqus/input_parser.hpp>
|
|
|
|
#include <string>
|
|
|
|
namespace {
|
|
|
|
int fail()
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int main()
|
|
{
|
|
fesa::io::abaqus::InputParser parser;
|
|
|
|
const std::string input = R"inp(
|
|
** mesh parser smoke case
|
|
*HeAdInG
|
|
small truss model
|
|
*NoDe
|
|
1, 0.0, 0.0, 0.0
|
|
2, 1.5, 0.0, 0.0
|
|
*ElEmEnT, TyPe=t3d2
|
|
10, 1, 2
|
|
)inp";
|
|
|
|
const auto result = parser.parse(input);
|
|
if (!result.status.is_ok()) {
|
|
return fail();
|
|
}
|
|
|
|
const auto& domain = result.domain;
|
|
if (domain.nodes().size() != 2 || domain.elements().size() != 1) {
|
|
return fail();
|
|
}
|
|
|
|
const auto* first_node = domain.find_node(fesa::core::NodeId{1});
|
|
if (first_node == nullptr || first_node->coordinates()[0] != 0.0 ||
|
|
first_node->coordinates()[1] != 0.0 || first_node->coordinates()[2] != 0.0) {
|
|
return fail();
|
|
}
|
|
|
|
const auto* second_node = domain.find_node(fesa::core::NodeId{2});
|
|
if (second_node == nullptr || second_node->coordinates()[0] != 1.5 ||
|
|
second_node->coordinates()[1] != 0.0 || second_node->coordinates()[2] != 0.0) {
|
|
return fail();
|
|
}
|
|
|
|
const auto* element = domain.find_element(fesa::core::ElementId{10});
|
|
if (element == nullptr ||
|
|
element->topology() != fesa::model::ElementTopology::truss2 ||
|
|
element->node_ids().size() != 2 ||
|
|
element->node_ids()[0].value != 1 ||
|
|
element->node_ids()[1].value != 2 ||
|
|
element->property_id().value != 0) {
|
|
return fail();
|
|
}
|
|
|
|
const std::string beam_input = R"inp(
|
|
*NODE
|
|
1, 0.0, 0.0, 0.0
|
|
2, 0.0, 2.0, 0.0
|
|
*ELEMENT, TYPE=B31
|
|
20, 1, 2
|
|
)inp";
|
|
|
|
const auto beam_result = parser.parse(beam_input);
|
|
const auto* beam = beam_result.domain.find_element(fesa::core::ElementId{20});
|
|
if (!beam_result.status.is_ok() ||
|
|
beam == nullptr ||
|
|
beam->topology() != fesa::model::ElementTopology::bar2 ||
|
|
beam->node_ids().size() != 2 ||
|
|
beam->property_id().value != 0) {
|
|
return fail();
|
|
}
|
|
|
|
return 0;
|
|
}
|