76 lines
3.1 KiB
C++
76 lines
3.1 KiB
C++
#include <gtest/gtest.h>
|
|
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <iomanip>
|
|
#include <iostream>
|
|
|
|
#include "fesa/app/fesa_application.h"
|
|
#include "thermal_reference_comparison.h"
|
|
|
|
namespace {
|
|
std::string Bytes(const std::filesystem::path& path) {
|
|
std::ifstream in{path, std::ios::binary};
|
|
return {std::istreambuf_iterator<char>{in}, std::istreambuf_iterator<char>{}};
|
|
}
|
|
TEST(ThermalReference, OriginalAbaqusNt11RemainsAnExplicitFailingDiagnostic) {
|
|
const auto folder =
|
|
std::filesystem::path{FESA_TEST_BINARY_DIR} / "reference/thermal-execution";
|
|
std::filesystem::create_directories(folder);
|
|
for (const auto& name : {"shell-thermal.inp",
|
|
"shell-thermal NodalTemperature.csv"}) {
|
|
std::filesystem::copy_file(
|
|
std::filesystem::path{FESA_TEST_SOURCE_DIR} / "reference/shell-thermal" / name,
|
|
folder / name, std::filesystem::copy_options::overwrite_existing);
|
|
}
|
|
const auto input = folder / "shell-thermal.inp";
|
|
const auto csv = folder / "shell-thermal NodalTemperature.csv";
|
|
const auto before_input = Bytes(input), before_csv = Bytes(csv);
|
|
ASSERT_FALSE(before_input.empty());
|
|
ASSERT_FALSE(before_csv.empty());
|
|
const int exit = fesa::FesaApplication{}.Run({input.string()});
|
|
EXPECT_EQ(Bytes(input), before_input);
|
|
EXPECT_EQ(Bytes(csv), before_csv);
|
|
ASSERT_EQ(exit, 0);
|
|
const auto result = fesa::test::CompareThermalReferenceFiles(
|
|
input, csv, folder / "shell-thermal_results.h5");
|
|
ASSERT_TRUE(result.HasValue())
|
|
<< (result.HasValue() ? "" : result.GetStatus().Diagnostics()[0].message);
|
|
const auto& r = result.Value();
|
|
ASSERT_EQ(r.rows.size(), 729U);
|
|
const auto output = std::filesystem::path{FESA_TEST_BINARY_DIR} /
|
|
"thermal-reference-metrics.csv";
|
|
std::ofstream rows{output};
|
|
rows
|
|
<< "instance,label,dof,actual,reference,absolute_error,threshold,passed\n"
|
|
<< std::setprecision(17);
|
|
std::size_t failed = 0;
|
|
for (const auto& row : r.rows) {
|
|
failed += !row.tolerance.passed;
|
|
rows << row.instance << ',' << row.label << ',' << row.source_dof << ','
|
|
<< row.actual << ',' << row.reference << ','
|
|
<< row.tolerance.absolute_error << ',' << row.tolerance.threshold
|
|
<< ',' << row.tolerance.passed << '\n';
|
|
}
|
|
ASSERT_TRUE(rows.good());
|
|
std::cout << std::setprecision(17)
|
|
<< "THERMAL_REFERENCE rows=" << r.rows.size()
|
|
<< " S=" << r.family.reference_scale
|
|
<< " B=" << r.family.near_zero_band
|
|
<< " RMS/S=" << r.family.relative_rms
|
|
<< " max_abs=" << r.family.maximum_absolute_error
|
|
<< " failed_rows=" << failed << " numerical_passed=" << r.passed
|
|
<< " classification=diagnostic blocking=" << r.family.blocking
|
|
<< '\n';
|
|
EXPECT_EQ(r.family.reference_scale, 1000);
|
|
EXPECT_EQ(r.family.near_zero_band, 10);
|
|
EXPECT_FALSE(r.family.blocking);
|
|
EXPECT_FALSE(r.passed);
|
|
EXPECT_FALSE(r.family.rms_passed);
|
|
EXPECT_EQ(failed, 87U);
|
|
EXPECT_GT(r.family.relative_rms,
|
|
fesa::test::ReferenceTolerancePolicy::kRelativeRmsTolerance);
|
|
EXPECT_GT(r.family.maximum_absolute_error, r.family.near_zero_band);
|
|
}
|
|
} // namespace
|