GenerateMesh via geometryFromEdges not working when large number of edges
2 ビュー (過去 30 日間)
古いコメントを表示
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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/355148/image.jpeg)
I have got a working code that will successfully achieve this with a number of edges up to 30. Shown below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/355151/image.jpeg)
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 件のコメント
Katherine Zheng
2022 年 5 月 3 日
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!
採用された回答
Katherine Zheng
2022 年 4 月 27 日
remove the bracket in the sf function like so
sf = [sf,'+',cf_i(i-1,:)]; % just for demonstration
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Contour Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!