MESH2D is a MATLABbased Delaunay meshgenerator for twodimensional geometries. It is designed to generate highquality constrained Delaunay triangulations for general polygonal regions in the plane. MESH2D provides simple and yet effective implementations of "Delaunayrefinement" and "FrontalDelaunay" triangulation techniques, in additional to "hillclimbing" type meshoptimisation. Support for userdefined "meshspacing" functions and "multipart" geometry definitions are provided, allowing varying levels of meshresolution to be specified within complex domains. Algorithms implemented in MESH2D are "provablygood"  ensuring convergence, geometrical and topological correctness, and providing guarantees on algorithm termination and worstcase element quality bounds. MESH2D typically generates very highquality output, appropriate for a variety of finitevolume/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 "radiusedge" threshold.
tridemo(2); % FrontalDelaunay vs. Delaunayrefinement algorithms.
tridemo(3); % explore impact of userdefined meshsize constraints.
tridemo(4); % explore impact of "hillclimbing" mesh optimisations.
tridemo(5); % assemble triangulations for "multipart" geometries.
tridemo(6); % assemble triangulations with "internal" constraints.
tridemo(7); % investigate the use of "quadtree"type refinement.
tridemo(8); % explore use of custom, userdefined meshsize functions.
tridemo(9); % largerscale problem, mesh refinement + optimisation.
tridemo(10); % mediumscale 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 threedimensional meshgeneration algorithm JIGSAW, providing an implementation of "provablygood" Delaunayrefinement and FrontalDelaunay triangulation techniques. JIGSAW is available here: http://github.com/dengwirda/jigsawmatlab.
MESH2D also makes use of my AABBTREE and FINDTRIA packages to compute efficient spatial queries and intersection tests. See http://github.com/dengwirda/aabbtree and http://github.com/dengwirda/findtria for details.
D. Engwirda, Locallyoptimal Delaunayrefinement and optimisationbased mesh generation, Ph.D. Thesis, School of Mathematics and Statistics, The University of Sydney, http://hdl.handle.net/2123/13148, 2014.
D. Engwirda, Unstructured mesh methods for the NavierStokes equations, Honours Thesis, School of Aerospace, Mechanical and Mechatronic Engineering, The University of Sydney, 2005.
3.1.0.1  Website 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 AABBTree 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 allround for MESH2D  3.0.0. 
Inspired by: FINDTRIA  PointinSimplex queries in ddimensions., AABBTREE  A ddimensional boundingbox tree.
Inspired: Im2mesh (2D image to triangular meshes), Remove Unconnected Triangle, FGT  Fold Geometry Toolbox, Accelerating Finite Element Analysis (FEA) in MATLAB
Create scripts with code, output, and formatted text in a single executable document.
Thanks for this toolbox.
I have a question: Is there a function to export the mesh information (such as nodal number, nodal coordinate, element number)? I want to submit these message to FEM
solver. Thanks very much.
@chunfeng: No, MESH2D doesn't really have direct support for moving mesh applications. JIGSAW (https://github.com/dengwirda/jigsawmatlab) offers somewhat finer control for remeshing operations, though moving mesh workflows are often highly specialised...
Hello, what I want to ask is, when the partition area changes, can mesh generation be locally meshed without all re meshing. For example, for a moving circle in a rectangle, when the circle moves, only the area around the circle needs to be locally meshed, and other parts only need to be changed appropriately. Thank you and look forward to your reply
@happy aprillia: the list of examples in tridemo.m should get you off to a good start.
thank you for providing the toolbox. how can we use the toolbox?
@Oliver Lojek: No, I'm not sure what the issue may be at this stage  there aren't any known limitations. The best thing to do is to open an "issue" via GitHub and attach the data / scripts you're using. If I can reproduce the error I'll be able to provide a little more feedback.
Dear Darren, thank you for providing this very powerful toolbox to the public. Using the toolbox on polygons derived from shape files with geocoordinates, works well for WGS84 reference system with Latitude & Longitude values, however if I project/change the reference system and use the same polygon, Mesh2D initially generates an identical grid but when I attempt to refine the initial grid by means such as laid out in the tridemo.m (cases 3 or 8) the toolbox gets caught in an endless iteration, whereas on Latitude & Longitude it runs 45 iterations depending on the refinement settings.
Assuming it has to do with the coordinate values, since they are the only thing that changes from Lat. Long. (degree) to Universal TransMercator (UTM, kilometers), I reduced the UTM input values by subtracting the mean to obtain small numbers like the Lat./Long. case but to no avail. Has anybody encountered a similar problem? I'm guessing it's me but I cannot fathom where I go wrong.
Help would be much appreciated,
Oliver
very helpful!!!
@Elias Wirth: The best place to start are the set of examples in tridemo.m.
How do I set this up?
How can I make Delaunay in Mesh 3D?
Thanks to the author for this awesome MATLAB toolbox for generating unstructured grids!
@Ben: The meshspacing information is actually just applied everywhere  on the boundaries and in the interior  so you don't need to do anything special to get this to work. Perhaps tridemo(8) and/or tridemo(3) may be helpful here.
Hi Darren, I understand you can impose a target mesh size along the outer perimeter of the domain. But is it also possible to impose a target mesh size within the interior of the domain? In other words: is there a way to locally refine in certain areas inside the domain, based on a file describing the target mesh size in 2D?
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 userspecified meshspacing functions (see TRIDEMO(8) for instance). I hope that some combination of these features can be used to satisfy the various farfield and interior constraints you describe.
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.
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!
Damn good this is !!!
Hi Darren,
I found this incredibly useful a coursework project involving implementing an asrigidaspossible 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 uptodate with the current MATLAB toolchain.
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: 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.
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 nonnull triangle neighbour (i.e. edge(:,4) == 0). The list of boundary nodes are those referenced by these boundary edges.
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 meshsize 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 edgebased information  the TRICON2 routine should be helpful here.
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 1dimensional facets), and CDT2 is the number of triangles (the 2dimensional 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.
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 boundarylayer mesh yourself. If you were interested to do this, it may be possible to: (1) create an 'envelope' for the boundarylayer by 'offsetting' the required polygons, (2) mesh the remainder of the domain using MESH2D, and (3) create a compatible mesh in the boundarylayer 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 "meshspacing" 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.
Hello, how do I if I want to mesh with elements of thinner size only for elements around a precise coordinate on the yaxis ?
@S W: I'm not sure about the multipart 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, fillin, etc. Generally, I think it's best to leave these kind of details to the sparsesolver itself, as various strategies are available. MATLAB also provides the SYMAMD and SYMRCM routines, which can be used to compute various sparse matrix permutations.
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.
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?
Thanks for the very quick update! The extra unconnected vertices were making the FEA code unhappy.
@Erik: To prevent issues with floatingpoint 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.
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
Thank you for making this code available. It makes a show stopper analysis step for many users easy to use. Well done.
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.
perfect as usual !
@NC: It's possible to pass a userdefined meshspacing function to the REFINE2 routine. If you already have an expected waterdepth function, you should be able to build a related spacing function. Have a look at the example code in TRIDEMO for more details.
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
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 = 100.1*sqrt( (xcp(1)).^2+(ycp(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?
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 !
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 (02) 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 :)
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
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 ?
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?
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.
Hey, Got the same errors as Frederic, and tried to fix them, but it's still not working!
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
Thanks Darren for sharing this. Helps a lot!
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.
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?
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.
there are few functions seem to be missing such as tsearch, pointLocation. any idea??
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.
Excellent ...code..very useful for FEA..
you are a genius!!!! awesome addition... thanks very helpful....
This is a great submission! A minor change was required for my application. Reason: The triangulation tends to be slightly overrefined 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!
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.
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:n11)', (2:n1)'; n1, 1];
c2 = [(1:n21)', (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 = nNodei(end);
>
del = nNodelength(i);
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 illadvised.
There are some useful examples on meshing a 3D surface on: http://persson.berkeley.edu/distmesh/
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
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.
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
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.
tsearch is gone as of 2012a. Any hope of a modification to use DelaunyTri?
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.
Hello.
I think, there are a bug in the function "triarea".
I miss a factor 0.5 in row 14.
Thanks
Maxim
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.
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 infonote 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.
Thanks so much for your file upload. This was invaluable to me
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
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.
This is what I was looking for. Many thanks!!
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
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!
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).