| 184 | } // getNumSources |
| 185 | |
| 186 | void |
| 187 | IBStandardSourceGen::getSourceLocations(std::vector<Point>& X_src, |
| 188 | std::vector<double>& r_src, |
| 189 | Pointer<LData> X_data, |
| 190 | const Pointer<PatchHierarchy<NDIM>> /*hierarchy*/, |
| 191 | const int level_number, |
| 192 | const double /*data_time*/, |
| 193 | LDataManager* const l_data_manager) |
| 194 | { |
| 195 | if (d_n_src[level_number] == 0) return; |
| 196 | |
| 197 | #if !defined(NDEBUG) |
| 198 | TBOX_ASSERT(X_src.size() == static_cast<unsigned int>(d_n_src[level_number])); |
| 199 | TBOX_ASSERT(r_src.size() == static_cast<unsigned int>(d_n_src[level_number])); |
| 200 | #endif |
| 201 | |
| 202 | // Set the radii of the sources. |
| 203 | r_src = d_r_src[level_number]; |
| 204 | |
| 205 | // Determine the positions of the sources. |
| 206 | std::fill(X_src.begin(), X_src.end(), Point::Zero()); |
| 207 | const double* const X_node = X_data->getLocalFormVecArray()->data(); |
| 208 | const Pointer<LMesh> mesh = l_data_manager->getLMesh(level_number); |
| 209 | const std::vector<LNode*>& local_nodes = mesh->getLocalNodes(); |
| 210 | for (const auto& node_idx : local_nodes) |
| 211 | { |
| 212 | const IBSourceSpec* const spec = node_idx->getNodeDataItem<IBSourceSpec>(); |
| 213 | if (!spec) continue; |
| 214 | const int& petsc_idx = node_idx->getLocalPETScIndex(); |
| 215 | const double* const X = &X_node[NDIM * petsc_idx]; |
| 216 | const int source_idx = spec->getSourceIndex(); |
| 217 | for (unsigned int d = 0; d < NDIM; ++d) |
| 218 | { |
| 219 | X_src[source_idx][d] += X[d] / static_cast<double>(d_num_perimeter_nodes[level_number][source_idx]); |
| 220 | } |
| 221 | } |
| 222 | X_data->restoreArrays(); |
| 223 | |
| 224 | std::vector<double> X_src_flattened(NDIM * X_src.size()); |
| 225 | for (unsigned int k = 0; k < X_src.size(); ++k) |
| 226 | { |
| 227 | for (unsigned int d = 0; d < NDIM; ++d) |
| 228 | { |
| 229 | X_src_flattened[NDIM * k + d] = X_src[k][d]; |
| 230 | } |
| 231 | } |
| 232 | IBTK_MPI::sumReduction(&X_src_flattened[0], static_cast<int>(X_src_flattened.size())); |
| 233 | for (unsigned int k = 0; k < X_src.size(); ++k) |
| 234 | { |
| 235 | for (unsigned int d = 0; d < NDIM; ++d) |
| 236 | { |
| 237 | X_src[k][d] = X_src_flattened[NDIM * k + d]; |
| 238 | } |
| 239 | } |
| 240 | return; |
| 241 | } // getSourceLocations |
| 242 | |
| 243 | void |
no test coverage detected