- Model and texture a HR object for visualization
- Duplicate the HR mesh
- Work your way to a simpler, and clean (no intersecting faces, no non-manifold edges) mesh
- Add a computational domain if you wish to simulate flow around the object, otherwise set up the different regions if you wish to simulate flow inside.
- Export to .mesh format
In a terminal, type:
medit /path/to/the/exported/object/myObject.mesh
- Left click to rotate
- Right click for the menu
- Middle click to translate
- Shift + click to get the reference of an element
- "C" to toggle the color
- "L" to toggle the wireframe
- "E" to toggle the material colors
- "B" to toggle between white and black background
- "F1" to toggle the clipping plane
- "F2" to toggle the clipping plane edition (Left button to rotate, middle button to translate)
To remesh your object with mmgs, type in a terminal:
mmgs_O3 /path/to/the/exported/object/myObject.mesh
The remeshed file will be saved as myObject.o.mesh.
You can check the output with:
medit /path/to/the/exported/object/myObject.o.mesh
To create a volume mesh of your object, type in a terminal:
tetgen -pgA /path/to/the/exported/object/myObject.mesh
or
tetgen -pgA /path/to/the/exported/object/myObject.o.mesh
The new file will have a ".1" suffix: myObject.1.mesh or myObject.o.1.mesh.
Open it in medit with:
medit /path/to/the/exported/object/myObject(.o).1.mesh
We will now remove the unnecessary geometry (tetrahedra inside your LR mesh if you used an exterior domain, and blue triangles) created by tetgen.
If you used a computational domain (flow outside an object), get the reference of the tetrahedra inside your object (with medit, Shift + click on the inside domain gives you the reference in the terminal), and execute:
python /path/to/pythonMesh/src/removeReference.py /path/to/myObject.1.mesh theReferenceOfTheInsideDomain
Make sure to replace theReferenceOfTheInsideDomain with the actual reference of the inside domain.
If you want to simulate the flow inside an object, just type:
python /path/to/pythonMesh/src/removeReference.py /path/to/myObject.1.mesh 0
The last step before running the simulation is to refine the volume mesh with mmg3d, which will add a ".o" suffix to your file name:
mmg3d_O3 /path/to/the/exported/object/myObject(.o).1.mesh
medit /path/to/the/exported/object/myObject(.o).1.o.mesh
Tip: Type "M" to toggle the scalar field (here the size of edges).
Create a new file called DEFAULT.nstokes in the same directory that myObject.mesh, which will control the simulation parameter.
Dirichlet
4 # 4 different regions
1 triangle v 0. 0. 0.
7 triangle v 0. 0. 0.
5 triangle v 0. 1. 0.
8 triangle v 0. 0. 0.
# the format for each region is:
# $referenceId triangle v $xVelocity $yVelocity $zVelocity
# Do not write a line for your outlet(s) region(s)
Domain
1 # 1 volume domain
1 1. 1. # ref 1, nu=1., rho=1.
Shift + Left click in medit to get a face reference.
Let's run the simulation:
Type in a terminal (replace 0.01 with lower values to get better results, at the cost of computation time):
nstokes -r 0.01 /path/to/the/exported/object/myObject(.o).1.o.mesh
After a while, the computation should be finished (depending on the size of your mesh). Open the file in medit:
medit /path/to/the/exported/object/myObject(.o).1.o.mesh
You should now see the velocity value:
Let's convert this file to Paraview .vtk format:
python /path/to/pythonMesh/src/convertToParaview.py /path/to/myObject.1.d.o.mesh
Open Paraview, load the newly created file (.vtk extension), and click on apply in the properties panel:
You can now add some filters (Filters menu -> search ) in order to create the appropriate visualization.
For instance:
- StreamTracer filter (change the radius, which defaults to 0, and the point source location)
- Tube
- Coloring set to "Velocity"
- Don't forget to hit apply after every modification!
Hide every object you don't want to import back to blender, and export the scene to .x3d format.
In blender, import your .x3d file, and delete the unwanted lamps and cameras.
Making sure that the rotation pivot point is at the center of the scene, rotate the imported object by 90° around the X axis, then by 180° around the Z axis:
Make sure that the imported object has a material, and that the "Vertex color paint" is checked in the material menu, in the "Options" panel.
Voila!