1#ifndef CHITECH_LBS_SOLVER_H
2#define CHITECH_LBS_SOLVER_H
19template <
class MatType,
class VecType,
class SolverType>
21template <
class MatType,
class VecType,
class SolverType>
23template <
class MatType,
class VecType,
class SolverType>
29class ChiMPICommunicatorSet;
35class GridFaceHistogram;
53 typedef std::shared_ptr<chi_math::LinearSolver<Mat, Vec, KSP>>
LinSolvePtr;
113 explicit LBSSolver(
const std::string& text_name);
141 const std::vector<LBSGroup>&
Groups()
const;
145 const std::vector<LBSGroupset>&
Groupsets()
const;
181 const std::map<uint64_t, std::shared_ptr<SweepBndry>>&
242 const std::vector<double>& phi_in);
244 const std::vector<double>& input,
245 std::vector<double>& output);
249 const std::vector<double>& phi_in,
250 std::vector<double>& delta_phi_local);
254 const std::vector<double>& delta_phi_local,
255 std::vector<double>& ref_phi_new);
265 const std::vector<double>& phi_in,
266 std::vector<double>& delta_phi_local);
269 const std::vector<double>& delta_phi_local,
270 std::vector<double>& ref_phi_new);
278 const std::string& file_base);
280 const std::string& file_base);
283 const std::string& file_base);
285 const std::string& file_base);
290 const std::vector<double>& flux_moments);
292 std::vector<double>& flux_moments,
293 bool single_file =
false);
298 const std::vector<size_t>& m_indices,
299 const std::vector<size_t>& g_indices);
324 const std::vector<double>& x_src,
325 std::vector<double>& y);
332 int first_group_id,
int last_group_id,
Vec x,
const std::vector<double>& y);
335 int first_group_id,
int last_group_id,
Vec x_src, std::vector<double>& y);
std::vector< double > precursor_new_local_
AGSLinSolverPtr GetPrimaryAGSSolver()
std::vector< double > & PhiNewLocal()
void SetBoundaryOptions(const chi::InputParameters ¶ms)
static chi::InputParameters GetInputParameters()
std::map< uint64_t, BoundaryPreference > & BoundaryPreferences()
virtual void PerformInputChecks()
void DisAssembleWGDSADeltaPhiVector(const LBSGroupset &groupset, const std::vector< double > &delta_phi_local, std::vector< double > &ref_phi_new)
static void CleanUpTGDSA(LBSGroupset &groupset)
std::vector< std::vector< double > > psi_new_local_
std::vector< PointSource > point_sources_
chi_mesh::MeshContinuumPtr grid_ptr_
std::shared_ptr< chi_math::SpatialDiscretization > discretization_
void SetPhiFromFieldFunctions(PhiSTLOption which_phi, const std::vector< size_t > &m_indices, const std::vector< size_t > &g_indices)
std::vector< lbs::CellLBSView > cell_transport_views_
std::vector< AGSLinSolverPtr > ags_solvers_
std::vector< UnitCellMatrices > unit_cell_matrices_
void AssembleTGDSADeltaPhiVector(const LBSGroupset &groupset, const std::vector< double > &phi_in, std::vector< double > &delta_phi_local)
virtual std::pair< size_t, size_t > GetNumPhiIterativeUnknowns()
size_t MapPhiFieldFunction(size_t g, size_t m) const
std::vector< double > & QMomentsLocal()
std::vector< LBSGroupset > & Groupsets()
std::vector< double > MakeSourceMomentsFromPhi()
std::vector< double > & PrecursorsNewLocal()
double ComputeFissionProduction(const std::vector< double > &phi)
size_t GetHandleToPowerGenFieldFunc() const
const chi_math::SpatialDiscretization & SpatialDiscretization() const
std::shared_ptr< const chi_math::TimeIntegration > time_integration_
GridFaceHistogramPtr grid_face_histogram_
std::vector< double > phi_new_local_
std::vector< LinSolvePtr > & GetWGSSolvers()
std::vector< LBSGroup > groups_
const std::vector< PointSource > & PointSources() const
std::map< uint64_t, std::shared_ptr< SweepBndry > > sweep_boundaries_
void ReadGroupsetAngularFluxes(LBSGroupset &groupset, const std::string &file_base)
SetSourceFunction GetActiveSetSourceFunction() const
void DisAssembleTGDSADeltaPhiVector(const LBSGroupset &groupset, const std::vector< double > &delta_phi_local, std::vector< double > &ref_phi_new)
double last_restart_write_
std::vector< double > WGSCopyOnlyPhi0(const LBSGroupset &groupset, const std::vector< double > &phi_in)
size_t LocalNodeCount() const
virtual void SetGSPETScVecFromPrimarySTLvector(LBSGroupset &groupset, Vec x, PhiSTLOption which_phi)
LBSSolver(const LBSSolver &)=delete
chi_math::UnknownManager flux_moments_uk_man_
const std::vector< lbs::CellLBSView > & GetCellTransportViews() const
void WriteGroupsetAngularFluxes(const LBSGroupset &groupset, const std::string &file_base)
std::map< uint64_t, BoundaryPreference > boundary_preferences_
const std::vector< LBSGroup > & Groups() const
size_t power_gen_fieldfunc_local_handle_
std::vector< VecDbl > & PsiNewLocal()
std::vector< double > & ExtSrcMomentsLocal()
virtual void SetMultiGSPETScVecFromPrimarySTLvector(const std::vector< int > &gs_ids, Vec x, PhiSTLOption which_phi)
size_t max_cell_dof_count_
std::vector< double > q_moments_local_
void InitWGDSA(LBSGroupset &groupset, bool vaccum_bcs_are_dirichlet=true)
void ComputeUnitIntegrals()
const std::map< uint64_t, std::shared_ptr< SweepBndry > > & SweepBoundaries() const
uint64_t glob_node_count_
virtual void SetPrimarySTLvectorFromMultiGSPETScVecFrom(const std::vector< int > &gs_ids, Vec x_src, PhiSTLOption which_phi)
chi_mesh::sweep_management::CellFaceNodalMapping CellFaceNodalMapping
const chi_math::UnknownManager & UnknownManager() const
std::shared_ptr< chi_math::LinearSolver< Mat, Vec, KSP > > LinSolvePtr
void InitializeFieldFunctions()
size_t GetMaxPrecursorsPerMaterial() const
double LastRestartWrite() const
void InitTGDSA(LBSGroupset &groupset)
std::vector< double > ext_src_moments_local_
virtual void SetPhiVectorScalarValues(std::vector< double > &phi_vector, double value)
void WriteRestartData(const std::string &folder_name, const std::string &file_base)
std::vector< double > phi_old_local_
virtual void SetPrimarySTLvectorFromGroupScopedPETScVec(int first_group_id, int last_group_id, Vec x_src, std::vector< double > &y)
void InitializePointSources()
std::map< std::pair< size_t, size_t >, size_t > phi_field_functions_local_map_
const chi_mesh::MeshContinuum & Grid() const
std::map< int, IsotropicSrcPtr > matid_to_src_map_
void AssembleWGDSADeltaPhiVector(const LBSGroupset &groupset, const std::vector< double > &phi_in, std::vector< double > &delta_phi_local)
virtual void InitializeSpatialDiscretization()
void Initialize() override
virtual void ScalePhiVector(PhiSTLOption which_phi, double value)
size_t NumMoments() const
std::vector< CellFaceNodalMapping > grid_nodal_mappings_
const std::map< int, XSPtr > & GetMatID2XSMap() const
virtual ~LBSSolver()=default
const std::map< int, IsotropicSrcPtr > & GetMatID2IsoSrcMap() const
void ReadFluxMoments(const std::string &file_base, std::vector< double > &flux_moments, bool single_file=false)
WGSContext< Mat, Vec, KSP > & GetWGSContext(int groupset_id)
virtual void InitializeWGSSolvers()
static void CleanUpWGDSA(LBSGroupset &groupset)
std::vector< LBSGroupset > groupsets_
size_t GlobalNodeCount() const
virtual void SetGroupScopedPETScVecFromPrimarySTLvector(int first_group_id, int last_group_id, Vec x, const std::vector< double > &y)
virtual void InitializeSolverSchemes()
void GSProjectBackPhi0(const LBSGroupset &groupset, const std::vector< double > &input, std::vector< double > &output)
std::map< uint64_t, UnitCellMatrices > unit_ghost_cell_matrices_
const std::vector< UnitCellMatrices > & GetUnitCellMatrices() const
MPILocalCommSetPtr grid_local_comm_set_
std::vector< LinSolvePtr > wgs_solvers_
std::shared_ptr< AGSLinearSolver< Mat, Vec, KSP > > AGSLinSolverPtr
AGSLinSolverPtr primary_ags_solver_
static chi::InputParameters BoundaryOptionsBlock()
void ComputeNumberOfMoments()
void WriteFluxMoments(const std::string &file_base, const std::vector< double > &flux_moments)
virtual void InitializeParrays()
uint64_t local_node_count_
size_t NumPrecursors() const
virtual void SetPrimarySTLvectorFromGSPETScVec(LBSGroupset &groupset, Vec x_src, PhiSTLOption which_phi)
double ComputeFissionRate(const std::vector< double > &phi)
std::vector< double > & PhiOldLocal()
std::map< int, XSPtr > matid_to_xs_map_
void InitializeBoundaries()
void ReadRestartData(const std::string &folder_name, const std::string &file_base)
size_t max_precursors_per_material_
LBSSolver & operator=(const LBSSolver &)=delete
void InitializeGroupsets()
SetSourceFunction active_set_source_function_
void UpdateFieldFunctions()
void AddPointSource(PointSource psrc)
static chi::InputParameters OptionsBlock()
void SetOptions(const chi::InputParameters ¶ms)
virtual void GSScopedCopyPrimarySTLvectors(LBSGroupset &groupset, const std::vector< double > &x_src, std::vector< double > &y)
LBSSolver(const std::string &text_name)
size_t GetSourceEventTag() const
std::shared_ptr< chi_mesh::GridFaceHistogram > GridFaceHistogramPtr
std::shared_ptr< chi::ChiMPICommunicatorSet > MPILocalCommSetPtr
std::vector< FaceNodalMapping > CellFaceNodalMapping
std::shared_ptr< MeshContinuum > MeshContinuumPtr
std::function< void(LBSGroupset &groupset, std::vector< double > &destination_q, const std::vector< double > &phi, SourceFlags source_flags)> SetSourceFunction