65 lines
2.4 KiB
C++
65 lines
2.4 KiB
C++
#include "fesa/IO/IO.hpp"
|
|
|
|
#include <fstream>
|
|
#include <sstream>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
|
|
namespace {
|
|
|
|
void check(bool value, const char* message) {
|
|
if (!value) {
|
|
throw std::runtime_error(message);
|
|
}
|
|
}
|
|
|
|
std::string sourceRoot() {
|
|
#ifdef FESA_SOURCE_DIR
|
|
return FESA_SOURCE_DIR;
|
|
#else
|
|
return ".";
|
|
#endif
|
|
}
|
|
|
|
std::string readTextFile(const std::string& path) {
|
|
std::ifstream input(path);
|
|
if (!input) {
|
|
throw std::runtime_error("failed to open " + path);
|
|
}
|
|
std::ostringstream buffer;
|
|
buffer << input.rdbuf();
|
|
return buffer.str();
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int main() {
|
|
const auto continued = fesa::parseKeywordLine("*Element, type=S4,");
|
|
check(continued.name == "element", "Keyword name normalization changed");
|
|
check(continued.parameters.at("type") == "S4", "Keyword parameter parsing changed");
|
|
|
|
const fesa::AbaqusInputParser parser;
|
|
|
|
const auto normalized = parser.parseFile(sourceRoot() + "/references/quad_02_phase1.inp");
|
|
check(normalized.ok(), "quad_02_phase1 normalized input should remain accepted");
|
|
check(normalized.domain.nodes.size() == 121, "quad_02_phase1 node count changed");
|
|
check(normalized.domain.elements.size() == 100, "quad_02_phase1 element count changed");
|
|
check(normalized.domain.node_sets.at("fixed_boundary").node_ids.size() == 40, "quad_02_phase1 fixed set changed");
|
|
check(normalized.domain.node_sets.at("load_node").node_ids.size() == 1, "quad_02_phase1 load set changed");
|
|
check(normalized.domain.element_sets.at("all_elements").element_ids.size() == 100, "quad_02_phase1 element set changed");
|
|
check(normalized.domain.materials.at("material_1").elastic_modulus == 7.0e10, "quad_02_phase1 material changed");
|
|
check(normalized.domain.shell_sections.front().thickness == 1.0, "quad_02_phase1 shell section changed");
|
|
|
|
const auto original = parser.parseFile(sourceRoot() + "/references/quad_02.inp");
|
|
check(!original.ok(), "original quad_02.inp should remain unsupported provenance");
|
|
check(fesa::containsDiagnostic(original.diagnostics, "FESA-PARSE-UNSUPPORTED-KEYWORD"),
|
|
"original quad_02.inp unsupported keyword diagnostic changed");
|
|
|
|
const auto nonzero_bc = parser.parseString("*Node\n1, 0, 0, 0\n*Boundary\n1, 1, 1, 0.5\n", "nonzero_bc.inp");
|
|
check(!nonzero_bc.ok(), "nonzero prescribed displacement should remain unsupported");
|
|
check(fesa::containsDiagnostic(nonzero_bc.diagnostics, "FESA-PARSE-BOUNDARY-NONZERO"),
|
|
"nonzero prescribed displacement diagnostic changed");
|
|
|
|
return 0;
|
|
}
|