MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / updateTimeStepSizeCFL

Method updateTimeStepSizeCFL

SPlisHSPlasH/Simulation.cpp:415–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

413}
414
415void Simulation::updateTimeStepSizeCFL()
416{
417 const Real radius = m_particleRadius;
418 Real h = TimeManager::getCurrent()->getTimeStepSize();
419 Simulation *sim = Simulation::getCurrent();
420 const unsigned int nBoundaries = sim->numberOfBoundaryModels();
421
422 // Approximate max. position change due to current velocities
423 Real maxVel = 0.0;
424 const Real diameter = static_cast<Real>(2.0)*radius;
425
426 // fluid particles
427 for (unsigned int fluidModelIndex = 0; fluidModelIndex < numberOfFluidModels(); fluidModelIndex++)
428 {
429 FluidModel *fm = getFluidModel(fluidModelIndex);
430 const unsigned int numParticles = fm->numActiveParticles();
431 for (unsigned int i = 0; i < numParticles; i++)
432 {
433 const Vector3r &vel = fm->getVelocity(i);
434 const Vector3r &accel = fm->getAcceleration(i);
435 const Real velMag = (vel + accel*h).squaredNorm();
436 if (velMag > maxVel)
437 maxVel = velMag;
438 }
439 }
440
441 // boundary particles
442 if (getBoundaryHandlingMethod() == BoundaryHandlingMethods::Akinci2012)
443 {
444 for (unsigned int i = 0; i < numberOfBoundaryModels(); i++)
445 {
446 BoundaryModel_Akinci2012 *bm = static_cast<BoundaryModel_Akinci2012*>(getBoundaryModel(i));
447 if (bm->getRigidBodyObject()->isDynamic() || bm->getRigidBodyObject()->isAnimated())
448 {
449 for (unsigned int j = 0; j < bm->numberOfParticles(); j++)
450 {
451 const Vector3r &vel = bm->getVelocity(j);
452 const Real velMag = vel.squaredNorm();
453 if (velMag > maxVel)
454 maxVel = velMag;
455 }
456 }
457 }
458 }
459 else if (sim->getBoundaryHandlingMethod() == BoundaryHandlingMethods::Koschier2017)
460 {
461 for (unsigned int boundaryModelIndex = 0; boundaryModelIndex < numberOfBoundaryModels(); boundaryModelIndex++)
462 {
463 BoundaryModel_Koschier2017 *bm = static_cast<BoundaryModel_Koschier2017*>(getBoundaryModel(boundaryModelIndex));
464 if (bm->getRigidBodyObject()->isDynamic() || bm->getRigidBodyObject()->isAnimated())
465 {
466 maxVel = std::max(maxVel, bm->getMaxVel());
467 }
468 }
469 }
470 else if (sim->getBoundaryHandlingMethod() == BoundaryHandlingMethods::Bender2019)
471 {
472 for (unsigned int boundaryModelIndex = 0; boundaryModelIndex < numberOfBoundaryModels(); boundaryModelIndex++)

Callers

nothing calls this directly

Calls 15

maxFunction · 0.85
minFunction · 0.85
numActiveParticlesMethod · 0.80
getVelocityMethod · 0.80
getRigidBodyObjectMethod · 0.80
isAnimatedMethod · 0.80
sqrtFunction · 0.50
getTimeStepSizeMethod · 0.45
squaredNormMethod · 0.45
isDynamicMethod · 0.45

Tested by

no test coverage detected