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

13 views (last 30 days)
Taiyi Wang
Taiyi Wang on 10 May 2022
Commented: Taiyi Wang on 12 May 2022
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.

Answers (1)

Cris LaPierre
Cris LaPierre on 10 May 2022
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 Comments
Taiyi Wang
Taiyi Wang on 12 May 2022
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?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by