File Exchange

image thumbnail

MESH2D - Delaunay-based unstructured mesh-generation

version 3.1.0.0 (409 KB) by

MESH2D is a Delaunay-based mesh-generator for two-dimensional geometries.

97 Downloads

Updated

MESH2D is a MATLAB-based Delaunay mesh-generator for two-dimensional geometries. It is designed to generate high-quality constrained Delaunay triangulations for general polygonal regions in the plane. MESH2D provides simple and yet effective implementations of "Delaunay-refinement" and "Frontal-Delaunay" triangulation techniques, in additional to "hill-climbing" type mesh-optimisation. Support for user-defined "mesh-spacing" functions and "multi-part" geometry definitions are provided, allowing varying levels of mesh-resolution to be specified within complex domains. Algorithms implemented in MESH2D are "provably-good" - ensuring convergence, geometrical and topological correctness, and providing guarantees on algorithm termination and worst-case element quality bounds. MESH2D typically generates very high-quality output, appropriate for a variety of finite-volume/element type applications.

See TRIDEMO to get started with a set of example problems:

tridemo( 0); % a very simple example to get everything started.
tridemo( 1); % investigate the impact of the "radius-edge" threshold.
tridemo( 2); % Frontal-Delaunay vs. Delaunay-refinement refinement.
tridemo( 3); % explore impact of user-defined mesh-size constraints.
tridemo( 4); % explore impact of "hill-climbing" mesh optimisations.
tridemo( 5); % assemble triangulations for "multi-part" geometries.
tridemo( 6); % assemble triangulations with "internal" constraints.
tridemo( 7); % investigate the use of "quadtree"-type refinement.
tridemo( 8); % explore use of custom, user-defined mesh-size functions.
tridemo( 9); % larger-scale problem, mesh refinement + optimisation.
tridemo(10); % medium-scale problem, mesh refinement + optimisation.

Additional information and references are available via the Github repository (http://github.com/dengwirda/mesh2d).

MESH2D is a simplified version of my three-dimensional mesh-generation algorithm JIGSAW, providing an implementation of "provably-good" Delaunay-refinement and Frontal-Delaunay triangulation techniques. JIGSAW is available here (http://github.com/dengwirda/jigsaw-matlab).

MESH2D also makes use of my AABBTREE and FINDTRIA packages to compute efficient spatial queries and intersection tests. See (http://github.com/dengwirda/aabb-tree) and (http://github.com/dengwirda/find-tria) for details.

[1] - Darren Engwirda, Locally-optimal Delaunay-refinement and optimisation-based mesh generation, Ph.D. Thesis, School of Mathematics and Statistics, The University of Sydney, September 2014. http://hdl.handle.net/2123/13148

[2] - Darren Engwirda, Unstructured mesh methods for the Navier-Stokes equations, Honours Thesis, School of Aerospace, Mechanical and Mechatronic Engineering, The University of Sydney, November 2005.

Comments and Ratings (114)

Do you have an LGPL licensed version of this code? I am using it for academic research and would like to supply this code along with my research work to others. But the GPL license would mean others would be forced to apply GPL to their entire project if they want to use any code with this integrated. Let me know.

@Neal Morgan: I haven't been able to reproduce this issue - setting opts.disp = inf seems to suppress output for me. Would you email me an example script and a description of your MATLAB release etc.

@heyworld: I'm not sure that I understand exactly what you're asking - it's possible to setup geometries that contain subdomains (see TRIDEMO(5) for example), and to define user-specified mesh-spacing functions (see TRIDEMO(8) for instance). I hope that some combination of these features can be used to satisfy the various far-field and interior constraints you describe.

Neal Morgan

I love your program and it has been very helpful for my research. I was wondering if there is a way to suppress the refine and smooth triangulation tabular output.
I have tried setting the options.DISP={inf}; as suggested in the comments of refine2 but it does prevent the command line output.

heyworld

Dear Dr. Darren, i haver a prolem that is how to discrete two region with different resolution or size function. When we try to solve a PDE which has infinity boundary, one needs to truncate into a finite region. howerer, for approximating better with the infinity, we usually generate a larger domain whinch includes a subdomain in which we construct refined mesh. so how to do it? Please giver some suggestion or strategies. The same problem can be met in threee dimension Volume discrete. Many Thanks!

Sambit Mishra

Damn good this is !!!

Dung Tran

Hi Darren,
I found this incredibly useful a coursework project involving implementing an as-rigid-as-possible shape deformation algorithm. I wanted to experiment with other 2D meshes, but could not find anything suitable on the web. I was able to use MESH2D to make my own from tracing images and using those mouse clicks as the border vertices. Thank you for the great work.

@Jon Jon: I suggest you use the current version of the code - the new implementation is generally better / more reliable / faster, and is up-to-date with the current MATLAB toolchain.

Jon Jon

Hi,because of using history version mesh2Dv24,I've got the same problem as Marcus's(Spe 19 2013),When I use meshfaces to get 2D unstructured mesh generation for polygonal geometry I get the message: 'Warning: Duplicate data points have been detected. Some data points do not map to vertices in the triangulation. To avoid this behavior, call UNIQUE on the data points prior to calling DELAUNAY.'
In delaunayn at 58
as follow:
if dupesfound warning(message('MATLAB:delaunayn:DuplicateDataPoints'));
end
I want to know how to deal with this problem. I appreciate if any one could help me

Jon Jon

@Jon Jon: TRIDEMO contains a list of example problems, and is probably the best place to start. REFINE2 and SMOOTH2 are the primary mesh refinement + smoothing algorithms.

Jon Jon

hi I'm a new learner from China,i have a question that which file(.m) can i begin to run the program? i want to try it.
thanks a lot!

@lutzzz: Yes, you should be able to use TRICON2 to do this. In the list of edges returned, the boundary edges are those that have only 1 non-null triangle neighbour (i.e. edge(:,4) == 0). The list of boundary nodes are those referenced by these boundary edges.

lutzzz

lutzzz (view profile)

Hi again,
the modelling tool I use requires the node numbers of the outer boundaries. At first I thought I could use the nodes from my input shape, but since I'm using refinement by mesh-size function, additional nodes along the boundaries are introduced with mesh generation. Is there a way to get these using the tool?

@heyworld: It is possible to build edge-based information - the TRICON2 routine should be helpful here.

heyworld

Dear Darren, how do i calculate the eage information like eage number? the program do not output that.

@Olivier: I think this discussion is probably better suited to email. If you have a specific case you'd like me to look at, feel free to send the details.

Thanks a lot for your immediate reply from my 17 Jan 2018 topic. The process you described is already exactly what I implemented and it works perfectly already all around the profile. The difficulty remains within the Wake area where the 2 boundary layers follow side by side a curve I impose from the profile trailing edge up to the end of the mesh area. The offset curves of the Wake one have 2 different point distributions (generated with mesh2D) that are not compatible to merge quads at the middle Wake curve.
The only solution I found for the moment is (1) to perform the mentioned process, (2) to locally modify the distribution points of the 2 offset Wake curves, (3) regenerate the triangular mesh with the Delaunay function. That' works, but I'm not confident of the triangle cell skewness generated close to the modify edges.
Your tridemo 5 example shows you have already succeeded to partially impose some edge constraints. Don't you think your algorithm could be adapted up to fully impose some edge point distributions?
Best regards

@lutzzz: The code is a 'Constrained Delaunay Triangulation' (CDT) algorithm. The digits printed relate to the size of the tessellation, where |CDT1| is the number of edges (the 1-dimensional facets), and |CDT2| is the number of triangles (the 2-dimensional facets). Intersecting polygons definitely are a problem, as it is often unclear what is 'inside' or 'outside' the domain, and which constraints really need to be satisfied. The FIXGEO2 routine may be helpful in these cases.

lutzzz

lutzzz (view profile)

Thanks a lot, the tool seems to do a good job. I have a question about the output: What are |CDT1(X)| and |CDT2(X)|? I have noticed that when |CDT2(X)| doesn't grow larger with each iteration the program doesn't seem to finish and eventually crashes because of too little memory. What could be causing this behaviour? Are there some tips as to what the polygons should look like for the algorithm to converge? Are intersecting polygons a problem?

@Olivier Barbara: Not directly, no - you'd have to do some of the work and create the boundary-layer mesh yourself. If you were interested to do this, it may be possible to: (1) create an 'envelope' for the boundary-layer by 'offsetting' the required polygons, (2) mesh the remainder of the domain using MESH2D, and (3) create a compatible mesh in the boundary-layer by 'marching' elements back to the initial boundaries.

Thanks for this mesh generator.It will help me at last to relaunch some topics I gave up 10 years ago.
I started on a simple mesh around a NACA profile where I would like to impose a thin boundary layer (quads) around.
I haven't find yet if it's possible to force as an input a distribution of points on the boundary of the unstructured mesh generated with this tool. If this option exists, it will help me to merge both structured boundary layer and unstructured external mesh together with coincident points at the frontier.
This question is close to one asked by II II the 31 oct 2016 (see below).
Many thanks in advance.
Olivier Barbara

@Graham Griffiths: Typically you would start with a given geometry and call REFINE2 to build a conforming triangulation. If instead you're just looking to triangulate points, the standard DELAUNAY function might be what you're after...

Thanks for a great program!
Is it possible to start with just a list of the vertices, i.e. without specifying the triangulation.

@Robin Maye: You can specify a target mesh size distribution by defining a "mesh-spacing" function H(x,y) - i.e. the HFUN argument in REFINE2. H(x,y) defines the target length of triangle edges. Type "HELP REFINE2" for details, and see, for instance TRIDEMO(8) for example code.

Robin Maye

Hello, how do I if I want to mesh with elements of thinner size only for elements around a precise coordinate on the y-axis ?

@S W: I'm not sure about the multi-part issue -- feel free to email me that geometry and I'll look into it. No attempt is made to reorder nodes/elements for sparse bandwidth, fill-in, etc. Generally, I think it's best to leave these kind of details to the sparse-solver itself, as various strategies are available. MATLAB also provides the SYMAMD and SYMRCM routines, which can be used to compute various sparse matrix permutations.

S W

S W (view profile)

Hi Darren, thanks for a great tool. For a multipart geometry, refine2 only seems to be meshing the first 3 parts. Am I going wrong somewhere? Also is the node numbering for multiparts optimised to make a diagonal centered stiffness matrix? Thank you!

@sedat dogru: You may wish to start with the examples in TRIDEMO. In particular TRIDEMO(0) shows how to setup a simple geometry and call the triangulation routines.

sedat dogru

hello, I do not understand how to start to use it. Can you help me, please?

Thank you for quick response. I was just little confused because there is no mesh2D file. After few practices with REFINE2, I'll test TRIDEMO to understand detailed functionalities. Thank you again!

@JUNHYEONG PARK: The main triangulation routine is REFINE2. This is probably where to start. I would also encourage you to have a look at the code in TRIDEMO though -- I've tried to structure these examples to introduce various functionality.

After I downloaded zip file and unzipped it, I couldn't find mesh2D file. Can anybody recommend how to get started easily not by tridemo.m?

Erik

Erik (view profile)

Thanks for the very quick update! The extra unconnected vertices were making the FEA code unhappy.

@Erik: To prevent issues with floating-point precision near the edges of the convex hull, the domain is inflated by adding four additional vertices as an external bounding box. These are the extra vertices you see in the output. These padding vertices are never indexed by the triangulation.

While this isn't a bug, I've updated the code so that the user doesn't see this anymore. The domain is still inflated internally, but any extra vertices are pruned off the data structures before they're returned. Your example should now return only the four vertices passed as input.

Erik

Erik (view profile)

I have been using the old version for a while, this looks like a nice update. A quick question - for a very simple square geometry, I get more vertices than I expect, some of which are not in the mesh domain. Any hints as to what I am doing wrong?

Thanks!

geom = [-1 -1; 1 -1; 1 1; -1 1]
edge = [1 2;2 3;3 4;4 1]
[vert,etri,tria,tnum] = refine2(geom,edge)

vert =

-1 -1
1 -1
1 1
-1 1
-2 -2
2 -2
2 2
-2 2

Seth

Seth (view profile)

Thank you for making this code available. It makes a show stopper analysis step for many users easy to use. Well done.

Jammy

Jammy (view profile)

Can mesh2d control edge length? I used other programs before which specify the maximum triangle area (e.g. 100 m2), but they give real small elements (e.g. 10 m2). So I wonder if mesh2d can control the edge length instead of mesh area. Thank you.

Jammy

Jammy (view profile)

Genaro Beas

perfect as usual !

@NC: It's possible to pass a user-defined mesh-spacing function to the REFINE2 routine. If you already have an expected water-depth function, you should be able to build a related spacing function. Have a look at the example code in TRIDEMO for more details.

NC

NC (view profile)

Hi, I am using mesh2d to generate a computational grid to simulate water wave behaviuour in shallow water coastal environments. Does anyone have any tips on how to (automatically) implement a mesh refinement based on the water depth (finer mesh in shallower water)? Cheers

JINI

JINI (view profile)

Hi, I am trying to create my own function to define the mesh size. I want to pass some other arguments to the function I have defined, hfun1. I have done it like this, following the manual provided in mesh2d.m:
%%%%
hdata.args = {cp(1),cp(2)};
hdata.fun = @hfun1;
%%%%
function h = hfun1(x,y,args{:})
h = 10-0.1*sqrt( (x-cp(1)).^2+(y-cp(2)).^2 );
end
%%%%

When I do this I get an error "Unbalanced or unexpected parenthesis or bracket."
If I remove the brackets and say
%%%%
function h = hfun1(x,y,args)
%%%%
It says too many input arguments.
I have been trying to fix this, I am not able to understand where I am going wrong. Can somebody please help me?

Nasser Ramsis

im getting the following error:

Undefined function or variable 'tsearch'.

Error in meshfaces>boundarynodes (line 199)
i = tsearch(ph(:,1),ph(:,2),th,p(:,1),p(:,2));

Error in meshfaces (line 140)
pbnd = boundarynodes(qtree.p,qtree.t,qtree.h,node,edge,options.output);

Error in mesh2d (line 102)
[p,t,junk,stats] = meshfaces(node,edge,[],hdata,options);

magnifique ! merci !

Meghan

Meghan (view profile)

Hi, excellent work on these tools. I wonder if you could help me with something. I'm trying to alter your refine.m function to allow for another parameter to be added. I have boundary codes (0-2) at each of the original nodes, I need for those codes to remain at the same nodes and populate the new nodes made from your function, i.e. one of my boundaries has all code 1 because it is a land boundary so I need all the newly created nodes on that boundary to have a 1 value.
Thanks, and again, excellent function :)

ll ll

ll ll (view profile)

Hi, I really appreciate for you work. However, i am wondering if this tool could generate mesh with the boundary node constant. That is the mesh generated with the input node (on the edge), the new node (on the edge) will not be added.

Hello. Excellent tool. Where can I find data set of interesting 2D meshes, or data set of interesting polygons from which I can generate meshes ?

there's a version of this with some bug fixes (e.g. missing tsearch) and more examples here: http://people.sc.fsu.edu/~jburkardt/m_src/mesh2d/mesh2d.html

Hello!

This work is really awesome. Its very helpful for me. But I am facing problem with parabolic functions in distmesh2d.m
Please help me by giving an example of discretization of a domain which is an intersection of 2 parabolas in the 1st quadrant.

Thanks,
Smitha

jun liu

Hi,I've got the same problem as Marcus's(Spe 19 2013),When I use meshfaces to get 2D unstructured mesh generation for polygonal geometry I get the message: 'Warning: Duplicate data points have been detected. Some data points do not map to vertices in the triangulation. To avoid this behavior, call UNIQUE on the data points prior to calling DELAUNAY.'
In delaunayn at 58
as follow:
if dupesfound warning(message('MATLAB:delaunayn:DuplicateDataPoints'));
end
I want to know how to deal with this problem. I appreciate if any one could help me.

Thank you for your work. I am trying to use it for meshing a star but I would like to get an uniform meshing;
Is there anyway to do that without using refine ?

Felix

Felix (view profile)

Hello, first thank you for this great tool!
My question is, there is a solution to the problem with the deleted function dsearch in tinterp?

Rui Liang

Just want to inform Jeremy and Frederic that, read Mike's fix carefully. Do not just change "tsearch" to "tsearchn" but also notice the changes in the brackets after "tsearchn". It works for me.

Jeremy

Jeremy (view profile)

Hey, Got the same errors as Frederic, and tried to fix them, but it's still not working!

Sergei P.

Hi, I get error in meshdemo
I fixed the tsearch with the tserachn how (Spe 23 2013) suggsted.
Now the next error is

Error using fixmesh
Too many input arguments.

Error in meshfaces (line 157)
[p,t,fnum,fnum] = fixmesh(p,t,[],fnum);

how to fix all this ?

regards

zheng kang

Thanks Darren for sharing this. Helps a lot!

henripes

Hi,
does anyone know why this hit me with this problem:
"Checking Geometry
Undefined function or variable 'wbar'.
Error in meshfaces (line 127)
close(wbar);
Error in facedemo (line 39)
meshfaces(node,edge,face,hdata); "

Im trying to run this:

node = [0.0, 0.0; .4,0.0;0.2,0.5;0.4,0.5;0.2,1; 0.0,1; ...
0.5,0;0.5,1;...
1,0;1,1];

edge = [1,2; 2,3; 3,4; 4,5;5,6;6,1;...
2,7;7,8;8,5;...
9,10;10,11;11,8];

face{1} = [1,2,3,4,5,6];
face{2} = [7,8,9,4,3,2];
face{3} = [10,11,12,8];

hdata.hmax = 0.05;

which should be a sawtooth grating between air layers.

henripes

Hi, finally some clear meshing program also for beginners! Thanks! There is anyhow a problem with "DSEARCH" in mesh_collection(6). Is it anyhow possible to repair it?

Seth

Seth (view profile)

We have been using this function since early 2010 and has proved very valuable for creating basic 2D meshes for finite element analysis.

The only issue is that with newer releases (since R2012?) the "tsearch" function is no longer supported by Matlab.

We have used the fix proposed by Mike (23 Sep 2013) and it has worked reasonably well for our problems and was fairly simple to fix in the source code.

Thanks again Darren & Mike for the quick fix.

This type of submission is one reason the File Exchange is simply awesome.

Tanvir Faisal

there are few functions seem to be missing such as tsearch, pointLocation. any idea??

Martin

Martin (view profile)

hust

hust (view profile)

unstructured mesh generator

Excellent work! I suggest Prof Darren should try to implement some of the bugs fixed in the comments below when preparing the newer version.

KSSV

KSSV (view profile)

Excellent ...code..very useful for FEA..

liron

liron (view profile)

you are a genius!!!! awesome addition... thanks very helpful....

Thomas Benson

This is a great submission! A minor change was required for my application. Reason: The triangulation tends to be slightly over-refined on complex boundaries. For some applications this is a bonus, but for hydrodymanic modelling it is not really necessary. I therefore replaced the line in 'quadtree.m' (about line 64) which reads:

L = 2.0*dist2poly(wm,edgexy,2.0*len);

with the following:

L=len;

This helps prevent over refinement and a nice mesh. Excellent work Darren!

Abdulrahman

Abdulrahman

Great work thank you very much.

I've got a question I appreciate if any one could help, where exactly the changes can take place ? I know it would be most about the geometry but I wasn't able to play with it.

Marcus

Marcus (view profile)

I'm doing something that must be pretty standard. I'm needing to mesh a 2d domain with an internal boundary. My approach has been to create 'holes' with zero area, which imposes duplicate nodes. Mesh2d seems able to remove these and gives e.g., the message 'WARNING: 2 duplicate node(s) removed'. However, with some of my examples I get the message: 'Warning: Duplicate data points have been detected. Some data points do not map to vertices in the triangulation. To avoid this behavior, call UNIQUE on the data points prior to calling DELAUNAY.' Now what I would like to know is whether this problem in the geometry is fixed by Mesh2d? I include a simple example of the sort of problem I'm interested in.
PS. Mesh2d has proved invaluable - Thank you!
***********************************
p1 = [0 0; ...
3 0; ...
3 3; ...
0 3];
p2 = [0.5 1.5; ...
1.5 1.5; ...
1.5 2.5; ...
1.5 1.5; ...
0.5 1.5];
n1 = size(p1,1);
n2 = size(p2,1);
c1 = [(1:n1-1)', (2:n1)'; n1, 1];
c2 = [(1:n2-1)', (2:n2)'; n2, 1];
node = [p1; p2];
cnect = [c1;c2+n1];
hdata.hmax = 1;
[p,t] = mesh2d(node,cnect,hdata,[]);
*****************************************

Great routine, although I was having some issues removing redundant nodes until I changed the following in line 66 of changegeometry.m

del = nNode-i(end);

-->

del = nNode-length(i);

Mike

Mike (view profile)

This is a powerful and useful tool. It is well written and documented.

Since Mathworks abandoned tsearch, simply calling tsearchn instead works for me. Moving to tsearchn requires two changes that I am aware of:

mytesearch.m Line 68:
i(j)=tsearchn([x y],t,[xi(j) yi(j)]);

meshfaces.m Line 199:
i = tsearchn(ph,th,p);

I do not agree with the solution proposed by Chen and Barnhart. Delaunay triangulations are not unique. Their approach effectively generates a separate triangulation and searches over it. Mapping such results into the original Mesh2D triangulation is ill-advised.

There are some useful examples on meshing a 3D surface on: http://persson.berkeley.edu/distmesh/

Evgeny

Evgeny (view profile)

How can I use it on 3D surface?
Is there some algorithm to create unstructured triangular meshes for 3D geometry?

One more fix. In quadtree.m, near line 528 (right before %Undo rotation, p=rotate(p,-theta)), add:

% remove duplicate nodes
goodid=find(h~=0);
p=p(goodid,:);
h=h(goodid);
for i=1:length(goodid)
t(t==goodid(i))=i;
end

So that's three places to fix with the comments below:
meshfaces.m, line 203
mytsearch.m, line 69
quadtree.m, line 528 (or thereabouts)

**Correction**

In my tsearch, replace:
i(j) = tsearch(x,y,t,xi(j),yi(j));

with:
for k=1:size(t,1)
temp=inpolygon(xi,yi,x(t(k,:)),y(t(k,:)));
i(temp)=k;
end

Then, no need to worry about delaunay triangulations

Tsearch fix courtesy of Rowena Lohman.
tsearch.m needs to be replaced in two locations. First:

in meshfaces.m, line 203 replace:
i=tsearch(ph(:,1),ph(:,2),th,p(:,1),p(:,2));

with:

for j=1:size(th,1)
temp=inpolygon(p(:,1),p(:,2),ph(th(j,:),1),ph(th(j,:),2));
i(temp)=j;
end

In mytsearch.m line 69, replace:
i(j) = tsearch(x,y,t,xi(j),yi(j));

with

t = DelaunayTri([x y]);
i(j)= pointLocation(t,[xi(j) yi(j)]);

This uses DelaunayTri which is being fazed out, but delaunayTriangulation can be equally used

Thomas Benson

Hi Darren, thanks for this submission. Is there a version of Mesh2d that works with V2012b ? (TSEARCH.m no longer works and requires the use of DelaunayTri.m). Cheers.

Elliot

Elliot (view profile)

I too need an update to replace tsearch function. The suggested replacement is not appropriate for me as performing 'DelaunayTri' within your routine can alter the triangulation depending on initial inputs i.e. I have specified internal boundaries, DelaunayTri does not respect these boundaries when implemented in the suggested way.

Is a modified/updated version in consideration?

thanks

Song Chen

Find the following line:

p = node;
e = edge;
i = tsearch(ph(:,1),ph(:,2),th,p(:,1),p(:,2));
Change it to

p = node;
e = edge;
dt = DelaunayTri(ph);
i = pointLocation(dt,p);

These two codes should be equivalent.

Jody Klymak

tsearch is gone as of 2012a. Any hope of a modification to use DelaunyTri?

cleidinei

I think Maxim is right:

>> A = triarea([0,0; 1,0; 0.5,1],[1,2,3])

A =

1.0000e+000

I think the area of that triangle should clearly be 0.5.

Maxim

Maxim (view profile)

Hello.
I think, there are a bug in the function "triarea".
I miss a factor 0.5 in row 14.
Thanks
Maxim

Bryan

Bryan (view profile)

Hello-

Thank you very much for this package, it is exactly what I'm looking for. I do have one question/comment. In Matlab 2011a, I get a warning that tsearch is going to be retired and to use delaunayTri/pointLocation isntead. I subbed in this set of commands (seemingly appropriately), and I cannot get the code to work correctly. Could you possibly advise on this? I'm going to use the code as is for the time being and try to implement and update. I'm not sure if you would be willing to use this update as a newer revision or are currently working on this problem.

Thank you,
Bryan

Hi Philippe, you may want to have a look at the utility "connectivity" routine. Amongst other things, it will identify the boundary nodes in a mesh.

Philippe N/A

Hi and ty for the great toolbox.

I'm using this to make a mesh that I want to use in another modeling tool. This other tool requires me to give nodes that are located on the edge of the mesh figure.

So, once the mesh is generated, is there any way to retrive nodes that have been generated on the contour of the figure?

Regards,
Phil

Hi, thank you very much for your work. It looks impressive. However allow me to add a small suggestion. It would Very Nice if the Toolbox comes with a small info-note or Manual about the functions and how to start for a beginer. Appart from this you´ve made a Great Work!
Thank you again
:)

Extremely helpful, this is a great library. Well documented and simple to use. Bravo sir, bravo.

Diablo

Diablo (view profile)

Thanks so much for your file upload. This was invaluable to me

Philippe N/A

Hi there.
First of all, thank you for that excellent toolbox.
I was wondering if it was possible to specify some point inside a geometric figure. For example, in the Lake Superior demo, I would like to insert a point in a specific location in the middle of the lake so the meshing is finer around that point. However, I can’t find how to do this. I bet I have to construct a new point (let’s say p8[x,y]) and connect it with existing points. But I get lost in that process.

Any help would be greatly appreciated.

With regards,
Phil

Greg

Greg (view profile)

I love your code, but I've recently begun some efforts to see if I can't speed up the runtime a bit.

Is there a particular reason why "mydelaunayn.m" uses the "delaunayn" function instead of the "delaunay" function? As far as I can tell on my machine (with Matlab 7.10), "delaunay" is around four times faster than "delaunayn" and the code seems to function just fine when I make the replacement.

Why the following fails with meshfaces. I can run it with mesh2d

node = [0.0, 0.0; 1.0,0.0; 1.0,1.0; 0.0,1.0; 2.0,0.0; 2.0,1.0; 3.0,0.0; 3.0,1.0];
edge = [1,2; 2,3; 3,4; 4,1; 2,5; 5,6; 6,3; 5,7; 7,8; 8,6];
faces{1} = [1,2,3,4];
faces{2} = [5,6,7,2];
faces{3} = [8,9,10,6];
hdata.edgeh=[1,0.05 ;7,1];
[p,t]=mesh2d(node,edge,hdata);
%[p,t,fnum]=meshfaces(node,edge,faces,hdata);

running it with meshfaces

??? Index exceeds matrix dimensions.

Error in ==> meshpoly>getedges at 283
bnd = e(~idx,:);
% Boundary edges

Error in ==> meshpoly at 88
e = getedges(t,size(p,1));
% Unique edges

Error in ==> meshfaces at 147
[pnew,tnew] =
meshpoly(node,edge(face{k},:),qtree,pbnd,options);

Very nice tool! Thank you a lot for sharing this.

Best regards, Johannes

Very minor irritation:
In line 127 of meshfaces.m, the variable wbar is addressed but never defined.

Canh Le

This is what I was looking for. Many thanks!!

Ralph

Ralph (view profile)

Hallo!

Thank you for this great work. Really, really helpful!

I need to ask a question: When using meshfaces, is it possible to use a different 'hfun' for each face?

Thanks,
Ralph

Robert Moucha

Many thanks,

Any plans to bypass MATLAB's tsearch?
In the 2010a release "Warning: TSEARCH will be removed in a future release. Use DelaunayTri/pointLocation instead."

Just a great collection of functions, thankyou!

Seth

Seth (view profile)

Wes

Wes (view profile)

I would like to generate a mesh with certain nodes specified on the interior. When I try to do this I end up with areas of my domain that are not filled with elements. For example, I would like node[0.25 0.5] connected to node[0.75 0.5] and the mesh to fill the entire region from [0 0;1 0;1 1;0 1]. The actual meshes I would like to make have more complex node positions.

The following produces a hole in the mesh:

node=[0 0;1 0;1 1;0 1;0.25 0.5;0.75 0.5];
[p,t]=mesh2d(node);

Do you have any thoughts going 3D?

Author comment: v24 was posted to resolve a licence conflict. The Mathworks no longer allows code to be released under a GNU GPL, so this has been removed for v24.

There are some (minor) revisions to the code, based on user feedback. Specifically, v24 may be slightly slower than v23, but should generally produce higher quality meshes, especially for complex geometries.

Comments/feedback is always welcome - d_engwirda@hotmail.com

Hi, thanks again for your software. What's new in this version ( i am using v23).

Updates

3.1.0.0

Updates to description/references.

3.1.0.0

Improved support for OCTAVE.

3.0.3.0

Updates to the underlying AABB-Tree package.

3.0.2.0

Updates to 3.0.2: added TRIDIV2, improved REFINE2 / SMOOTH2, new examples in TRIDEMO.

3.0.1.0

Update project title.

3.0.0.0

Major updates all-round for MESH2D - 3.0.0.

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux

MATLAB Online Live Editor Challenge

Win cash prizes and have your live script featured on our website

Learn more

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video