diff --git a/docs/planning/feedback-correction-checklist-2026-11-14.md b/docs/planning/feedback-correction-checklist-2026-11-14.md index 303dcf813..64a07b694 100644 --- a/docs/planning/feedback-correction-checklist-2026-11-14.md +++ b/docs/planning/feedback-correction-checklist-2026-11-14.md @@ -1408,3 +1408,40 @@ SolidCylinderOgrid_VolumeAndBoundary CoaxialTubeSweep_VolumeAndBoundary BoxHexMeshIsClosedAndVolumeConserved ~~~ + + +## 进展(2026-11-14 第二十八轮) + +### VDE-1347:空心圆环结构化四面体 + +新增: + +~~~text +内外两个同主半径圆环面 +u(主圆)× v(截面角)× 径向 +内外表面 boundary_faces +~~~ + +测试: + +~~~text +TetrahedralMeshTest.HollowTorusStructuredPath_VolumeAndBoundary + outer R5/r1 + inner R5/r0.8 + + closed=true + volume ≈ 2π²R(r_out²-r_in²) ±2% +~~~ + +全部: + +~~~text +test_fea_mesh: 37/37 PASS +~~~ + +Tetra 当前覆盖: + +~~~text +拉伸体 / 星形 / 实心圆环 / 空心圆环 / +圆台 / 一般解析体 +~~~ diff --git a/src/cae/fea_mesh.cpp b/src/cae/fea_mesh.cpp index 1ecc9ebe1..f7de84284 100644 --- a/src/cae/fea_mesh.cpp +++ b/src/cae/fea_mesh.cpp @@ -1503,6 +1503,129 @@ bool make_cone_tet_mesh(const brep::BrepModel& body, double target_size, } // namespace + +namespace { + +// 空心圆环(O 形圈):内外两个同主半径圆环面之间的结构化四面体。 +bool make_hollow_torus_tet_mesh(const brep::BrepModel& body, double target_size, + FEAMesh& out) { + std::vector tori; + for (int fi = 0; fi < static_cast(body.num_faces()); ++fi) { + if (body.face_type(fi) != brep::FaceType::Torus) return false; + auto g = brep::face_torus_geometry(body, fi); + if (!g) return false; + tori.push_back(*g); + } + if (tori.size() < 2) return false; + const auto& t0 = tori.front(); + double rmin = 1e300, rmax = -1e300; + for (const auto& g : tori) { + if ((g.center - t0.center).norm() > 1e-7) return false; + if (std::abs(g.major_radius - t0.major_radius) > 1e-7) return false; + if (std::abs(g.axis.normalized().dot(t0.axis.normalized())) < 1.0 - 1e-7) + return false; + rmin = std::min(rmin, g.minor_radius); + rmax = std::max(rmax, g.minor_radius); + } + const double R = t0.major_radius; + if (!(rmin > 0.0 && rmax > rmin + 1e-9 && rmax < R)) return false; + const double body_volume = body.body_volume(); + if (!(body_volume > 1e-12)) return false; + + const double pi = 3.14159265358979323846; + const double h = std::max(target_size * 0.5, 1e-9); + const int nu = std::max(16, static_cast(std::ceil(2.0 * pi * (R + rmax) / h))); + const int nv = std::max(8, static_cast(std::ceil(2.0 * pi * rmax / h))); + const int nr = std::max(1, static_cast(std::ceil((rmax - rmin) / h))); + if (static_cast(nu) * nv * nr > 500000) return false; + + const core::Vector3D axis = t0.axis.normalized(); + const core::Vector3D ex = axis.unitOrthogonal(); + const core::Vector3D ey = axis.cross(ex).normalized(); + FEAMesh mesh; + mesh.element_type = FEAElementType::Tet4; + std::vector>> ring( + nu, std::vector>(nr + 1, std::vector(nv))); + for (int ui = 0; ui < nu; ++ui) { + const double u = 2.0 * pi * ui / nu; + const core::Vector3D radial = ex * std::cos(u) + ey * std::sin(u); + const core::Point3D c = t0.center + radial * R; + for (int i = 0; i <= nr; ++i) { + const double rho = rmin + (rmax - rmin) * i / nr; + for (int j = 0; j < nv; ++j) { + const double v = 2.0 * pi * j / nv; + ring[ui][i][j] = static_cast(mesh.vertices.size()); + mesh.vertices.push_back(c + radial * (rho * std::cos(v)) + + axis * (rho * std::sin(v))); + } + } + } + auto add_tet = [&](int a, int b, int c, int d) { + const core::Vector3D ab = mesh.vertices[b] - mesh.vertices[a]; + const core::Vector3D ac = mesh.vertices[c] - mesh.vertices[a]; + const core::Vector3D ad = mesh.vertices[d] - mesh.vertices[a]; + if (ab.dot(ac.cross(ad)) < 0.0) std::swap(c, d); + mesh.elements.push_back({a, b, c, d}); + }; + for (int ui = 0; ui < nu; ++ui) { + const int u1 = (ui + 1) % nu; + for (int i = 0; i < nr; ++i) + for (int j = 0; j < nv; ++j) { + const int j1 = (j + 1) % nv; + const int A = ring[ui][i][j], B = ring[ui][i][j1]; + const int C = ring[ui][i + 1][j1], D = ring[ui][i + 1][j]; + const int A1 = ring[u1][i][j], B1 = ring[u1][i][j1]; + const int C1 = ring[u1][i + 1][j1], D1 = ring[u1][i + 1][j]; + add_tet(A, B, C, C1); + add_tet(A, C, D, C1); + add_tet(A, D, D1, C1); + add_tet(A, D1, A1, C1); + add_tet(A, A1, B1, C1); + add_tet(A, B1, B, C1); + } + } + double vol = 0.0; + for (const auto& e : mesh.elements) { + const auto a = mesh.vertices[e[0]]; + const auto b = mesh.vertices[e[1]]; + const auto c = mesh.vertices[e[2]]; + const auto d = mesh.vertices[e[3]]; + vol += std::abs((b - a).cross(c - a).dot(d - a)) / 6.0; + } + if (std::abs(vol - body_volume) > 0.02 * body_volume) return false; + + auto add_tri = [&](int a, int b, int c) { + mesh.boundary_faces.push_back({a, b, c}); + mesh.boundary_face_tags.push_back(-1); + mesh.boundary_edges.push_back({a, b}); + mesh.boundary_edges.push_back({b, c}); + mesh.boundary_edges.push_back({c, a}); + mesh.boundary_edge_tags.push_back(-1); + mesh.boundary_edge_tags.push_back(-1); + mesh.boundary_edge_tags.push_back(-1); + }; + for (int ui = 0; ui < nu; ++ui) { + const int u1 = (ui + 1) % nu; + for (int j = 0; j < nv; ++j) { + const int j1 = (j + 1) % nv; + const int A = ring[ui][nr][j], B = ring[ui][nr][j1]; + const int C = ring[u1][nr][j1], D = ring[u1][nr][j]; + add_tri(A, B, C); + add_tri(A, C, D); + const int Ai = ring[ui][0][j], Bi = ring[ui][0][j1]; + const int Ci = ring[u1][0][j1], Di = ring[u1][0][j]; + add_tri(Ai, Ci, Bi); + add_tri(Ai, Di, Ci); + } + } + mesh.material_ids.assign(mesh.elements.size(), 0); + mesh.diagnostic = "tetrahedral_mesh: hollow torus structured path"; + out = std::move(mesh); + return true; +} + +} // namespace + FEAMesh tetrahedral_mesh(const brep::BrepModel& body, const TetMeshParams& params) { // 目标单元尺寸:优先用户值;缺省取包围盒最大跨度的 5%(与头文件一致) @@ -1559,6 +1682,13 @@ FEAMesh tetrahedral_mesh(const brep::BrepModel& body, return cone; } + // 空心圆环(内外双环面)。 + { + FEAMesh hollow; + if (make_hollow_torus_tet_mesh(body, target_size, hollow)) + return hollow; + } + // 实心圆环(非星形):结构化 u/v/径向四面体。 { FEAMesh torus; diff --git a/tests/cae/test_fea_mesh.cpp b/tests/cae/test_fea_mesh.cpp index 178bfa436..8affdf513 100644 --- a/tests/cae/test_fea_mesh.cpp +++ b/tests/cae/test_fea_mesh.cpp @@ -624,3 +624,21 @@ TEST(VolumeMeshValidationTest, BoxHexMeshIsClosedAndVolumeConserved) { EXPECT_NEAR(v.mesh_volume, 24.0, 1e-9); EXPECT_TRUE(v.ok) << v.diagnostic; } + + +TEST(TetrahedralMeshTest, HollowTorusStructuredPath_VolumeAndBoundary) { + auto outer = make_torus_exact(5.0, 1.0); + auto inner = make_torus_exact(5.0, 0.8); + auto hollow = brep_difference(outer, inner); + TetMeshParams params; + params.max_size = 0.5; + params.quality_iterations = 0; + auto mesh = tetrahedral_mesh(hollow, params); + ASSERT_FALSE(mesh.elements.empty()) << mesh.diagnostic; + const auto v = validate_volume_mesh(hollow, mesh, 0.02); + EXPECT_TRUE(v.closed) << v.diagnostic; + EXPECT_TRUE(v.ok) << v.diagnostic; + const double expect = 2.0 * 3.14159265358979323846 * + 3.14159265358979323846 * 5.0 * (1.0 - 0.64); + EXPECT_NEAR(v.mesh_volume, expect, 0.02 * expect); +}