| 17 | } |
| 18 | |
| 19 | void SimulationDataPCISPH::init() |
| 20 | { |
| 21 | Simulation *sim = Simulation::getCurrent(); |
| 22 | const unsigned int nModels = sim->numberOfFluidModels(); |
| 23 | |
| 24 | m_predX.resize(nModels); |
| 25 | m_predV.resize(nModels); |
| 26 | m_densityAdv.resize(nModels); |
| 27 | m_pressure.resize(nModels); |
| 28 | m_pressureAccel.resize(nModels); |
| 29 | m_pcisph_factor.resize(nModels); |
| 30 | for (unsigned int i = 0; i < nModels; i++) |
| 31 | { |
| 32 | FluidModel *fm = sim->getFluidModel(i); |
| 33 | m_predX[i].resize(fm->numParticles(), Vector3r::Zero()); |
| 34 | m_predV[i].resize(fm->numParticles(), Vector3r::Zero()); |
| 35 | m_densityAdv[i].resize(fm->numParticles(), 0.0); |
| 36 | m_pressure[i].resize(fm->numParticles(), 0.0); |
| 37 | m_pressureAccel[i].resize(fm->numParticles(), Vector3r::Zero()); |
| 38 | } |
| 39 | |
| 40 | LOG_INFO << "Initialize PCISPH scaling factor"; |
| 41 | for (unsigned int fluidModelIndex = 0; fluidModelIndex < nModels; fluidModelIndex++) |
| 42 | { |
| 43 | FluidModel *model = sim->getFluidModel(fluidModelIndex); |
| 44 | m_pcisph_factor[fluidModelIndex] = 0.0; |
| 45 | |
| 46 | // Find prototype particle |
| 47 | // => particle with max. fluid neighbors |
| 48 | const Real density0 = model->getDensity0(); |
| 49 | |
| 50 | Vector3r sumGradW = Vector3r::Zero(); |
| 51 | Real sumGradW2 = 0.0; |
| 52 | const Real supportRadius = sim->getSupportRadius(); |
| 53 | const Real particleRadius = sim->getParticleRadius(); |
| 54 | const Real diam = static_cast<Real>(2.0) * particleRadius; |
| 55 | const Vector3r xi(0,0,0); |
| 56 | |
| 57 | // use a regular sampling around (0,0,0) |
| 58 | if (sim->is2DSimulation()) |
| 59 | { |
| 60 | Vector3r xj = { -supportRadius, -supportRadius, 0.0 }; |
| 61 | while (xj[0] <= supportRadius) |
| 62 | { |
| 63 | while (xj[1] <= supportRadius) |
| 64 | { |
| 65 | // check if xj is in the support of xi |
| 66 | if ((xi - xj).squaredNorm() < supportRadius*supportRadius) |
| 67 | { |
| 68 | const Vector3r gradW = sim->gradW(xi - xj); |
| 69 | sumGradW += gradW; |
| 70 | sumGradW2 += gradW.squaredNorm(); |
| 71 | } |
| 72 | xj[1] += diam; |
| 73 | } |
| 74 | xj[0] += diam; |
| 75 | xj[1] = -supportRadius; |
| 76 | } |
no test coverage detected