projects links |
Tutorials / MeshGenerating
Generating a Meshby Carlos Remuzzi, BEng Biomedical Engineering, Freelance Developer, London UK ![]() Figure 1: A generic uncapped surface. We will refer to it as foo.vtp How vmtkMeshGenerator worksThe mesh generator for vmtk works by performing two fundamental steps, Surface Remeshing and Volume Meshing. Surface remeshingSurface remeshing is performed under the assumption that the surface requires improvement before being used for CFD. In the surface remeshing step, the surface triangle edges are resized according to two alternative methods decided by the user: - a target edge length is uniformly assigned to the whole surface.
- a scalar sizing function is adopted to resize the triangles. The scalar sizing function can be of any type, usually the distance of the surface points from the centerline will be adopted.
Volume meshingAfter the surface has been remeshed the volume is filled with a combination of tetrahedral and prismatic elements. This task relies on algorithms based on Tetgen. The parameter
Using vmtkMeshGeneratorHere you can find some examples on how to use vmtkmeshgenerator. All of the meshes displayed below have been generated from the surface in Figure 1, referred as foo.vtp. Generating a uniform element meshIt is advisable to adopt this method on branches with uniform dimensions. vmtkmeshgenerator -ifile foo.vtp -ofile foo.vtu -edgelength 0.5 Where
Generating a radius-adaptive element meshvmtksurfacereader -ifile foo.vtp --pipe vmtkcenterlines -endpoints 1 -seedselector openprofiles --pipe vmtkdistancetocenterlines -useradius 1 --pipe vmtkmeshgenerator -elementsizemode edgelengtharray -edgelengtharray DistanceToCenterlines -edgelengthfactor 0.3 -ofile foo.vtu
Adding a boundary layerAdding a boundary layer means increasing the element density close to the wall. This is advisable, for example, when dealing with hemodynamics because the solution near the wall is rather important as it's related to the wall shear stress. To add a layer simply add vmtksurfacereader -ifile foo.vtp --pipe vmtkcenterlines -endpoints 1 -seedselector openprofiles --pipe vmtkdistancetocenterlines -useradius 1 --pipe vmtkmeshgenerator -elementsizemode edgelengtharray -edgelengtharray DistanceToCenterlines -edgelengthfactor 0.3 -boundarylayer 1 -ofile foo.vtu
Converting mesh elements to quadraticvmtklineartoquadratic -ifile foo.vtu -ofile foo_q.vtu -rfile foo.vtp -entityidsarray CellEntityIds
Scaling the meshMedical images are often in mm. Typically you want your computations and results to be either in cgs or SI systems, which means scaling the model in cm (1e-1) or in m (1e-3). Let's scale our mesh in cm and store it in the usual vtu format. vmtkmeshscaling -ifile foo.vtu -scale 0.1 -ofile foo_scaled.vtu Inspecting the mesh entitiesvmtkmeshboundaryinspector -ifile foo.vtu -entityidsarray CellEntityIds
Tetrahedralizing the meshIf you added a boundary layer to your mesh you will have prismatic elements in it. Those elements are not always recognized by solvers. In those cases you'll simply need to tetrahedralize your mesh. vmtkmeshtetrahedralize -ifile foo.vtu -ofile foo_t.vtu Linearizing the meshThis allows you to linearize your mesh preserving its elements. vmtkmeshlinearize -ifile foo.vtu -ofile foo_l.vtu Exporting the mesh for your solverFluent : vmtkmeshwriter -ifile foo.vtu -entityidsarray CellEntityIds -ofile foo.msh Dolfin : vmtkmeshwriter -ifile foo.vtu -entityidsarray CellEntityIds -ofile foo.xml libMesh : vmtkmeshwriter -ifile foo.vtu -entityidsarray CellEntityIds -ofile foo.xda lifeV : vmtkmeshwriter -ifile foo.vtu -entityidsarray CellEntityIds -ofile foo.lifev |