doyubkim / fluid-engine-dev

Fluid simulation engine for computer graphics applications
https://fluidenginedevelopment.org/
MIT License
1.84k stars 256 forks source link

How do I set up a fluid particles at rest and a fluid particles with initial velocity #310

Closed xiaoxiaoyu1872 closed 3 years ago

xiaoxiaoyu1872 commented 3 years ago

such as water-crown example, droplet has initial velocity (0, -5, 0). auto fbox = Box3::builder() .withLowerCorner({0, 0, 0}) .withUpperCorner({1, 0.25 * domain.height(), 1}) .makeShared();

auto sphere = Sphere3::builder()
                  .withCenter(domain.midPoint())
                  .withRadius(0.15 * domain.width())
                  .makeShared();

auto surfaceSet = ImplicitSurfaceSet3::builder()
                      .withExplicitSurfaces({fbox})
                      .makeShared();

auto surfaceSet_sphere = ImplicitSurfaceSet3::builder()
                  .withExplicitSurfaces({sphere})
                  .makeShared();

auto emitter = VolumeParticleEmitter3::builder()
                   .withImplicitSurface(surfaceSet)
                   .withSpacing(targetSpacing)
                   .withMaxRegion(sourceBound)
                   .withIsOneShot(true)
                   .makeShared();

auto emitter_sphere = VolumeParticleEmitter3::builder()
                   .withImplicitSurface(surfaceSet_sphere)
                   .withSpacing(targetSpacing)
                   .withMaxRegion(sourceBound)
                   .withIsOneShot(true)
                   .withInitialVelocity(Vector3D(0, -5, 0)) 
                   .makeShared();

solver->setEmitter(emitter);
solver->setEmitter(emitter_sphere);

The problem with this is that emitter_sphere will overwrite emitter

doyubkim commented 3 years ago

Hi @xiaoxiaoyu1872,

In such cases (multiple emitters), can you try creating ParticleEmitterSet3, add your emitters to it, and then add the emitter set to the solver?

xiaoxiaoyu1872 commented 3 years ago

ParticleEmitterSet3 worked! Thank you very much

doyubkim commented 3 years ago

Awesome!