| 1093 | } |
| 1094 | |
| 1095 | void SimulatorBase::initFluidData() |
| 1096 | { |
| 1097 | LOG_INFO << "Initialize fluid particles"; |
| 1098 | |
| 1099 | Simulation *sim = Simulation::getCurrent(); |
| 1100 | const std::string& sceneFile = SceneConfiguration::getCurrent()->getSceneFile(); |
| 1101 | const Utilities::SceneLoader::Scene& scene = SceneConfiguration::getCurrent()->getScene(); |
| 1102 | |
| 1103 | ////////////////////////////////////////////////////////////////////////// |
| 1104 | // Determine number of different fluid IDs |
| 1105 | ////////////////////////////////////////////////////////////////////////// |
| 1106 | std::map<std::string, unsigned int> fluidIDs; |
| 1107 | unsigned int index = 0; |
| 1108 | for (unsigned int i = 0; i < scene.fluidBlocks.size(); i++) |
| 1109 | { |
| 1110 | if (fluidIDs.find(scene.fluidBlocks[i]->id) == fluidIDs.end()) |
| 1111 | fluidIDs[scene.fluidBlocks[i]->id] = index++; |
| 1112 | } |
| 1113 | for (unsigned int i = 0; i < scene.fluidModels.size(); i++) |
| 1114 | { |
| 1115 | if (fluidIDs.find(scene.fluidModels[i]->id) == fluidIDs.end()) |
| 1116 | fluidIDs[scene.fluidModels[i]->id] = index++; |
| 1117 | } |
| 1118 | for (unsigned int i = 0; i < scene.emitters.size(); i++) |
| 1119 | { |
| 1120 | if (fluidIDs.find(scene.emitters[i]->id) == fluidIDs.end()) |
| 1121 | fluidIDs[scene.emitters[i]->id] = index++; |
| 1122 | } |
| 1123 | const unsigned int numberOfFluidModels = static_cast<unsigned int>(fluidIDs.size()); |
| 1124 | |
| 1125 | std::vector<std::vector<Vector3r>> fluidParticles; |
| 1126 | std::vector<std::vector<Vector3r>> fluidVelocities; |
| 1127 | std::vector<std::vector<unsigned int>> fluidObjectIds; |
| 1128 | fluidParticles.resize(numberOfFluidModels); |
| 1129 | fluidVelocities.resize(numberOfFluidModels); |
| 1130 | fluidObjectIds.resize(numberOfFluidModels); |
| 1131 | |
| 1132 | createFluidBlocks(fluidIDs, fluidParticles, fluidVelocities, fluidObjectIds); |
| 1133 | |
| 1134 | std::string base_path = FileSystem::getFilePath(sceneFile); |
| 1135 | |
| 1136 | const bool useCache = getUseParticleCaching(); |
| 1137 | std::string scene_path = FileSystem::getFilePath(sceneFile); |
| 1138 | string cachePath = scene_path + "/Cache"; |
| 1139 | sim->setCachePath(cachePath); |
| 1140 | sim->setUseCache(useCache); |
| 1141 | |
| 1142 | unsigned int startIndex = 0; |
| 1143 | unsigned int endIndex = 0; |
| 1144 | for (unsigned int i = 0; i < scene.fluidModels.size(); i++) |
| 1145 | { |
| 1146 | const unsigned int fluidIndex = fluidIDs[scene.fluidModels[i]->id]; |
| 1147 | const unsigned int startIndex = (unsigned int)fluidParticles[fluidIndex].size(); |
| 1148 | const Matrix3r rotation = AngleAxisr(scene.fluidModels[i]->angle, scene.fluidModels[i]->axis).toRotationMatrix(); |
| 1149 | |
| 1150 | std::string fileName; |
| 1151 | if (FileSystem::isRelativePath(scene.fluidModels[i]->samplesFile)) |
| 1152 | fileName = base_path + "/" + scene.fluidModels[i]->samplesFile; |
nothing calls this directly
no test coverage detected