GenerateMesh via geometryFromEdges not working when large number of edges
4 views (last 30 days)
Show older comments
Elliot Bontoft
on 2 Sep 2020
Commented: Elliot Bontoft
on 3 May 2022
I am trying to write a code that will autonomously create a mesh surrounding the edges of geometric shapes created from MATLAB contour function. E.g.:
[X,Y,Z] = peaks;
v = [-1,-1];
contourf(X,Y,Z,v)
I have got a working code that will successfully achieve this with a number of edges up to 30. Shown below:
When the number of edges exceeds 30, I recieve the following error:
Error using pde.AnalyticGeometry (line 56)
Invalid geometry. To specify a function handle, use
the @ prefix.
Error in pde.EquationModel/geometryFromEdges (line
48)
gm = pde.AnalyticGeometry(gedges);
Error in generateMesh_from_contours (line 559)
geometryFromEdges(model,g);
I am unsure why this is the case. I build the geometry from the edges of the contour lines. The geometry description is built via the decsg function (https://uk.mathworks.com/help/pde/ug/decsg.html), which is comprised of 3 inputs: geometry description matrix, set formula, name-space matrix.
- The geometry description matrix, gdm, is created from the coordinate data that can be extracted to describe the contour lines from the contour plot.
- The set formula, sf, is created from an algorithm I wrote to iteratively deduct contour lines from the domain (a rectangle).
- And the name-space matrix, ns, is just a collumn vector of all the contour line IDs.
Maybe the issue is to do with memory, when the sf or gdm is too large? One thought I had was to potentially create more than one model and concatenate the data after, but I can't see a way to do this.
Please find the code attached.
In the section named 'Surface function' you can toggle different the equations that describes surfaces with different amount of contour lines (denoted by N=..., e.g. N=30).
The bulk of the work relevant to building the geometry in order to generate the mesh is done in the 'Create geometry and build SF equation' section; bar creating the geometry description matrix, gdm, which is done at various points of the 'Internal values of contours' section.
Thank you for your support and advice in advance.
14 Comments
Katherine Zheng
on 3 May 2022
Hi @Elliot Bontoft, thank you so much for your suggestion. You are right smaller the average size helps but the nodes are exceeding 250000 which is too many. So I removed some close points in the contour and the mesh nodes decreased dramatically. Yeah!
Accepted Answer
Katherine Zheng
on 27 Apr 2022
remove the bracket in the sf function like so
sf = [sf,'+',cf_i(i-1,:)]; % just for demonstration
0 Comments
More Answers (0)
See Also
Categories
Find more on Geometry and Mesh in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!