11 const size_t first_grp =
groups_.front().id_;
12 const size_t final_grp =
groups_.back().id_;
16 typedef const int64_t cint64_t;
17 for (
const auto& cell :
grid_ptr_->local_cells)
19 const auto& cell_mapping = sdm.GetCellMapping(cell);
20 const size_t num_nodes = cell_mapping.NumNodes();
22 for (
size_t i=0; i<num_nodes; ++i)
27 double* phi = &phi_vector[dof_map];
29 for (
size_t g=first_grp; g<=final_grp; ++g)
41 std::vector<double>* y_ptr;
47 throw std::logic_error(
"SetGSPETScVecFromPrimarySTLvector");
59 const std::vector<double>* y_ptr;
65 throw std::logic_error(
"SetGSPETScVecFromPrimarySTLvector");
69 VecGetArray(x,&x_ref);
71 int gsi = groupset.
groups_.front().id_;
72 int gsf = groupset.
groups_.back().id_;
76 for (
const auto& cell : grid_ptr_->local_cells)
78 auto& transport_view = cell_transport_views_[cell.local_id_];
80 for (
int i=0; i < cell.vertex_ids_.size(); i++)
82 for (
int m=0; m < num_moments_; m++)
84 size_t mapping = transport_view.MapDOF(i,m,gsi);
85 for (
int g=0; g<gss; g++)
88 x_ref[index] = (*y_ptr)[mapping+g];
94 VecRestoreArray(x,&x_ref);
103 std::vector<double>* y_ptr;
109 throw std::logic_error(
"SetPrimarySTLvectorFromGSPETScVec");
113 VecGetArrayRead(x_src,&x_ref);
115 int gsi = groupset.
groups_.front().id_;
116 int gsf = groupset.
groups_.back().id_;
120 for (
const auto& cell : grid_ptr_->local_cells)
122 auto& transport_view = cell_transport_views_[cell.local_id_];
124 for (
int i=0; i < cell.vertex_ids_.size(); i++)
126 for (
int m=0; m < num_moments_; m++)
128 size_t mapping = transport_view.MapDOF(i,m,gsi);
129 for (
int g=0; g<gss; g++)
132 (*y_ptr)[mapping+g] = x_ref[index];
138 VecRestoreArrayRead(x_src,&x_ref);
145 const std::vector<double>& x_src,
146 std::vector<double>& y)
148 int gsi = groupset.
groups_.front().id_;
149 size_t gss = groupset.
groups_.size();
151 for (
const auto& cell : grid_ptr_->local_cells)
153 auto& transport_view = cell_transport_views_[cell.local_id_];
155 for (
int i=0; i < cell.vertex_ids_.size(); i++)
157 for (
int m=0; m < num_moments_; m++)
159 size_t mapping = transport_view.MapDOF(i,m,gsi);
160 for (
int g=0; g<gss; g++)
162 y[mapping+g] = x_src[mapping+g];
176 std::vector<double>* y_ptr;
177 switch (to_which_phi)
182 throw std::logic_error(
"GSScopedCopyPrimarySTLvectors");
185 std::vector<double>* x_src_ptr;
186 switch (from_which_phi)
191 throw std::logic_error(
"GSScopedCopyPrimarySTLvectors");
194 int gsi = groupset.
groups_.front().id_;
195 size_t gss = groupset.
groups_.size();
197 for (
const auto& cell : grid_ptr_->local_cells)
199 auto& transport_view = cell_transport_views_[cell.local_id_];
201 for (
int i=0; i < cell.vertex_ids_.size(); i++)
203 for (
int m=0; m < num_moments_; m++)
205 size_t mapping = transport_view.MapDOF(i,m,gsi);
206 for (
int g=0; g<gss; g++)
208 (*y_ptr)[mapping+g] = (*x_src_ptr)[mapping+g];
219 int last_group_id,
Vec x,
220 const std::vector<double>& y)
223 VecGetArray(x,&x_ref);
225 int gsi = first_group_id;
226 int gsf = last_group_id;
230 for (
const auto& cell : grid_ptr_->local_cells)
232 auto& transport_view = cell_transport_views_[cell.local_id_];
234 for (
int i=0; i < cell.vertex_ids_.size(); i++)
236 for (
int m=0; m < num_moments_; m++)
238 size_t mapping = transport_view.MapDOF(i,m,gsi);
239 for (
int g=0; g<gss; g++)
242 x_ref[index] = y[mapping+g];
248 VecRestoreArray(x,&x_ref);
256 int last_group_id,
Vec x_src,
257 std::vector<double>& y)
260 VecGetArrayRead(x_src,&x_ref);
262 int gsi = first_group_id;
263 int gsf = last_group_id;
267 for (
const auto& cell : grid_ptr_->local_cells)
269 auto& transport_view = cell_transport_views_[cell.local_id_];
271 for (
int i=0; i < cell.vertex_ids_.size(); i++)
273 for (
int m=0; m < num_moments_; m++)
275 size_t mapping = transport_view.MapDOF(i,m,gsi);
276 for (
int g=0; g<gss; g++)
279 y[mapping+g] = x_ref[index];
285 VecRestoreArrayRead(x_src,&x_ref);
294 const std::vector<double>* y_ptr;
300 throw std::logic_error(
"SetMultiGSPETScVecFromPrimarySTLvector");
304 VecGetArray(x,&x_ref);
307 for (
int gs_id : gs_ids)
309 const auto& groupset = groupsets_.at(gs_id);
311 int gsi = groupset.groups_.front().id_;
312 int gsf = groupset.groups_.back().id_;
315 for (
const auto& cell : grid_ptr_->local_cells)
317 auto& transport_view = cell_transport_views_[cell.local_id_];
319 for (
int i=0; i < cell.vertex_ids_.size(); i++)
321 for (
int m=0; m < num_moments_; m++)
323 size_t mapping = transport_view.MapDOF(i,m,gsi);
324 for (
int g=0; g<gss; g++)
327 x_ref[index] = (*y_ptr)[mapping+g];
334 VecRestoreArray(x,&x_ref);
344 std::vector<double>* y_ptr;
350 throw std::logic_error(
"SetPrimarySTLvectorFromMultiGSPETScVecFrom");
354 VecGetArrayRead(x_src,&x_ref);
357 for (
int gs_id : gs_ids)
359 const auto& groupset = groupsets_.at(gs_id);
361 int gsi = groupset.groups_.front().id_;
362 int gsf = groupset.groups_.back().id_;
365 for (
const auto& cell : grid_ptr_->local_cells)
367 auto& transport_view = cell_transport_views_[cell.local_id_];
369 for (
int i=0; i < cell.vertex_ids_.size(); i++)
371 for (
int m=0; m < num_moments_; m++)
373 size_t mapping = transport_view.MapDOF(i,m,gsi);
374 for (
int g=0; g<gss; g++)
377 (*y_ptr)[mapping+g] = x_ref[index];
384 VecRestoreArrayRead(x_src,&x_ref);
std::vector< LBSGroup > groups_
chi_mesh::MeshContinuumPtr grid_ptr_
std::shared_ptr< chi_math::SpatialDiscretization > discretization_
std::vector< LBSGroup > groups_
virtual void SetGSPETScVecFromPrimarySTLvector(LBSGroupset &groupset, Vec x, PhiSTLOption which_phi)
chi_math::UnknownManager flux_moments_uk_man_
virtual void SetMultiGSPETScVecFromPrimarySTLvector(const std::vector< int > &gs_ids, Vec x, PhiSTLOption which_phi)
virtual void SetPrimarySTLvectorFromMultiGSPETScVecFrom(const std::vector< int > &gs_ids, Vec x_src, PhiSTLOption which_phi)
virtual void SetPhiVectorScalarValues(std::vector< double > &phi_vector, double value)
virtual void SetPrimarySTLvectorFromGroupScopedPETScVec(int first_group_id, int last_group_id, Vec x_src, std::vector< double > &y)
virtual void ScalePhiVector(PhiSTLOption which_phi, double value)
virtual void SetGroupScopedPETScVecFromPrimarySTLvector(int first_group_id, int last_group_id, Vec x, const std::vector< double > &y)
virtual void SetPrimarySTLvectorFromGSPETScVec(LBSGroupset &groupset, Vec x_src, PhiSTLOption which_phi)
virtual void GSScopedCopyPrimarySTLvectors(LBSGroupset &groupset, const std::vector< double > &x_src, std::vector< double > &y)
void Scale(VecDbl &x, const double &val)