fix(solver+io): B1 block-FD Hessian, V3 NaN/Inf guard, C1 ok-flag (audit quick-wins)
B1 (api-performance): wire hyper_ideal_hessian_block_fd_sym into newton_hyper_ideal instead of the full-FD path — 33×/1166× faster on cathead/brezel, also fixes the FD-step vs Newton-tol accuracy floor (N1 cross-fix). V3 (input-validation): add isfinite check on all vertex coordinates in load_mesh; NaN/Inf now throws runtime_error at the I/O boundary before poisoning the solver. C1 (test-coverage): expose the internal ok flag via an optional bool* parameter on solve_linear_system so double-solver failure is no longer invisible to callers. +5 new tests (LoadMeshThrowsOnNaN/Inf, OkFlag_True*, OkFlag_NullPointerIsSafe). 282/282 tests pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace conformallab;
|
||||
@@ -171,3 +172,42 @@ TEST(MeshIO, SaveLoadConvenienceWrappers)
|
||||
|
||||
rm(path);
|
||||
}
|
||||
|
||||
// ════════════════════════════════════════════════════════════════════════════
|
||||
// V3: load_mesh throws on non-finite vertex coordinate (NaN / Inf)
|
||||
//
|
||||
// A mesh file containing NaN or Inf vertex coordinates must be rejected at
|
||||
// the I/O boundary — before the coordinates can silently poison the solver.
|
||||
// ════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
TEST(MeshIO, LoadMeshThrowsOnNaNCoordinate)
|
||||
{
|
||||
// Write a minimal OFF triangle with a NaN in the first vertex.
|
||||
auto path = tmp_path("nan.off");
|
||||
{
|
||||
std::ofstream ofs(path);
|
||||
ofs << "OFF\n3 1 0\n"
|
||||
<< "nan 0.0 0.0\n"
|
||||
<< "1.0 0.0 0.0\n"
|
||||
<< "0.0 1.0 0.0\n"
|
||||
<< "3 0 1 2\n";
|
||||
}
|
||||
EXPECT_THROW(load_mesh(path), std::runtime_error);
|
||||
rm(path);
|
||||
}
|
||||
|
||||
TEST(MeshIO, LoadMeshThrowsOnInfCoordinate)
|
||||
{
|
||||
// Write a minimal OFF triangle with Inf in the y-coordinate.
|
||||
auto path = tmp_path("inf.off");
|
||||
{
|
||||
std::ofstream ofs(path);
|
||||
ofs << "OFF\n3 1 0\n"
|
||||
<< "0.0 0.0 0.0\n"
|
||||
<< "1.0 inf 0.0\n"
|
||||
<< "0.0 1.0 0.0\n"
|
||||
<< "3 0 1 2\n";
|
||||
}
|
||||
EXPECT_THROW(load_mesh(path), std::runtime_error);
|
||||
rm(path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user