test(cae): thin plate corpus midsurface and tetra regression

This commit is contained in:
hm
2026-11-14 21:34:28 +08:00
parent ae1e506c6b
commit ab0324fb33
2 changed files with 89 additions and 0 deletions
@@ -1521,3 +1521,54 @@ body volume = 156.499604
~~~text
未合入空心圆锥代码/测试。
~~~
## 进展(2026-11-14 第三十一轮)
### 真实语料回归:薄板 161×120×2
使用语料:
~~~text
corpus/real/step/box plate1.stp
~~~
导入结果:
~~~text
V=16 E=24 F=10
volume=38320
bbox=(-80.5,-60,0)-(80.5,60,2)
10 个平面,无圆柱面
~~~
验证:
~~~text
extract_midsurface:
1 个 Plane patch
thickness=2
loops=1
shell_mesh:非空
tetrahedral_mesh:
star-shaped 路径
28 个 Tet4
closed=true
volume=38320
相对误差≈1.9e-16
~~~
测试:
~~~text
CorpusProbe.ThinPlateMidsurfaceAndTetra
VDE_SOURCE_DIR 缺失时 skip
~~~
全部:
~~~text
test_fea_mesh: 39/39 PASS
~~~
+38
View File
@@ -2,10 +2,13 @@
#include "vde/cae/fea_mesh.h"
#include "vde/brep/modeling.h"
#include "vde/brep/brep_boolean.h"
#include "vde/brep/format_io.h"
#include "vde/cae/cae_preprocess.h"
#include "vde/mesh/mesh_quality.h"
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <set>
@@ -660,3 +663,38 @@ TEST(TetrahedralMeshTest, HollowSphereStructuredPath_VolumeAndBoundary) {
(125.0 - 91.125);
EXPECT_NEAR(v.mesh_volume, expect, 0.02 * expect) << v.diagnostic;
}
TEST(CorpusProbe, ThinPlateMidsurfaceAndTetra) {
const char* src_root = std::getenv("VDE_SOURCE_DIR");
const std::string path =
std::string(src_root ? src_root : "D:/20_AI/ViewDesignEngine") +
"/corpus/real/step/box plate1.stp";
std::ifstream in(path);
if (!in.good()) GTEST_SKIP() << "corpus file missing";
auto r = vde::brep::import_cad(path);
ASSERT_TRUE(r.ok) << r.diagnostic.summary();
ASSERT_FALSE(r.bodies.empty());
const auto& b = r.bodies.front();
const auto bb = b.bounds();
EXPECT_NEAR(bb.max().z() - bb.min().z(), 2.0, 1e-9);
EXPECT_NEAR(b.body_volume(), 38320.0, 1.0);
const auto mids = vde::cae::extract_midsurface(b, 0.2);
ASSERT_EQ(mids.size(), 1u);
EXPECT_NEAR(mids[0].thickness, 2.0, 1e-9);
EXPECT_EQ(mids[0].kind, vde::cae::MidsurfaceKind::Plane);
EXPECT_FALSE(mids[0].loops.empty());
const auto shell = vde::cae::shell_mesh(b);
EXPECT_FALSE(shell.triangles.empty()) << shell.diagnostic;
TetMeshParams tp;
tp.max_size = 5.0;
tp.quality_iterations = 0;
auto tet = tetrahedral_mesh(b, tp);
ASSERT_FALSE(tet.elements.empty()) << tet.diagnostic;
const auto val = validate_volume_mesh(b, tet, 0.02);
EXPECT_TRUE(val.closed) << val.diagnostic;
EXPECT_TRUE(val.ok) << val.diagnostic;
EXPECT_NEAR(val.relative_error, 0.0, 1e-9);
}