Input mesh does not form a closed volume error; checked that mesh is watertight

조회 수: 13 (최근 30일)
Taiyi Wang
Taiyi Wang 2022년 5월 10일
댓글: Taiyi Wang 2022년 5월 12일
I encountered the following error message while using geometryFromMesh
"Error using checkMeshWatertight; Input mesh does not form a closed volume. Likely, there are missing faces or gaps in the input."
Below is the code, example input parameters are attached:
% gengerate mesh
load('input.mat')
tnodes = [P(:, 1)'; P(:, 2)'; P(:, 3)'];
telements = T';
model = createpde;
geometryFromMesh(model,tnodes,telements); % this line is where error is produced
mesh = generateMesh(model,'Hmin', 300 , 'Hmax', 310 ,'GeometricOrder','linear');
Background: my goal is to make a 3D surface triangular mesh automatically from spherical harmonics. The reason I'm using geometryFromMesh is that, I would 1. sample the spherical harmonics analytical expression using a regular grid in spherical coordinates; 2. use surf2patch to roughly convert this into a triangular mesh; 3. use my own algorithm to mend any holes on the mesh 4. convert this mesh to geometry object, and create a more uniform-sized mesh using "generateMesh". It is a convoluted process, but one seemed necessary given that I want the meshing process to be done in Matlab for any spherical harmonics.
For the attached example, I have checked that the mesh is watertight using Find-holes-in-triangular-mesh, but did not find any hole. If you could point me to what produced the error, or suggest more elegant workflow than what I described above, I would really appreciate it.

답변 (1개)

Cris LaPierre
Cris LaPierre 2022년 5월 10일
I wouldn't say I can suggest a more elegant workflow, but here is one that I have found to work in the past. It involves using stlwrite to export the mesh, and then importgeometry to create the geometry.
% gengerate mesh
load('input.mat')
TR = triangulation(T,P);
stlwrite(TR,'Geom.stl')
% create geometry
model = createpde;
gm = importGeometry(model,'Geom.stl')
gm =
DiscreteGeometry with properties: NumCells: 1 NumFaces: 52 NumEdges: 101 NumVertices: 51 Vertices: [51×3 double]
pdegplot(gm)
  댓글 수: 2
Taiyi Wang
Taiyi Wang 2022년 5월 10일
편집: Cris LaPierre 2022년 5월 10일
Thanks for the answer! This method does work - although the problem now is that the mesh produced using generateMesh no longer has uniform triangular elements (attached .fig file). I had hoped that only the geometry will be extracted, not the input mesh itself, so that the resulting mesh is uniform.
Previously, I tried using "boundary" to generate triangulation form point clouds, and then couple that into generateMesh. The problem with that approach is that "boundary" failed to capture detailed geoemetry for high order spherical harmonics. In that case though, the resulting mesh was uniform.
Is that possible to still generate uiform mesh?
Thanks so much,
Taiyi
openfig('nonuniform.fig')
ans =
Figure (1) with properties: Number: 1 Name: '' Color: [1 1 1] Position: [222 345 560 420] Units: 'pixels' Show all properties
Taiyi Wang
Taiyi Wang 2022년 5월 12일
As a follow up - it seems that the main feature that results in non-uniform meshing are the vertices in the discrete geometry "gm". I there a way to edit the discrete geometry object to remove those vertices?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Geometry and Mesh에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by