GenerateMesh via geometryFromEdges not working when large number of edges

13 visualizzazioni (ultimi 30 giorni)
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 Commenti
Katherine Zheng
Katherine Zheng il 3 Mag 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!

Accedi per commentare.

Risposta accettata

Katherine Zheng
Katherine Zheng il 27 Apr 2022
remove the bracket in the sf function like so
sf = [sf,'+',cf_i(i-1,:)]; % just for demonstration

Più risposte (0)

Categorie

Scopri di più su Contour Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by