Repository navigation
Tutorials
Orlando Garcia-Feal edited this page May 20, 2019
·
9 revisions
In this case we are going to simulate a floating box moved by the action of the waves produced by a piston. This case is included in the official package of DualSPHysics . You can find extra documentation about this case in the official guide or the WIKI.
In this case it is assumed that you have installed VisualSPHysics addon for Blender, if not, you can check the installation page of this wiki.
Remember to save your project frequently to avoid loosing your work if something crashes!!
- So, once we have unzipped the DualSPHysics package, go to the
DualSPHysics_v4.2\examples\main\11_Floatingfolder. - Open the
CaseFloating_Def.xmlwith a text editor. Then modify the line<definition dp="0.1" units_comment="metres (m)">and set the parameterdpto0.25. In this way we will reduce the number of particles, so the simulation will run faster and it will be easier to learn. - We will also modify the writing time step. We will make an animation with 24fps, so we will modify the line
<parameter key="TimeOut" value="0.1" comment="Time out data" units_comment="seconds" />and change thevalueparameter to0.04. - Now we can run the simulation. If you have a Nvidia GPU run the script
wCaseFloating_win64_GPU.batif notwCaseFloating_win64_CPU.bat. There are also scripts for GNU/Linux! (xCaseFloating_linux64_GPU.shandxCaseFloating_linux64_CPU.sh). - Once we have run the simulation script, we can load it into Blender. So open Blender and create a new project.
- Delete the existing cube of the scene. For this select it with right mouse button, press
xkey andenterkey. - Now we will import the isosurface of the water. So press
Shift+A, go toMeshand click onDualSPHysics object. Go toDualSPHysics_v4.2\examples\main\11_Floating\CaseFloating_out\surfacefolder. On the lower left part of the window, checkObject Type: Fluid Object,Smooth ShadingandValidate mesh. Now double click on anySurface_XXXX.vtkfile to import the sequence. - Now we will import the floating box in a very similar way. So press
Shift+A, go toMeshand click onDualSPHysics object. Go toDualSPHysics_v4.2\examples\main\11_Floating\CaseFloating_out\boundaryfolder. On the lower left part of the window, checkObject Type: OtherandTransfer UV Maps. Now double click on anySurface_XXXX.vtkfile to import the sequence. - We can see that if we click on the timeline an change frame, the isosurface and the cube position are updated.
- Now we are going to make the foam simulation. For this we will open the system console, here we can see the simulation progress and details. In order to open it, just go to
Window menuand click onToggle System Console. If you are running Blender from GNU/Linux, this option is not available, in order to see the system console, just open a terminal and launch Blender from it by typingblender. - Select the water body by right clicking on it. Now, in the
Physicspanel, you can find a section namedDualSPHysics foam simulation. Here, we will make some modification: -
Input Path: here we will introduce the folder were the particle vtk files are placed (C:\path\to\DualSPHysics_v4.2\examples\main\11_Floating\CaseFloating_out\particles\). -
Input Prefix: the name prefix of the particle vtk files (PartFluid_). -
Ouput Path: select a folder were the foam vtk files will be placed. -
Output Prefix: the name of the foam vtk files (optional). -
XML: here, select the XML file generated by gencaseC:\path\to\DualSPHysics_v4.2\examples\main\11_Floating\CaseFloating_out\CaseFloating.xml. - Set
Ending stepto250. - The default parameters will produce almost no foam particles in this case, so we will increase the
Trapped air multiplierandWave crests multiplierto300.00. If this number is too low, no foam particles will be produced. But if it is too high, too much particles will be produced, so the simulation will be very slow and Blender could crash trying to load a huge amount of particles. So we have to play with this parameters, take a look to the system console to see number of particles produced e.g.[Stage 10] Append new particles! Total diffuse particles: XXXX. - We will set
Enable custom domain limitsto avoid foam generation in the paddle zone. So we will setMin Xto2.00. - Now click on
Run Foam Simulationbutton to start the simulation. The Blender window will freeze during the process (this should be improved!), but you can see the log of the simulation on the system console. - If you don't like the results, remember to delete the blender foam object before running the simulation again!
- Now you have your DualSPHysics simulation with foam in Blender. Now you can add some nice shaders for each object.
- The fluid simulation will look ugly because we employed a very low number of fluid particles. So once you have finished you can try a simulation with a lower
dplike0.1.