20 std::vector<double>& destination_q,
21 const std::vector<double>&,
24 const std::string fname =
"AdjointSourceFunction::AddVolumetricQOISources";
27 const auto adjoint_solver_ptr =
dynamic_cast<CAdjointSolver*
>(&
lbs_solver_);
28 if (not adjoint_solver_ptr)
29 throw std::logic_error(fname +
": Failed to cast lbs_solver_ to adjoint.");
31 const auto& adjoint_solver = *adjoint_solver_ptr;
33 const auto& response_functions = adjoint_solver.GetResponseFunctions();
34 const auto& basic_options = adjoint_solver.GetBasicOptions();
35 const auto& cell_transport_views = adjoint_solver.GetCellTransportViews();
36 const auto& grid = adjoint_solver.Grid();
37 const auto num_groups = adjoint_solver.NumGroups();
41 const auto gs_i =
static_cast<size_t>(groupset.
groups_.front().id_);
42 const auto gs_f =
static_cast<size_t>(groupset.
groups_.back().id_);
45 for (
const auto& qoi_data : response_functions)
47 const auto& qoi_designation = qoi_data.first;
48 const auto& qoi_cell_subscription = qoi_data.second;
50 if (qoi_designation.name == basic_options(
"REFERENCE_RF").StringValue())
52 for (
size_t local_id : qoi_cell_subscription)
54 const auto& full_cell_view = cell_transport_views[local_id];
55 const auto& cell = grid.local_cells[local_id];
56 const auto& response = qoi_designation.GetMGResponse(cell, num_groups);
57 const int num_nodes = full_cell_view.NumNodes();
58 for (
int i = 0; i < num_nodes; ++i)
60 size_t uk_map = full_cell_view.MapDOF(i, 0, 0);
61 for (
size_t g = gs_i; g <= gs_f; ++g)
62 destination_q[uk_map + g] += response[g];
AdjointSourceFunction(const LBSSolver &lbs_solver)
void AddVolumetricQOISources(LBSGroupset &groupset, std::vector< double > &destination_q, const std::vector< double > &phi, SourceFlags source_flags)
std::vector< LBSGroup > groups_
const LBSSolver & lbs_solver_