| 2192 | |
| 2193 | |
| 2194 | void SimulatorBase::writeBoundaryState(const std::string &fileName, BoundaryModel *bm) |
| 2195 | { |
| 2196 | Simulation *sim = Simulation::getCurrent(); |
| 2197 | if (sim->getBoundaryHandlingMethod() == BoundaryHandlingMethods::Akinci2012) |
| 2198 | { |
| 2199 | BoundaryModel_Akinci2012 *model = static_cast<BoundaryModel_Akinci2012*>(bm); |
| 2200 | Partio::ParticlesDataMutable& particleData = *Partio::create(); |
| 2201 | const Partio::ParticleAttribute &attrX0 = particleData.addAttribute("position0", Partio::VECTOR, 3); |
| 2202 | const Partio::ParticleAttribute &attrX = particleData.addAttribute("position", Partio::VECTOR, 3); |
| 2203 | const Partio::ParticleAttribute &attrVel = particleData.addAttribute("velocity", Partio::VECTOR, 3); |
| 2204 | const Partio::ParticleAttribute &attrVol = particleData.addAttribute("volume", Partio::FLOAT, 1); |
| 2205 | |
| 2206 | const unsigned int numParticles = model->numberOfParticles(); |
| 2207 | |
| 2208 | for (unsigned int i = 0; i < numParticles; i++) |
| 2209 | { |
| 2210 | Partio::ParticleIndex index = particleData.addParticle(); |
| 2211 | |
| 2212 | float* val = particleData.dataWrite<float>(attrX0, index); |
| 2213 | const Vector3r &x0 = model->getPosition0(i); |
| 2214 | val[0] = (float)x0[0]; |
| 2215 | val[1] = (float)x0[1]; |
| 2216 | val[2] = (float)x0[2]; |
| 2217 | |
| 2218 | val = particleData.dataWrite<float>(attrX, index); |
| 2219 | const Vector3r &x = model->getPosition(i); |
| 2220 | val[0] = (float)x[0]; |
| 2221 | val[1] = (float)x[1]; |
| 2222 | val[2] = (float)x[2]; |
| 2223 | |
| 2224 | val = particleData.dataWrite<float>(attrVel, index); |
| 2225 | const Vector3r &v = model->getVelocity(i); |
| 2226 | val[0] = (float)v[0]; |
| 2227 | val[1] = (float)v[1]; |
| 2228 | val[2] = (float)v[2]; |
| 2229 | |
| 2230 | val = particleData.dataWrite<float>(attrVol, index); |
| 2231 | val[0] = (float)model->getVolume(i); |
| 2232 | } |
| 2233 | |
| 2234 | Partio::write(fileName.c_str(), particleData, true); |
| 2235 | particleData.release(); |
| 2236 | } |
| 2237 | } |
| 2238 | |
| 2239 | |
| 2240 | void SimulatorBase::readBoundaryState(const std::string &fileName, BoundaryModel *bm) |
nothing calls this directly
no test coverage detected