Rvo wrote:What's a good value here? I'm setting it to -9.8 for the fluid world and don't change anything for the local parameters.
I think the default there is -4.8. Will it act realistic like that?
-9.8 gravity is fine; whether it is realistic depends on the definition of 'realistic'. With the default
parameters, a gravity of -1.9 is needed to make a column of fluid to fall at the same rate as a
rigid body( world scale gravity -9.8 ). At the same time, though, that gravity also makes the fluid
much more floaty, as if the simulation were performed on the Moon instead of the Earth.
When performing a real time simulation, especially on CPU, there are not really any 'more realistic'
or 'more correct' values due to the amount of approximations/hacks. For example, an accurate
stiffness for water is on the order of 10^6 or 10^7, which would require time steps less than 10^-6.
The right way to simulate an incompressible fluid with SPH is to use an iterative method (IISPH, PBF,
or constraint fluids), but those methods are also more expensive so fewer particles can be used. On
the CPU, it would amount to using, say, 3000 particles instead of 16000 particles.
Rvo wrote:I'm updating my contacts every internal callback. You set the distance for each contact,
in the code it is "distance + m_fluidLocalParameters.m_particleRadiusExpansion". This distance quite differs from my own calculation where I do the following...
The expansion radius is already accounted for; that is, the distance in the contact does not include the
expansion radius.
If there is a particle with radius 1 and expansion radius 0.5, then a sphere of radius 1.5 is used for
the collision detection. Say that there is a plane at y = 0.0, and a particle as above at y = 1.5. The
collision detection returns a distance of 0.0, but the actual distance is 0.5. For this reason, the
distance is calculated as "distance + m_fluidLocalParameters.m_particleRadiusExpansion".
The contact point being a bit off is due to the position update; the internal loop is:
- -Calculate and apply SPH forces
-Perform collision detection(generate contacts)
-Correct velocity
-Update position
So the contacts(hit point, distance, and normal) are off by 1 frame. A single frame should not make
much of a difference if a force is applied to move the particles towards the mesh, but
btFluidSphRigidCollisionDetector::performNarrowphase() can be used to update the contacts if the
current state is absolutely needed. (If that is too slow, then it would be necessary to add another
callback.)
Rvo wrote:
Anyway. At one point in time I will have "many" particles (10-20) spawning very close to each other. So they will actually very likely overlap each other. Now with the stiffness at 0.5 they will continue to push each other away which looks pretty bad. Yet it is blood so the stiffness should be somewhere around 1.5 actually, being in-compressible and all? Do you have any suggestions or should I regulate the spawning per emitter so that the particles will not overlap (and push each other away) and then maybe place several emitters close to each other to simulate a cut or bullet hole?
Not sure about the emitters, but it would probably help to use a lower stiffness and m_initialSum to
make the particles push on each other less. The default values(1.5 and 0.25) are both very high.
0.5 for the stiffness should be fine, try reducing the m_initialSum.
Rvo wrote:For the sake of my experiment, I'd like the particles to maybe look more like they can group up and form a larger droplet.
However, there's a spacing between particles now that I'm not totally sure if that can be removed. ...
Surface tension forces are necessary to make the particles form into clumps, but they are not
currently implemented. If I can find the time I'll look into implementing it.
The SPH pressure force tries to maintain a constant density, so to make the particles move closer
you could decrease the SPH particle mass, but it could mean that other parameters need to be
changed. The stiffness actually does have an effect on the particle spacing, but it is not as noticeable
unless there is a column or pool of fluid.
I don't quite understand your last point though; what is the issue with increasing the billboard radius?