| 572 | } // isInstrumented |
| 573 | |
| 574 | void |
| 575 | IBInstrumentPanel::initializeHierarchyIndependentData(const Pointer<PatchHierarchy<NDIM>> hierarchy, |
| 576 | LDataManager* const l_data_manager) |
| 577 | { |
| 578 | IBAMR_TIMER_START(t_initialize_hierarchy_independent_data); |
| 579 | |
| 580 | const int coarsest_ln = 0; |
| 581 | const int finest_ln = hierarchy->getFinestLevelNumber(); |
| 582 | |
| 583 | // Determine how many flow meters/pressure gauges are present in the local |
| 584 | // data. |
| 585 | int max_meter_index = -1; |
| 586 | std::vector<int> max_node_index; |
| 587 | for (int ln = coarsest_ln; ln <= finest_ln; ++ln) |
| 588 | { |
| 589 | if (l_data_manager->levelContainsLagrangianData(ln)) |
| 590 | { |
| 591 | const Pointer<LMesh> mesh = l_data_manager->getLMesh(ln); |
| 592 | const std::vector<LNode*>& local_nodes = mesh->getLocalNodes(); |
| 593 | for (const auto& node_idx : local_nodes) |
| 594 | { |
| 595 | const IBInstrumentationSpec* const spec = node_idx->getNodeDataItem<IBInstrumentationSpec>(); |
| 596 | if (spec) |
| 597 | { |
| 598 | const int m = spec->getMeterIndex(); |
| 599 | max_meter_index = std::max(m, max_meter_index); |
| 600 | |
| 601 | const int n = spec->getNodeIndex(); |
| 602 | max_node_index.resize(max_meter_index + 1, -1); |
| 603 | max_node_index[m] = std::max(n, max_node_index[m]); |
| 604 | } |
| 605 | } |
| 606 | } |
| 607 | } |
| 608 | |
| 609 | // Communicate local data to all processes. |
| 610 | d_num_meters = IBTK_MPI::maxReduction(max_meter_index) + 1; |
| 611 | max_node_index.resize(d_num_meters, -1); |
| 612 | d_num_perimeter_nodes.clear(); |
| 613 | d_num_perimeter_nodes.resize(d_num_meters, -1); |
| 614 | for (unsigned int m = 0; m < d_num_meters; ++m) |
| 615 | { |
| 616 | d_num_perimeter_nodes[m] = max_node_index[m] + 1; |
| 617 | } |
| 618 | IBTK_MPI::maxReduction(d_num_meters > 0 ? &d_num_perimeter_nodes[0] : nullptr, d_num_meters); |
| 619 | #if !defined(NDEBUG) |
| 620 | for (unsigned int m = 0; m < d_num_meters; ++m) |
| 621 | { |
| 622 | TBOX_ASSERT(d_num_perimeter_nodes[m] > 0); |
| 623 | } |
| 624 | #endif |
| 625 | |
| 626 | // Resize arrays. |
| 627 | d_X_centroid.resize(d_num_meters); |
| 628 | d_X_perimeter.resize(d_num_meters); |
| 629 | for (unsigned int m = 0; m < d_num_meters; ++m) |
| 630 | { |
| 631 | d_X_perimeter[m].resize(boost::extents[d_num_perimeter_nodes[m]]); |
no test coverage detected