18 const std::vector<double>& phi_in)
20 typedef const int64_t cint64;
27 const int gsi = groupset.
groups_.front().id_;
28 const size_t gss = groupset.
groups_.size();
30 const size_t diff_num_local_dofs =
32 : diff_sdm.GetNumLocalDOFs(diff_uk_man);
34 std::vector<double> phi_data;
41 VecDbl output_phi_local(diff_num_local_dofs, 0.0);
45 const auto& cell_mapping = lbs_sdm.GetCellMapping(cell);
46 const size_t num_nodes = cell_mapping.NumNodes();
48 for (
size_t i = 0; i < num_nodes; i++)
50 cint64 diff_phi_map = diff_sdm.MapDOFLocal(cell, i, diff_uk_man, 0, 0);
51 cint64 lbs_phi_map = lbs_sdm.MapDOFLocal(cell, i, phi_uk_man, 0, gsi);
53 double* output_mapped = &output_phi_local[diff_phi_map];
54 const double* phi_in_mapped = &phi_data[lbs_phi_map];
56 for (
size_t g = 0; g < gss; g++)
58 output_mapped[g] = phi_in_mapped[g];
63 return output_phi_local;
70 const std::vector<double>& input,
71 std::vector<double>& output)
73 typedef const int64_t cint64;
80 const int gsi = groupset.
groups_.front().id_;
81 const size_t gss = groupset.
groups_.size();
83 const size_t diff_num_local_dofs =
85 : diff_sdm.GetNumLocalDOFs(diff_uk_man);
88 "Vector size mismatch");
92 const auto& cell_mapping = lbs_sdm.GetCellMapping(cell);
93 const size_t num_nodes = cell_mapping.NumNodes();
95 for (
size_t i = 0; i < num_nodes; i++)
97 cint64 diff_phi_map = diff_sdm.MapDOFLocal(cell, i, diff_uk_man, 0, 0);
98 cint64 lbs_phi_map = lbs_sdm.MapDOFLocal(cell, i, phi_uk_man, 0, gsi);
100 const double* input_mapped = &input[diff_phi_map];
101 double* output_mapped = &output[lbs_phi_map];
103 for (
int g = 0; g < gss; g++)
104 output_mapped[g] = input_mapped[g];
116 Chi::log.
Log() <<
"Making PWLD ghost communicator";
121 Chi::log.
Log() <<
"Number of global dofs" << num_globl_dofs;
123 const size_t num_unknowns = uk_man.
unknowns_.size();
126 std::set<int64_t> global_dof_ids_set;
130 for (
const auto global_id : ghost_cell_ids)
132 const auto& cell = grid.cells[global_id];
134 const size_t num_nodes = cell_mapping.
NumNodes();
136 for (
size_t i = 0; i < num_nodes; ++i)
138 for (
size_t u = 0; u < num_unknowns; ++u)
140 const size_t num_comps = uk_man.
unknowns_[u].num_components_;
141 for (
size_t c = 0; c < num_comps; ++c)
143 const int64_t dof_map = sdm.
MapDOF(cell, i, uk_man, u, c);
144 global_dof_ids_set.insert(dof_map);
151 std::vector<int64_t> global_indices(global_dof_ids_set.begin(),
152 global_dof_ids_set.end());
155 auto vgc = std::make_shared<chi_math::VectorGhostCommunicator>(
156 num_local_dofs, num_globl_dofs, global_indices,
Chi::mpi.comm);
159 std::map<int64_t, int64_t> ghost_global_id_2_local_map;
162 for (
const auto ghost_id : global_indices)
164 ghost_global_id_2_local_map[ghost_id] =
165 static_cast<int64_t
>(num_local_dofs + k++);
169 Chi::log.
Log() <<
"Done making PWLD ghost communicator";
170 return {vgc, ghost_global_id_2_local_map};
#define ChiLogicalErrorIf(condition, message)
static chi::MPI_Info & mpi
LogStream Log(LOG_LVL level=LOG_0)
const CellMapping & GetCellMapping(const chi_mesh::Cell &cell) const
size_t GetNumGlobalDOFs(const UnknownManager &unknown_manager) 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
size_t GetNumLocalDOFs(const UnknownManager &unknown_manager) const
std::vector< Unknown > unknowns_
std::vector< uint64_t > GetGhostGlobalIDs() const
LocalCellHandler local_cells
std::vector< LBSGroup > groups_
const chi_math::SpatialDiscretization & SpatialDiscretization() const
const chi_math::UnknownManager & UnknownManager() const
const chi_mesh::MeshContinuum & Grid() const
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)
GhostInfo lbs_pwld_ghost_info_
std::vector< double > CopyOnlyPhi0(const LBSGroupset &groupset, const std::vector< double > &phi_in)
DiffusionSolverPtr diffusion_solver_
void ProjectBackPhi0(const LBSGroupset &groupset, const std::vector< double > &input, std::vector< double > &output)
SDMPtr continuous_sdm_ptr_
GhostInfo MakePWLDVecGhostCommInfo(const chi_math::SpatialDiscretization &sdm, const chi_math::UnknownManager &uk_man)
std::vector< double > VecDbl