14 const std::string fname =
"FieldFunctionInterpolationPoint::Initialize";
18 std::vector<uint64_t> cells_potentially_owning_point;
19 for (
const auto& cell : grid.local_cells)
21 const auto& vcc = cell.centroid_;
23 const auto nudged_point = poi + 1.0e-6*(vcc-poi);
24 if (grid.CheckPointInsideCell(cell, nudged_point))
25 cells_potentially_owning_point.push_back(cell.global_id_);
28 const int local_count =
static_cast<int>(cells_potentially_owning_point.size());
29 std::vector<int> locI_count(
Chi::mpi.process_count,0);
30 MPI_Allgather(&local_count,
36 std::vector<int> recvdispls(
Chi::mpi.process_count,0);
38 int running_count = 0;
41 recvdispls[locI] = running_count;
42 running_count += locI_count[locI];
45 const auto& sendbuf = cells_potentially_owning_point;
46 std::vector<uint64_t> recvbuf(running_count, 0);
47 MPI_Allgatherv(sendbuf.data(),
48 local_count, MPI_UINT64_T,
56 throw std::logic_error(fname +
": No cell identified containing the point.");
58 uint64_t owning_cell_gid = recvbuf.front();
59 for (
const uint64_t gid : recvbuf)
60 owning_cell_gid = std::min(owning_cell_gid, gid);
63 for (
const uint64_t gid : cells_potentially_owning_point)
64 if (gid == owning_cell_gid)
76 if (not locally_owned_)
return;
78 const auto& ref_ff = *field_functions_.front();
79 const auto& sdm = ref_ff.GetSpatialDiscretization();
80 const auto& grid = sdm.Grid();
82 const auto& uk_man = ref_ff.GetUnknownManager();
84 const auto cid = ref_component_;
87 const auto field_data = ref_ff.GetGhostedFieldVector();
89 const auto& cell = grid.cells[owning_cell_gid_];
90 const auto& cell_mapping = sdm.GetCellMapping(cell);
91 const size_t num_nodes = cell_mapping.NumNodes();
93 std::vector<double> node_dof_values(num_nodes, 0.0);
94 for (
size_t i=0; i<num_nodes; ++i)
96 const int64_t imap = sdm.MapDOFLocal(cell,i,uk_man,uid,cid);
97 node_dof_values[i] = field_data[imap];
100 std::vector<double> shape_values(num_nodes, 0.0);
101 cell_mapping.ShapeValues(point_of_interest_, shape_values);
104 for (
size_t i=0; i<num_nodes; ++i)
105 point_value_ += node_dof_values[i] * shape_values[i];
112 double global_point_value;
113 MPI_Allreduce(&point_value_,
119 return global_point_value;
static chi::MPI_Info & mpi
const MPI_Comm & comm
MPI communicator.
const int & process_count
Total number of processes.
std::vector< chi_physics::FieldFunctionGridBasedPtr > field_functions_
chi_mesh::Vector3 point_of_interest_
double GetPointValue() const
uint64_t owning_cell_gid_
void Initialize() override