for each particle find lower grid check if out of range, if out, remove it get the containing cell set bnodes of the cell add the particle to the cell add bnodes to the cell
| 1185 | // add the particle to the cell |
| 1186 | // add bnodes to the cell |
| 1187 | int BackgroundMesh::addParticles() { |
| 1188 | // for all particles |
| 1189 | TaggedObjectIter& meshes = OPS_getAllMesh(); |
| 1190 | Mesh* mesh = 0; |
| 1191 | while ((mesh = dynamic_cast<Mesh*>(meshes())) != 0) { |
| 1192 | ParticleGroup* group = dynamic_cast<ParticleGroup*>(mesh); |
| 1193 | if (group == 0) { |
| 1194 | continue; |
| 1195 | } |
| 1196 | |
| 1197 | // check group tag |
| 1198 | if (group->getTag() == contact_tag) { |
| 1199 | opserr << "WARNING: the particle group tag " |
| 1200 | << contact_tag; |
| 1201 | opserr |
| 1202 | << " is reserved for internal use. Please select a " |
| 1203 | "different one\n"; |
| 1204 | return -1; |
| 1205 | } |
| 1206 | |
| 1207 | // remove particles |
| 1208 | VInt rm(group->numParticles(), 0); |
| 1209 | |
| 1210 | // for all particles |
| 1211 | for (int j = 0; j < group->numParticles(); j++) { |
| 1212 | // get particle |
| 1213 | Particle* p = group->getParticle(j); |
| 1214 | if (p == 0) continue; |
| 1215 | |
| 1216 | // get particle coordinates |
| 1217 | const VDouble& crds = p->getCrds(); |
| 1218 | |
| 1219 | // get index |
| 1220 | VInt index; |
| 1221 | lowerIndex(crds, index); |
| 1222 | |
| 1223 | // if out of range |
| 1224 | for (int i = 0; i < (int)index.size(); ++i) { |
| 1225 | if (index[i] < lower[i] || index[i] >= upper[i]) { |
| 1226 | rm[j] = 1; |
| 1227 | break; |
| 1228 | } |
| 1229 | } |
| 1230 | if (rm[j] == 1) continue; |
| 1231 | |
| 1232 | // get bcell |
| 1233 | BCell& bcell = bcells[index]; |
| 1234 | |
| 1235 | // add particles |
| 1236 | bcell.add(p); |
| 1237 | |
| 1238 | // if initial check structure cell |
| 1239 | if (bcell.getType() == BACKGROUND_STRUCTURE) { |
| 1240 | continue; |
| 1241 | } |
| 1242 | |
| 1243 | // add bnodes of the cell |
| 1244 | if (bcell.getNodes().empty()) { |
nothing calls this directly
no test coverage detected