Archive for the 'maillage-FEM-BEM' Category

Mesh Generation & Grid Generation on the Web

Mesh Generation & Grid Generation on the Web

The aim of this document is to provide information on mesh and grid generation: people working in the field, research groups, books and conferences. It is maintained by Robert Schneiders.

Mesh generation is an interdisciplinary area, and people from different departments are working on it: Mathematicians, computer scientists, engineers from many disciplines. Despite the fact that surprisingly many people are active in the field, often there are few contacts between researchers. The aim of this page is to improve communication between research groups and to help people to get an overview of the field.

The page is organized as follows:

<!– –>

    People and research groups: Info on meshing research at universities, companies, government labs etc.

    List of people: A directory of people working on mesh generation.

    Latest news: What’s up in mesh generation.

    Software: A list of programs, both public domain and commercial.

    Conferences: Information on conferences, summerschools, short courses etc.

    Literature: Books, reviews, online sources and course materials.

    Open positions: Career opportunities for people with background in mesh generation.

    Information on related topics: Pages with information on CFD, scientific computing, computational geometry and other fields related to mesh generation.

<!– –> Service for frequent readers: You can find all entries, sorted by time of insertion, here (there is also an archive page). <!– Click here to see the latest updates (there is also an archive page). –>

Research on mesh generation is abundant, and I don’t claim to give a complete overview. In order make this page a useful service for the mesh generation community, I need help from other people. So if you are interested in getting put on the list, or if you have any comments or hints on other sources of information on mesh generation in the net, please send me an email (

A valuable source of information is the Meshing Research Corner, a comprehensive database with literature on mesh generation. It is maintained by Steve Owen.

ParaView is an application framework as well as a turn-key application; Modeling software OpenFOAM and ParaView ; mesh processing: generation, manipulation, conversion

ParaView is an open source, multi-platform data analysis and visualization application. It has a client-server architecture to facilitate remote visualization of datasets

It is an application built on top of the Visualization Tool Kit (VTK) libraries.

The ParaView code base is designed in such a way that all of its components can be reused to quickly develop vertical applications. This flexibility allows ParaView developers to quickly develop applications.

Input/Output and File Format

  • Supports a variety of file formats including: VTK (new and legacy, all types including parallel, ascii and binary, can read and written).
  • Various polygonal file formats including STL and BYU (by default, read only, other VTK writers can be added by writing XML description).
  • Many other file formats are supported. See ParaView Readers and ParaView Writers for a full list.

CMake is a family of tools designed to build, test and package software. CMake is used to control the software compilation process using simple platform and compiler independent configuration files. CMake generates native makefiles and workspaces that can be used in the compiler environment of your choice. ParaView utilizes CMake for the software compilation process.


ParaView is used as the visualization platform for the Modeling software OpenFOAM (Open Field Operation and Manipulation).It is primarily a C++ toolbox for the customisation and extension of numerical solvers for continuum mechanics problems, including computational fluid dynamics (CFD). It comes with a growing collection of pre-written solvers applicable to a wide range of problems.

First major general-purpose CFD package to use polyhedral cells. This functionality is a natural consequence of the hierarchical description of simulation objects.

OpenFOAM compares favourably with the capabilities of most leading general-purpose commercial closed-source CFD packages. It relies on the user’s choice of third party pre- and post-processing utilities, and ships with:

  • a plugin (paraFoam) for visualisation of solution data and meshes in ParaView.
  • a wide range of mesh converters allowing import from a number of leading commercial packages
  • an automatic hexahedral mesher to mesh engineering configurations

OpenFOAM was conceived as a continuum mechanics platform but is ideal for building multi-physics simulations.

OpenCFD develop OpenFOAM in the Linux/UNIX operating system because: we believe it is the best platform for this kind of high end simulation code development and operation; Linux is efficient, robust, reliable and flexible and undergoes rapid development and improvement; Linux is open source, like OpenFOAM; Linux is very effective for parallel operation on Beowulf clusters.

OpenFOAM is open source software so people can freely compile it on any operating system they choose. Most OpenFOAM users are running Linux, so this site offers the download of binaries for selected Linux systems.

As the present time we are unaware of any binary distributions for Windows or MacOSX. However, ports to these operating systems have been the subject of debate on the OpenFOAM discussion site, which may provide the best source of information on the matter.

OpenFOAM uses finite volume numerics to solve systems of partial differential equations ascribed on any 3D unstructured mesh of polyhedral cells.

Mesh generation

OpenFOAM applications handle unstructured meshes of mixed polyhedra with any number of faces: hexahedra, tetrahedra, degenerate cells, basically anything.

Mesh generation is made simple by the fact that a cell is simply represented as a list of faces and a face as a list of vertices: this makes mesh handling very easy even for complex meshes with, say, embedded refinement or complex shapes near the boundary.

OpenFOAM is supplied with the following mesh generator tools that run in parallel.

Mesh generation tools

blockMesh A multi-block mesh generator
extrude2DMesh Takes 2D mesh (all faces 2 points only, no front and back faces) and creates a 3D mesh by extruding with specified thickness
extrudeMesh Extrude mesh from existing patch (by default outwards facing normals; optional flips faces) or from patch read from file
snappyHexMesh Automatic split hex mesher. Refines and snaps to surface

The main mesh generators cover two extremes: snappyHexMesh, that can mesh to complex CAD surfaces; blockMesh a simple file-driven block mesh generator.

Mesh manipulation

OpenFOAM is supplied with several utilties that perform mesh checking and manipulation. The full list of utilties is given below

Mesh manipulation

attachMesh Attach topologically detached mesh using prescribed mesh modifiers
autoPatch Divides external faces into patches based on (user supplied) feature angle
cellSet Selects a cell set through a dictionary
checkMesh Checks validity of a mesh
createBaffles Makes internal faces into boundary faces. Does not duplicate points, unlike mergeOrSplitBaffles
createPatch Utility to create patches out of selected boundary faces. Faces come either from existing patches or from a faceSet
deformedGeom Deforms a polyMesh using a displacement field U and a scaling factor supplied as an argument
faceSet Selects a face set through a dictionary
flattenMesh Flattens the front and back planes of a 2D cartesian mesh
insideCells Picks up cells with cell centre ’inside’ of surface. Requires surface to be closed and singly connected
mergeMeshes Merge two meshes
mergeOrSplitBaffles Detects faces that share points (baffles). Either merge them or duplicate the points
mirrorMesh Mirrors a mesh around a given plane
moveDynamicMesh Mesh motion and topological mesh changes utility
moveEngineMesh Solver for moving meshes for engine calculations.
moveMesh Solver for moving meshes
objToVTK Read obj line (not surface!) file and convert into vtk
pointSet Selects a point set through a dictionary
refineMesh Utility to refine cells in multiple directions
renumberMesh Renumbers the cell list in order to reduce the bandwidth, reading and renumbering all fields from all the time directories
rotateMesh Rotates the mesh and fields from the direcion n1   \special {t4ht= to the direction n2   \special {t4ht=
setSet Manipulate a cell/face/point set interactively
setsToZones Add pointZones/faceZones/cellZones to the mesh from similar named pointSets/faceSets/cellSets
splitMesh Splits mesh by making internal faces external. Uses attachDetach
splitMeshRegions Splits mesh into multiple regions
stitchMesh ’Stitches’ a mesh
subsetMesh Selects a section of mesh based on a cellSet
transformPoints Transforms the mesh points in the polyMesh directory according to the translate, rotate and scale options
zipUpMesh Reads in a mesh with hanging vertices and zips up the cells to guarantee that all polyhedral cells of valid shape are closed

Mesh motion

OpenFOAM adopts a novel approach to mesh motion by defining it in terms of the boundary motion which is extremely robust.

The solver need only define the the motion of the boundary and everything else will be done automatically. The open architecture of OpenFOAM solver codes allows quick and efficient implementation: mesh motion can be based on any solution variable, either local or integrated and by dynamically adjusted during the run.

Mesh motion is also transparently integrated with top-level models: the model writer does not see the additional complexity, which is conveniently packaged within the discretisation operators.

For examples of automated mesh motion in OpenFOAM, see Solutions

Mesh conversion

OpenFOAM accepts meshes generated by any of the major mesh generators and CAD systems. Listed below are converter utlities for the major commercial mesh generators. Note that it is also possible to import the meshes from most general purpose mesh generators since they will export in a format read by one of the converters.

Mesh converters

ansysToFoam Converts an ANSYS input mesh file, exported from I-DEAS, to OPENFOAM®format
cfx4ToFoam Converts a CFX 4 mesh to OPENFOAM®format
fluent3DMeshToFoam Converts a Fluent mesh to OPENFOAM®format
fluentMeshToFoam Converts a Fluent mesh to OPENFOAM®format including multiple region and region boundary handling
foamMeshToFluent Writes out the OPENFOAM®mesh in Fluent mesh format
foamToStarMesh Reads an OPENFOAM®mesh and writes a PROSTAR (v4) bnd/cel/vrt format
gambitToFoam Converts a GAMBIT mesh to OPENFOAM®format
gmshToFoam Reads .msh file as written by Gmsh
ideasUnvToFoam I-Deas unv format mesh conversion
kivaToFoam Converts a KIVA grid to OPENFOAM®format
mshToFoam Converts .msh file generated by the Adventure system
netgenNeutralToFoam Converts neutral file format as written by Netgen v4.4
plot3dToFoam Plot3d mesh (ascii/formatted format) converter
polyDualMesh Calculate the dual of a polyMesh. Adheres to all the feature and patch edges
sammToFoam Converts a STAR-CD SAMM mesh to OPENFOAM®format
star4ToFoam Converts a STAR-CD (v4) PROSTAR mesh into OPENFOAM®format
starToFoam Converts a STAR-CD PROSTAR mesh into OPENFOAM®format
tetgenToFoam Converts .ele and .node and .face files, written by tetgen
writeMeshObj For mesh debugging: writes mesh as three separate OBJ files which can be viewed with e.g. javaview

FEM, finite element method, PDE, partial differential equation;mathematica
This package allows to solve second order elliptic differential equations in two variables:

div(a*grad u) – b*u = f in the domain domain u = gD Dirichlet boundary conditions on first part of boundary a*du/dn = gN Neumann condition on the other part of the boundary

If the functions a, b f, gD and gN are given, then a numerical approximation is computed, using the method of finite elements. To generate meshes the programm EasyMesh can be used.

a general finite element environment;mathematica

The Mathematica application package AceFEM is a general finite element environment designed to solve multi-physics and multi-field problems. Using Mathematica, the program provides both extensive symbolic capabilities and the numeric efficiency of a commercial finite element environment.

AceFEM consists of two components. The main module performs tasks such as processing user-input data, mesh generation, control of solution procedures, and graphic post-processing of results. A fully integrated second module handles numerically intensive operations such as evaluation and assembly of finite element quantities, solution of linear systems of equations, contact search procedures, and more.

alliance for medical image computing Kit = free open source software platform


The NA-MIC Kit is a free open source software platform. The NA-MIC Kit is distributed under a BSD-style license without restrictions or « give-back » requirements and is intended for research, but there are not restrictions on other uses. It consists of the 3D Slicer application software, a number of tools and toolkits such as VTK and ITK, and a software engineering methodology that enables multiplatform implementations. It also draws on other « best practices » from the community to support automatic testing for quality assurance. The NA-MIC kit uses a modular approach, where the individual components can be used by themselves or together. The NA-MIC kit is fully-compatible with local installation (behind institutional firewalls) and installation as an internet service. Significant effort has been invested to ensure compatibility with standard file formats and interoperability with a large number of external applications.

See this presentation on the NA-MIC Kit for more information.

Download Central

Please go here to download Slicer software, documentation and data.

Software Packages

3D Slicer

3D Slicer is a software package for visualization and medical image computing. A tutorial for prospective users of the program can be found on the web. See our tutorials page for an introduction to the use of 3D Slicer. More…

The Visualization Toolkit VTK

The Visualization Toolkit is an object-oriented toolkit for processing, viewing and interacting with a variety of data forms including images, volumes, polygonal data, and simulation datasets such as meshes, structured grids, and hierarchical multi-resolution forms. It also supports large-scale data processing and rendering. More…

The Insight Toolkit ITK

The Insight Segmentation and Registration Toolkit (ITK) is an open-source software toolkit for performing registration and segmentation. Segmentation is the process of identifying and classifying data found in digitally sampled representations. Typically the sampled representation is an image acquired from such medical instrumentation as CT or MRI scanners. Registration is the task of aligning or developing correspondences between data. For example, in the medical environment, a CT scan may be registered with a MRI scan in order to combine the information contained in both. More…

KWKidgets GUI Toolkit

KWWidgets is an Open Source library of GUI classes based on Tcl/Tk with a C++ API. This library was originally developed by Kitware for ParaView, and now has been extended in functionality and architecture thanks to NAMIC support. More…

Teem Libraries and Command Line Tools

Teem is a coordinated group of libraries for representing, processing, and visualizing scientific raster data. Teem includes command-line tools that permit the library functions to be quickly applied to files and streams, without having to write any code. More…

XNAT Web-based Image Informatics Server

The Extensible Neuroimaging Archive Toolkit (XNAT) is an open source software platform designed to facilitate management and exploration of neuroimaging and related data. XNAT includes a secure database backend and a rich web-based user interface.

NA-MIC is working to provide a portable, easy-to-install and easy-to-administer version of XNAT that can be deployed as part the Kit. These efforts will build on ongoing work in the BIRN community to integrate Slicer with XNAT.


BatchMake is a cross platform tool for batch processing of large amount of data. BatchMake can process datasets locally or on distributed systems using Condor (a grid computing tool that enables distributed computing across the network). Some of the key features of BatchMake include: 1) a BSD License, 2) CMake-like scripting language, 3) distributed scripting via Condor, 4) a centralized remote website for online statistical analysis. 4) a user Interface using FLTK, and 5) BatchMake is cross platform. More…

CMake The Cross-platform Make Tool

CMake is used to control the software build process using simple platform, compiler and operating system independent configuration files. CMake generates native makefiles and workspaces that can be used in the development environment of your choice. That is, CMake does not attempt to replace standard development tools such as compilers and debuggers, rather it produces build files and other development resources that can benefit from automated generation. Further, once CMake configuration files are created, they can be used to produce developer resources across the many platforms that CMake supports. CMake is quite sophisticated: it is possible to support complex environments requiring system configuration, pre-processor generation, code generation, and template instantiation. More…

New: CMake has been adopted by KDE, one of the world’s largest open source software systems.

CDash, CTest, CPack Software Process Tools

As an adjunct to CMake the tools CDash, CTest, CPack are used to test and package all components of the NAMIC kit. CTest is a testing client that locally performs testing on a software repository, and then communicates the results of the testing to CDash (and other testing, dashboard servers such as DART2). CPack is a cross-platform tool for packaging, distributing and installing the NAMIC kit on various systems including Linux, Windows, and Mac OSX. More…

DART Testing Server

DART is a testing server, meaning that it gathers the results of testing from clients (such as CTest) and aggregates them on the testing « dashboard ». This dashboard is central to the NAMIC software process; it provides a centralized web site where NAMIC Kit developers and users can ascertain the day-to-day health of the software, and repair the software immediately if faults are discovered. It facilitates distributed development, and provides the stability that complex software such as the NAMIC Kit requires to support a large community of users. More…




NA-MIC Kit in Numbers

The numbers in this table are statistics characterizing the NA-MIC kit. They provide an estimate of the scale of the Kit, including approximate costs to create and total effort expended. Note that estimates such as these are required because large open-source software systems cannot be tracked via direct investment since much of the effort is voluntary in nature, and distributed across the world through a variety of organizations.
Source: Captured on May 30 2008. See the Ohloh website for an explanation of how the numbers were computed.

Package Lines of code Person years Price tag at 100k per person year
Slicer 587,919 161 $16,068,440
KWW 189,627 49 $ 4,925,590
VTK 1,344,989 385 $38,521,873
ITK 711,474 197 $19,712,495
CMAKE 213,671 56 $ 5,586,895
Total 3,047,680 848 $84,815,293

Matlab .m Unstructured Mesh Generation (Mesh2d v2.3)

Unstructured Mesh Generation (Mesh2d v2.3)

MESH2D is a toolbox for the generation and manipulation of unstructured triangular meshes in MATLAB. High quality meshes can be generated automatically for user defined geometries.

These meshes are suitable for subsequent FEM or FVM analysis.

MESH2D will automatically adapt the element size to ensure that the geometry is adequately resolved, allowing very complex geometries to be meshed with no additional user input. User defined size functions are also available, allowing the user to control mesh resolution if desired.

MESH2D is based on an iterative continuous smoothing method, and generally results in very high quality meshes with no small angles and smooth element size variations.


MESH2D v2.3 allows connected polygons to be meshed, with a compatible mesh generated along internal boundaries. MESH 2D v2.3 should also produce meshes with a higher mean element quality in most cases.

– MESH2D can produce large scale meshes, with meshes incorporating over 500,000 elements produced based on satellite coastline data.

– MESH2D allows fully user defined size functions, giving the user full control over mesh resolution if desired. A template for boundary layer regions is also included.

– MESH2D includes functions for uniform and non-uniform mesh refinement, allowing existing meshes to be refined without costly re-triangulation.

– MESH2D includes functions to assemble the connectivity information necessary for FE or FV methods.

Tested on MATLAB 6.5, 7.0, R2006b and R2007a.


Please use the following functions to launch MESH2D demos:

– meshdemo();
– mesh_collection(n);
– facedemo(n);

MESH2D is (always!) under development, so any problems or suggestions are welcome via email.

MESH2D is distributed under the GNU GPL.


matlab .m DISTMESH A Simple Mesh Generator in MATLAB

HomePage Per-Olof Persson



  • DistMesh – A Simple Mesh Generator in MATLAB

Educational MATLAB codes:

  • Tridiagonal Eigenvalues in MATLAB – Interface to LAPACK routines for computing eigenvalues of tridiagonal matrices and singular values of bidiagonal matrices
  • Level Set Demo – Simple MATLAB scripts for illustration of explicit/implicit interface tracking, reinitialization, and the fast marching method (undocumented, but see presentations for slides and notes).
  • fempoisson.m – Solves the Poisson equation on an unstructured grid (square in this example but easy to change) using linear finite elements. Good start to learn about implementation of FEM.
  • poiunit.m – Fourier solution of Poisson’s equation on the unit line, square, or cube. Good for verification of Poisson solvers, but slow if many Fourier terms are used (high accuracy).
  • laplacefft.m – Solve the Laplace equation on a rectangular domain using the FFT. Supports Dirichlet or Dirichlet/Neumann conditions. Contains the following short functions for discrete Sine and Cosine transforms:
    • dst.m – Discrete Sine Transform DST-I
    • idst.m – Inverse Discrete Sine Transform IDST-I
    • dct.m – Discrete Cosine Transform DCT-I
    • idct.m – Inverse Discrete Cosine Transform DCT-I
  • Implementation of Finite Element-Based Navier-Stokes Solver

————————–end HomePage

3-D meshes, the left plots show surface meshes and the right plots show cross sections.


DISTMESH is a MATLAB library which generates and manipulates unstructured meshes in 2D, 3D and general ND. The code is relatively simple, and the user is able to define a variety of geometric shapes, and desired mesh densities.

DISTMESH can be a very quick and flexible means of computing a set of points in a region. However, keep in mind the following flaws:

  • Especially if you are have specified some fixed points which must appear in the mesh, it is possible for DISTMESH to return multiple instances of the same point. For finite element applications, in particular, this can result in catastrophe. The program TABLE_MERGE can fix this.
  • The nodes produced by DISTMESH are not ordered or sorted in any way whatsoever.
  • Because the nodes are not ordered in any way, the triangular elements produced by DISTMESH will typically contain nodes with widely ranging indices. For finite element applications, this can result in a system matrix with an unnecessarily outrageous bandwidth. The program TRIANGULATION_RCM can fix this, after the fact.
  • The triangles produced by DISTMESH are not necessarily oriented; they are just as likely to have positive or negative orientation. Some finite element programs insist that all triangles have positive orientation. The program TRIANGULATION_ORIENT can fix this, after the fact.
  • When DISTMESH is trying to approximate a boundary, particularly a long straight boundary, it is possible for several points that really belong on the boundary to be slightly out of line. This means that they will be used to form a triangle, of very small area, and terrible conditioning. This can result in perplexing problems near the boundary.
  • Because DISTMESH uses tolerances, it is possible for some nodes to lie outside the boundary of the region; it is possible for some triangles on the boundary to lie partially outside the region; it is possible for triangles that lie partly on the boundary, but entirely within the region, to be deleted, leaving a triangular hole.
  • Once you have the mesh, you may want to know which nodes lie on the boundary. You’ll want this information, for instance, if you need to impose boundary conditions on such nodes. You can get a list of the boundary nodes using the program TRIANGULATION_BOUNDARY_NODES.


[ p, t ] = distmesh_2d ( fd, fh, h, box, iteration_max, fixed );

  • fd, the name of a distance function defining the region;
  • fh, the name of a mesh density function;
  • h, the nominal mesh spacing;
  • box, defining a box that contains the region;
  • iteration_max, which limits the number of iterations;
  • fixed, a list of points which must be included in the mesh.

and returns a triangulation defined by:

  • p, a list of node coordinates;
  • t, a list of node indices forming triangles;

Related Data and Programs:

DIST_PLOT is a MATLAB program which creates a color contour plot of the distance functions that are used by DISTMESH.

DISTMESH_3D is a MATLAB program which is a subset of the DISTMESH routines, exclusively for 3D problems.

TABLE_IO is a MATLAB library which reads and writes files using the TABLE format; these routines are used by DISTMESH when creating some output files.

TABLE_MERGE is a FORTRAN90 program which removes duplicate points from a TABLE file; it can also remove points that are « close » to each other;

TEST_TRIANGULATION is a MATLAB library which defines some test regions for triangulation.

TRIANGLE is a C program which triangulates a region.

TRIANGULATION_BOUNDARY_NODES is a MATLAB program which reads data defining a triangulation and determines which nodes lie on the boundary.

TRIANGULATION_DISPLAY_OPEN_GL is a C++ program which reads files defining a triangulation and displays an image using Open GL.

TRIANGULATION_L2Q is a MATLAB program which reads data defining a linear triangulation and adds midpoint nodes to create a quadratic triangulation.

TRIANGULATION_MASK is a MATLAB program which is compiled with a user routine that defines a region; it then reads data defining a triangulation and removes all triangles that are outside the region. This is one way to clean up an unconstrained Delaunay triangulation of a nonconvex region.

TRIANGULATION_ORDER3 is a data directory which discusses order 3 triangulations; The node and triangle files output by DISTMESH are an example of such triangulations.

TRIANGULATION_ORIENT is a MATLAB program which reads data defining a triangulation, makes sure that every triangle has positive orientation, and if not, writes a corrected triangle file.

TRIANGULATION_PLOT is a MATLAB program which plots a triangulation.

TRIANGULATION_RCM is a MATLAB program which reads data defining a triangulation, and uses the Reverse Cuthill McKee algorithm to reorder the nodes so as the reduce the bandwidth of the corresponding adjacency matrix. This can be very helpful for cases where the data is to be handled by a frontal technique, or treated as a banded linear system.

TRIANGULATION_REFINE is a MATLAB program which reads data defining a triangulation and creates a refinement of the triangulation by subdividing each triangle.


DISTMESH is Copyright (C) 2004 Per-Olof Persson.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place – Suite 330, Boston, MA 02111-1307, USA.

If you use DISTMESH in any program or publication, please acknowledge its authors by citing the reference.


    Per-Olof Persson’s web site.
  2. Per-Olof Persson and Gilbert Strang,
    A Simple Mesh Generator in MATLAB,
    SIAM Review,
    Volume 46, Number 2, June 2004, pages 329-345,
    Available online at ../../pdf/persson_distmesh.pdf

Tar File:

A GZIP’ed TAR file of the contents of this directory is available. This is only done as a convenience for users who want ALL the files, and don’t want to download them individually. This is not a convenience for me, so don’t be surprised if the tar file is somewhat out of date.

Source Code:

  • boundedges.m finds the surface edges in a triangular mesh.
  • circumcenter.m computes the circumcenters of the triangles that form a triangulation of a set of nodes.
  • dcircle.m returns the signed distance of one or more points to a circle.
  • ddiff.m returns the signed distance of one or more points to a region defined as the set difference of two regions.
  • dexpr.m returns the signed distance of one or more points to a region defined by a general symbolic expression.
  • dintersect.m returns the signed distance to a region that is the intersection of two regions.
  • distmesh_2d.m computes a mesh of a given 2D region.
  • distmesh_nd.m computes a mesh of a given ND region.
  • dmatrix.m returns the signed distance to a region by interpolation of known distance values on a Cartesian grid.
  • dpoly.m returns the signed distance of one or more points to a polygon.
  • drectangle.m returns the signed distance of one or more points to a rectangle.
  • drectangle0.m, returns the signed distance of one or more points to a rectangle.
  • dsegment.cpp (C++ file), a version of the algorithm for the signed distance of one or more points to a set of line segments, for use with a non-Windows version of MATLAB. This file must be compiled, and the corresponding MEX file must be available to define the MATLAB/C++ interface.
  • dsegment.dll (binary file), a Windows DLL file, returns the signed distance of one or more points to a set of line segments.
  • dsegment.m a pure MATLAB version of DSEGMENT, which returns the signed distance of one or more points to a set of line segments. This routine will be significantly slower than the MEXGLX or DLL versions.
  • dsegment.mexglx (binary file), used on non-Windows machines to allow MATLAB to calculate the DSEGMENT algorithm (distance to a line segment) by calling a compiled C++ routine (dsegment.cpp).
  • dsphere.m returns the signed distance of one or more points to a sphere.
  • dunion.m returns the signed distance to a region that is the union of two regions.
  • hmatrix.m computes the mesh size function by interpolation from values specified on a Cartesian grid.
  • huniform.m computes a uniform mesh size function.
  • meshdemo_nd.m demonstrates the use of the program for higher dimensional problems.
  • post_2d.m performs postprocessing for output from DISTMESH_2D.
  • protate.m rotates a set of points by a given angle.
  • pshift.m shifts a set of points by a given increment.
  • r8_epsilon.m returns the R8 arithmetic precision.
  • simp_plot_2d.m displays a plot of the triangles that form a mesh in 2D.
  • simp_plot_2d_demo.m reads and displays the node and triangle data for each problem.
  • simp_plot_3d.m displays a plot of the tetrahedrons that form a mesh in 3D.
  • simpqual.m computes the simplex quality of the mesh.
  • simpvol.m computes the volume of a simplex.
  • surftri.m finds the surface triangles in a tetrahedral mesh.
  • timestamp.m prints the current YMDHMS time as a timestamp.
  • timestring.m returns the current YMDHMS time as a string.
  • triangulation_order3_plot.m writes a PostScript file containing an image of the mesh.
  • uniformity.m computes the uniformity of the mesh.

Routines to read and write data to files (borrowed from TABLE_IO) include:


DistMesh Function Reference



Syntax: e=boundedges(p,t)
Description: Find all the boundary edges e in triangular mesh p,t.
Comments: Useful for implementation of boundary conditions for PDE solvers. See surftri for 3-D version.


Syntax: [pc,r]=circumcenter(p,t)
Description: Compute the circumcenters pc and the circumradii r for all triangles in the mesh p,t.
Comments: Not vectorized.


Syntax: d=dcircle(p,xc,yc,r)
Description: Compute signed distance function for circle centered at xc,yc with radius r.


Syntax: d=ddiff(d1,d2)
Description: Compute signed distance function for set difference of two regions described by signed distance functions d1,d2.
Comments: Not exactly the true signed distance function for the difference, for example around corners.


Syntax: d=dellipse(p,axes)
Description: Compute distance from points p to the ellipse centered at the origin with axes=[a,b].
Comments: C++ code, uses LAPACK for eigenvalue problem.


Syntax: d=dellipsoid(p,axes)
Description: Compute distance from points p to the ellipsoid centered at the origin with axes=[a,b,c].
Comments: C++ code, uses LAPACK for eigenvalue problem.


Syntax: d=dexpr(p,fin,nit,alpha)
Description: Compute signed distance function for general implicit expression fin. The parameters nit and alpha have the default values 20 and 0.1.
Comments: Requires the Symbolic Toolbox, although easy to rewrite to accept derivatives of fin as inputs. The performance is poor, a simple C implementation makes a big difference.


Syntax: d=dintersect(d1,d2)
Description: Compute signed distance function for set intersection of two regions described by signed distance functions d1,d2.
Comments: Not exactly the true signed distance function for the intersection, for example around corners.


Syntax: [p,t]=distmesh2d(fd,fh,h0,bbox,pfix,fparams)
Description: 2-D Mesh Generator. See other documentation for details on usage.


Syntax: [p,t]=distmeshnd(fd,fh,h0,bbox,pfix,fparams)
Description: 3-D Mesh Generator. See other documentation for details on usage.


Syntax: d=dmatrix(p,xx,yy,dd)
Description: Compute signed distance function by interpolation of the values dd on the Cartesian grid xx,yy.
Comments: xx,yy can be created with meshgrid.


Syntax: d=dmatrix3d(p,xx,yy,zz,dd)
Description: Compute signed distance function by interpolation of the values dd on the Cartesian grid xx,yy,zz.
Comments: xx,yy,zz can be created with ndgrid.


Syntax: d=dpoly(p,pv)
Description: Compute signed distance function for polygon with vertices pv.
Comments: Uses dsegment and inpolygon. It is usually good to provide pv as fix points to distmesh2d.


Syntax: d=drectangle(p,x1,x2,y1,y2)
Description: Compute signed distance function for rectangle with corners (x1,y1), (x2,y1), (x1,y2), (x2,y2).
Comments: Incorrect distance to the four corners, see drectangle0 for a true distance function.


Syntax: d=drectangle0(p,x1,x2,y1,y2)
Description: Compute signed distance function for rectangle with corners (x1,y1), (x2,y1), (x1,y2), (x2,y2).
Comments: See drectangle for simpler version ignoring corners.


Syntax: ds=dsegment(p,pv)
Description: Compute distance from points p to the line segments in pv.
Comments: C++ code, used by dpoly.


Syntax: d=dsphere(p,xc,yc,zc,r)
Description: Compute signed distance function for sphere centered at xc,yc,zc with radius r.


Syntax: d=dunion(d1,d2)
Description: Compute signed distance function for set union of two regions described by signed distance functions d1,d2.
Comments: Not exactly the true signed distance function for the union, for example around corners.


Syntax: [p,t]=fixmesh(p,t)
Description: Remove duplicated and unused nodes from p and update t correspondingly. Also make all elements orientations equal.


Syntax: h=hmatrix(p,xx,yy,dd,hh)
Description: Compute mesh size function by interpolation of the values hh on the Cartesian grid xx,yy.
Comments: xx,yy can be created with meshgrid. The parameter dd is not used, but included to get a syntax consistent with dmatrix.


Syntax: h=hmatrix3d(p,xx,yy,zz,dd,hh)
Description: Compute mesh size function by interpolation of the values hh on the Cartesian grid xx,yy,zz.
Comments: xx,yy,zz can be created with ndgrid. The parameter dd is not used, but included to get a syntax consistent with dmatrix.


Syntax: h=huniform(p)
Description: Implements the trivial uniform mesh size function h=1.


Syntax: meshdemo2d
Description: Demonstration of distmesh2d.


Syntax: meshdemond
Description: Demonstration of distmeshnd.


Syntax: [t2t,t2n]=mkt2t(t)
Description: Compute element connectivities from element indices.


Syntax: p=protate(p,phi)
Description: Rotate points p the angle phi around origin.


Syntax: p=pshift(p,x0,y0)
Description: Move points p by (x0,y0).


Syntax: simpplot(p,t,expr,bcol,icol)
Description: Plot 2-D or 3-D mesh p,t. The parameters expr, bcol, icol are only used in 3-D and they have default values.


Syntax: q=simpqual(p,t,type)
Description: Compute qualities of triangular or tetrahedral elements in the mesh p,t. If type==1 (default) the inradius/outradius expression is used. If type==2 a slightly different expression is used.


Syntax: v=simpvol(p,t)
Description: Compute the signed volumes of the simplex elements in the mesh p,t.


Syntax: tri=surftri(p,t)
Description: Find all the surface triangles tri in tetrahedral mesh p,t.
Comments: Used by simpplot. Also useful for implementation of boundary conditions for PDE solvers. See boundedges for 2-D version.


Syntax: u=uniformity(p,t,fh,fparams)
Description: Computes « uniformity measure », that is, how close the element sizes in the mesh p,t are to the desired mesh size function fh.


Examples and Tests:

MESHDEMO_2D runs all the 2D tests:

P01 is the circle:

P02 is the circle with a hole:

P03 is the square with a hole:

P04 is the hexagon with hexagonal hole:

P05 is the horn:

P06 is the superellipse:

P07 is the bicycle seat:

P08 is the holey pie slice:

P09 is Jeff Borggaard’s square with two hexagonal holes:

P10 is the unit square:

P11 is the L-shaped region:

P12 is the John Shadid’s H-shaped region:

P13 is the Sandia fork:

P14 is Marcus Garvie’s Lake Alpha, with Beta Island:

P15 is Sangbum Kim’s forward step region:

P16 is Kevin Pond’s elbow, a quarter of a circular annulus:

P17 is a rectangular region with a Reuleaux triangle obstacle.


Blog Stats

  • 220 804 hits

Meilleurs clics

  • Aucun


Flickr Photos

avril 2019
« Oct