15 const std::vector<double>& input,
22 const auto& dfem_dof_global2local_map =
25 auto input_with_ghosts = vgc->MakeGhostedVector(input);
26 vgc->CommunicateGhostEntries(input_with_ghosts);
28 typedef const int64_t cint64_t;
30 const auto& grid = pwld_sdm.
Grid();
32 const size_t num_unknowns = uk_man.
unknowns_.size();
36 std::vector<double> cont_input(num_cfem_local_dofs, 0.0);
37 std::vector<double> cont_input_ctr(num_cfem_local_dofs, 0.0);
39 std::map<int64_t, int64_t> cfem_dof_global2local_map;
42 std::set<uint64_t> partition_bndry_vertex_id_set;
43 for (
const auto& cell : grid.local_cells)
46 const size_t num_nodes = cell_mapping.
NumNodes();
48 for (
size_t i = 0; i < num_nodes; ++i)
50 for (
size_t u = 0; u < num_unknowns; ++u)
52 const size_t num_components = uk_man.
unknowns_[u].num_components_;
53 for (
size_t c = 0; c < num_components; ++c)
55 cint64_t dof_dfem_map = pwld_sdm.
MapDOFLocal(cell, i, uk_man, u, c);
56 cint64_t dof_cfem_map = pwlc_sdm.
MapDOFLocal(cell, i, uk_man, u, c);
57 cint64_t dof_cfem_map_globl = pwlc_sdm.
MapDOF(cell, i, uk_man, u, c);
59 cfem_dof_global2local_map[dof_cfem_map_globl] = dof_cfem_map;
61 const double phi_value = input[dof_dfem_map];
63 cont_input[dof_cfem_map] += phi_value;
64 cont_input_ctr[dof_cfem_map] += 1.0;
69 for (
const auto& face : cell.faces_)
70 if (face.has_neighbor_)
71 if (not grid.IsCellLocal(face.neighbor_id_))
72 for (
const uint64_t vid : face.vertex_ids_)
73 partition_bndry_vertex_id_set.insert(vid);
77 const auto ghost_cell_ids = grid.cells.GetGhostGlobalIDs();
78 const auto& vid_set = partition_bndry_vertex_id_set;
79 for (
const auto global_id : ghost_cell_ids)
81 const auto& cell = grid.cells[global_id];
83 const size_t num_nodes = cell_mapping.
NumNodes();
85 for (
size_t i = 0; i < num_nodes; ++i)
87 if (vid_set.find(cell.vertex_ids_[i]) == vid_set.end())
continue;
89 for (
size_t u = 0; u < num_unknowns; ++u)
91 const size_t num_components = uk_man.
unknowns_[u].num_components_;
92 for (
size_t c = 0; c < num_components; ++c)
94 cint64_t dof_dfem_map_globl = pwld_sdm.
MapDOF(cell, i, uk_man, u, c);
95 cint64_t dof_cfem_map_globl = pwlc_sdm.
MapDOF(cell, i, uk_man, u, c);
96 if (cfem_dof_global2local_map.count(dof_cfem_map_globl) > 0)
98 cint64_t dof_dfem_map =
99 dfem_dof_global2local_map.at(dof_dfem_map_globl);
100 cint64_t dof_cfem_map =
101 cfem_dof_global2local_map[dof_cfem_map_globl];
103 const double phi_value = input_with_ghosts[dof_dfem_map];
105 cont_input[dof_cfem_map] += phi_value;
106 cont_input_ctr[dof_cfem_map] += 1.0;
115 const size_t num_vals = cont_input.size();
116 for (
size_t k = 0; k < num_vals; ++k)
117 cont_input[k] /= cont_input_ctr[k];
122 for (
const auto& cell : grid.local_cells)
125 const size_t num_nodes = cell_mapping.
NumNodes();
127 for (
size_t i = 0; i < num_nodes; ++i)
129 for (
size_t u = 0; u < num_unknowns; ++u)
131 const size_t num_components = uk_man.
unknowns_[u].num_components_;
132 for (
size_t c = 0; c < num_components; ++c)
134 cint64_t dof_dfem_map = pwld_sdm.
MapDOFLocal(cell, i, uk_man, u, c);
135 cint64_t dof_cfem_map = pwlc_sdm.
MapDOFLocal(cell, i, uk_man, u, c);
137 const double phi_value = cont_input[dof_cfem_map];
139 output[dof_dfem_map] = phi_value;
size_t GetNumLocalAndGhostDOFs(const UnknownManager &unknown_manager) const
const CellMapping & GetCellMapping(const chi_mesh::Cell &cell) const
const chi_mesh::MeshContinuum & Grid() const
virtual int64_t MapDOF(const chi_mesh::Cell &cell, unsigned int node, const UnknownManager &unknown_manager, unsigned int unknown_id, unsigned int component) const =0
virtual int64_t MapDOFLocal(const chi_mesh::Cell &cell, unsigned int node, const UnknownManager &unknown_manager, unsigned int unknown_id, unsigned int component) const =0
std::vector< Unknown > unknowns_
static std::vector< double > NodallyAveragedPWLDVector(const std::vector< double > &input, const chi_math::SpatialDiscretization &pwld_sdm, const chi_math::SpatialDiscretization &pwlc_sdm, const chi_math::UnknownManager &uk_man, const XXPowerIterationKEigenSCDSA::GhostInfo &ghost_info)
VecGhostCommPtr vector_ghost_communicator
std::map< int64_t, int64_t > ghost_global_id_2_local_map