diff --git a/docs/planning/feedback-correction-checklist-2026-11-14.md b/docs/planning/feedback-correction-checklist-2026-11-14.md index da0588f68..d14652e41 100644 --- a/docs/planning/feedback-correction-checklist-2026-11-14.md +++ b/docs/planning/feedback-correction-checklist-2026-11-14.md @@ -717,3 +717,42 @@ VDE1346CaePreprocess.SphericalShellMidsurfaceAndMesh ~~~text 8/8 PASS ~~~ + + +## 进展(2026-11-14 第十二轮) + +### VDE-1347:同轴圆管六面体 + +新增: + +~~~text +hexahedral_mesh + 同轴内外圆柱面 + → 柱坐标结构化六面体 + ncirc × nrad × nz + 内/外柱面 + 上下环形端面 boundary_faces +~~~ + +回归: + +~~~text +HexahedralMeshTest.CoaxialTubeSweep_VolumeAndBoundary + outer r5 / inner r4.5 / 高20 + sweep_layers=8 + cell_size=1 + boundary_faces>0 + tags 与 faces 等长 +~~~ + +全部: + +~~~text +test_fea_mesh: 29/29 PASS +~~~ + +仍不支持: + +~~~text +实心圆柱轴心的六面体(会退化) +自由曲面体 +~~~ diff --git a/src/cae/fea_mesh.cpp b/src/cae/fea_mesh.cpp index 3b7aaa752..80f87e5e4 100644 --- a/src/cae/fea_mesh.cpp +++ b/src/cae/fea_mesh.cpp @@ -1614,9 +1614,101 @@ FEAMesh hexahedral_mesh(const brep::BrepModel& body, // 正确的结构化六面体;其他形状明确返回空 + 诊断,不再静默给错网格。 AxisBoxInfo bi; if (!detect_axis_aligned_box(body, bi)) { + // 薄壁圆管:同轴内外圆柱面 → 柱坐标结构化六面体。 + core::Vector3D axis{0, 0, 1}; + core::Point3D axis_point{0, 0, 0}; + double rmin = 1e300, rmax = -1e300, zmin = 1e300, zmax = -1e300; + int ncyl = 0; + for (int fi = 0; fi < static_cast(body.num_faces()); ++fi) { + if (body.face_type(fi) != brep::FaceType::Cylinder) continue; + auto g = body.face_cylinder_geometry(fi); + if (!g) continue; + if (ncyl == 0) { + axis = g->axis.normalized(); + axis_point = g->axis_point; + } else { + const core::Vector3D d = g->axis_point - axis_point; + if (std::abs(axis.dot(g->axis.normalized())) < 1.0 - 1e-6 || + (d - axis * d.dot(axis)).norm() > 1e-6) + continue; + } + ++ncyl; + rmin = std::min(rmin, g->radius); + rmax = std::max(rmax, g->radius); + for (int ei : body.face_edges(fi)) { + const auto& e = body.edge(ei); + for (int v : {e.v_start, e.v_end}) { + const double t = (body.vertex(v).point - axis_point).dot(axis); + zmin = std::min(zmin, t); + zmax = std::max(zmax, t); + } + } + } + if (ncyl >= 2 && rmax > rmin + 1e-9 && zmax > zmin + 1e-9) { + const double L = zmax - zmin; + double step = params.cell_size; + if (!(step > 0.0)) step = std::max(rmax * 0.2, L / 8.0); + const int ncirc = std::max(8, static_cast( + std::ceil(2.0 * 3.14159265358979323846 * rmax / step))); + const int nrad = std::max(1, static_cast( + std::ceil((rmax - rmin) / step))); + const int nz = std::max(1, params.sweep_layers); + if (static_cast(ncirc) * nrad * nz <= 500000) { + const core::Vector3D ex = axis.unitOrthogonal(); + const core::Vector3D ey = axis.cross(ex).normalized(); + auto vid = [&](int i, int j, int k) { + return i + (ncirc + 1) * (j + (nrad + 1) * k); + }; + for (int k = 0; k <= nz; ++k) + for (int j = 0; j <= nrad; ++j) { + const double r = rmin + (rmax - rmin) * j / nrad; + const double z = zmin + L * k / nz; + for (int i = 0; i <= ncirc; ++i) { + const double a = 2.0 * 3.14159265358979323846 * i / ncirc; + result.vertices.push_back( + axis_point + axis * z + + ex * (r * std::cos(a)) + ey * (r * std::sin(a))); + } + } + for (int k = 0; k < nz; ++k) + for (int j = 0; j < nrad; ++j) + for (int i = 0; i < ncirc; ++i) + result.elements.push_back({ + vid(i, j, k), vid(i + 1, j, k), + vid(i + 1, j + 1, k), vid(i, j + 1, k), + vid(i, j, k + 1), vid(i + 1, j, k + 1), + vid(i + 1, j + 1, k + 1), vid(i, j + 1, k + 1)}); + result.material_ids.assign(result.elements.size(), 0); + auto add_quad = [&](int a, int b, int c, int d) { + result.boundary_faces.push_back({a, b, c, d}); + result.boundary_face_tags.push_back(-1); + const int q[4] = {a, b, c, d}; + for (int s = 0; s < 4; ++s) { + result.boundary_edges.push_back({q[s], q[(s + 1) % 4]}); + result.boundary_edge_tags.push_back(-1); + } + }; + for (int k = 0; k < nz; ++k) + for (int i = 0; i < ncirc; ++i) { + add_quad(vid(i, 0, k), vid(i, 0, k + 1), + vid(i + 1, 0, k + 1), vid(i + 1, 0, k)); + add_quad(vid(i, nrad, k), vid(i + 1, nrad, k), + vid(i + 1, nrad, k + 1), vid(i, nrad, k + 1)); + } + for (int j = 0; j < nrad; ++j) + for (int i = 0; i < ncirc; ++i) { + add_quad(vid(i, j, 0), vid(i + 1, j, 0), + vid(i + 1, j + 1, 0), vid(i, j + 1, 0)); + add_quad(vid(i, j, nz), vid(i, j + 1, nz), + vid(i + 1, j + 1, nz), vid(i + 1, j, nz)); + } + result.diagnostic = "hexahedral_mesh: cylindrical tube sweep"; + return result; + } + } result.diagnostic = - "hexahedral_mesh: sweep hex currently supports axis-aligned box only; " - "use tetrahedral_mesh or mapped_hex_mesh for this body"; + "hexahedral_mesh: sweep hex currently supports axis-aligned box and " + "coaxial circular tube only; use tetrahedral_mesh or mapped_hex_mesh"; return result; } const Vector3D ext = bi.hi - bi.lo; diff --git a/tests/cae/test_fea_mesh.cpp b/tests/cae/test_fea_mesh.cpp index cd639bbb3..e49ebcfb2 100644 --- a/tests/cae/test_fea_mesh.cpp +++ b/tests/cae/test_fea_mesh.cpp @@ -1,6 +1,7 @@ #include #include "vde/cae/fea_mesh.h" #include "vde/brep/modeling.h" +#include "vde/brep/brep_boolean.h" #include "vde/mesh/mesh_quality.h" #include #include @@ -473,3 +474,17 @@ TEST(HexahedralMeshTest, NonBoxReturnsExplicitDiagnostic) { EXPECT_TRUE(mesh.elements.empty()); EXPECT_FALSE(mesh.diagnostic.empty()); } + + +TEST(HexahedralMeshTest, CoaxialTubeSweep_VolumeAndBoundary) { + auto outer = make_cylinder_exact(5.0, 20.0); + auto inner = make_cylinder_exact(4.5, 20.2); + auto tube = brep_difference(outer, inner); + HexMeshParams params; + params.sweep_layers = 8; + params.cell_size = 1.0; + auto mesh = hexahedral_mesh(tube, params); + ASSERT_FALSE(mesh.elements.empty()) << mesh.diagnostic; + EXPECT_GT(mesh.boundary_faces.size(), 0u); + EXPECT_EQ(mesh.boundary_face_tags.size(), mesh.boundary_faces.size()); +}