Class LBSProblem
Defined in File lbs_problem.h
Inheritance Relationships
Base Types
public opensn::Problem(Class Problem)public std::enable_shared_from_this< LBSProblem >
Derived Types
public opensn::DiscreteOrdinatesProblem(Class DiscreteOrdinatesProblem)public opensn::UncollidedProblem(Class UncollidedProblem)
Class Documentation
-
class LBSProblem : public opensn::Problem, public std::enable_shared_from_this<LBSProblem>
Base class for all Linear Boltzmann Solvers.
Problems are created only through their static Create(), which constructs the problem (the constructor only parses input) and passes it to Build(), so public methods operate on a fully built and validated problem:
return Build(std::shared_ptr<T>(new T(MakeInputParameters<T>(“lbs::T”, params))));
Subclassed by opensn::DiscreteOrdinatesProblem, opensn::UncollidedProblem
Public Types
-
using RestartDataHook = std::function<bool(hid_t)>
Public Functions
-
LBSProblem(const LBSProblem&) = delete
Construction and lifetime.
-
LBSProblem &operator=(const LBSProblem&) = delete
-
~LBSProblem() override
-
const LBSOptions &GetOptions() const
Time and adjoint-mode controls.
Returns a constant reference to the solver options.
-
double GetTime() const
Returns simulation time in seconds for time dependent problems.
-
virtual void SetTime(double time)
Sets simulation time in seconds for time dependent problems.
-
void SetTimeStep(double dt)
Sets dt.
-
double GetTimeStep() const
Returns dt.
-
void SetTheta(double theta)
Sets theta for time discretization.
-
double GetTheta() const
Returns theta for time discretization.
-
virtual bool IsTimeDependent() const
Returns true if the problem is currently in time-dependent mode.
-
virtual void SetTimeDependentMode()
Set the problem to time-dependent mode.
-
virtual void SetSteadyStateMode()
Set the problem to steady-state mode.
-
void SetAdjoint(bool adjoint = true)
Toggle forward/adjoint transport mode.
If the requested mode differs from the current mode, this performs a mode-transition reset. Materials are reinitialized in the selected mode, sources and boundaries are cleared, and solution vectors are zeroed. Adjoint mode is supported only for Cartesian geometries.
-
void SetForward()
Set the problem to forward mode.
-
bool IsAdjoint() const
Returns true if the problem is in adjoint mode.
-
void ValidateConfiguration() const
Throws std::invalid_argument listing every rule the problem violates.
Collective; not callable from a constructor.
-
inline bool IsBuilt() const
Returns true once Create() has built the problem.
-
void ZeroPhi()
Supported solution-vector operations.
-
void CopyPhiNewToOld()
-
void SetPhiOldFrom(const std::vector<double> &phi_old)
-
void SetPhiNewFrom(const std::vector<double> &phi_new)
-
void SetPrecursorsOldFrom(const std::vector<double> &precursors_old)
-
void ScalePhiOld(double factor)
-
void ScalePhiNew(double factor)
-
void ZeroQMoments()
-
void ScaleQMoments(double factor)
-
void SetQMomentsFrom(const std::vector<double> &q_moments)
-
void ScalePrecursors(double factor)
-
void ZeroPrecursors()
-
void ZeroExtSrcMoments()
-
void ScaleExtSrcMoments(double factor)
-
GeometryType GetGeometryType() const
Problem metadata and immutable access.
-
unsigned int GetNumMoments() const
Returns the number of moments for the solver.
-
unsigned int GetMaxCellDOFCount() const
-
unsigned int GetMinCellDOFCount() const
-
bool UseGPUs() const
-
unsigned int GetNumGroups() const
Returns the number of groups for the solver.
-
unsigned int GetScatteringOrder() const
Returns the scattering order for the solver.
-
unsigned int GetNumPrecursors() const
Returns the number of precursors for the solver.
-
unsigned int GetMaxPrecursorsPerMaterial() const
Returns the maximum number of precursors defined on any material.
-
const std::vector<LBSGroupset> &GetGroupsets() const
-
LBSGroupset &GetGroupset(size_t groupset_id)
-
const LBSGroupset &GetGroupset(size_t groupset_id) const
-
size_t GetNumGroupsets() const
Problem runtime reconfiguration.
These collective methods validate changes and refresh dependent runtime data. Other mutable accessors support solvers and low-level I/O, not general reconfiguration. Replaces (
clear_existing) or extends the point sources withsources.Every new source is initialized for this problem, the resulting list is validated, and only then is it committed, so a rejected call leaves the problem’s sources unchanged. The source objects themselves stay initialized for this problem. Collective.
Adds a point source to the solver. See SetPointSources().
-
void ClearPointSources()
Clears all the point sources from the solver. See SetPointSources().
-
const std::vector<std::shared_ptr<PointSource>> &GetPointSources() const
Constant accessor to the list of point sources.
Replaces (
clear_existing) or extends the volumetric sources withsources, as SetPointSources() does for point sources.Collective.
Adds a volumetric source to the solver. See SetVolumetricSources().
-
void ClearVolumetricSources()
Clears all the volumetric sources from the solver. See SetVolumetricSources().
-
const std::vector<std::shared_ptr<VolumetricSource>> &GetVolumetricSources() const
Constant accessor to the list of volumetric sources.
-
virtual void ClearBoundaries() = 0
Clears all the boundary conditions from the solver.
-
const BlockID2XSMap &GetBlockID2XSMap() const
Returns a reference to the map of material ids to XSs.
-
void SetBlockID2XSMap(const BlockID2XSMap &xs_map)
Replaces the map of block ids to XSs and refreshes material data.
-
std::shared_ptr<MeshContinuum> GetGrid() const
Obtains a reference to the grid.
-
inline TotalXSCarrier *GetTotalXSCarrier()
Low-level device/runtime carriers used by solver components.
-
inline const TotalXSCarrier *GetTotalXSCarrier() const
-
inline OutflowCarrier *GetOutflowCarrier()
-
inline const OutflowCarrier *GetOutflowCarrier() const
-
inline MeshCarrier *GetMeshCarrier()
-
inline const MeshCarrier *GetMeshCarrier() const
-
inline DeviceVectorMirror<double> *GetSourceMomentsPinner()
-
inline const DeviceVectorMirror<double> *GetSourceMomentsPinner() const
-
inline DeviceVectorMirror<double> *GetPhiPinner()
-
inline const DeviceVectorMirror<double> *GetPhiPinner() const
-
const SpatialDiscretization &GetSpatialDiscretization() const
Discretization and local transport data.
Obtains a reference to the spatial discretization.
-
const std::vector<UnitCellMatrices> &GetUnitCellMatrices() const
Returns read-only access to the unit cell matrices.
-
const std::map<uint64_t, UnitCellMatrices> &GetUnitGhostCellMatrices() const
Returns read-only access to the unit ghost cell matrices.
-
const std::vector<CellLBSView> &GetCellTransportViews() const
Returns read-only access to the list of local cell transport views.
-
OutflowBank &GetOutflowBank()
Returns reference to the outflow contiguous memory manager.
-
std::vector<CellOutflowView> &GetCellOutflowViews()
Returns read/write access to local cell outflow tallies.
-
const std::vector<CellOutflowView> &GetCellOutflowViews() const
Returns read-only access to local cell outflow tallies.
-
void ConfigureOutflowStorage(bool include_internal_faces)
Rebuilds face outflow storage, optionally including internal faces.
-
const UnknownManager &GetUnknownManager() const
Obtains a reference to the unknown manager for flux-moments.
-
size_t GetLocalNodeCount() const
Returns the local node count for the flux-moments data structures.
-
std::uint64_t GetGlobalNodeCount() const
Returns the global node count for the flux-moments data structures.
-
std::vector<double> &GetQMomentsLocal()
Internal solver-state access.
These mutable references are intentionally available to solver kernels, iterative methods, acceleration routines, and restart/flux I/O. User-facing code should prefer the explicit operations above or read-only field-function/query APIs. Read/write access to source moments vector.
-
const std::vector<double> &GetQMomentsLocal() const
Read access to source moments vector.
-
const std::vector<double> &GetExtSrcMomentsLocal() const
Read access to exterior src moments vector.
-
void SetExtSrcMomentsFrom(const std::vector<double> &ext_src_moments)
Replaces exterior source moments vector.
-
void RequireSourceMoments() const
With
use_source_moments=true, throws std::invalid_argument unless source moments matching the flux-moment layout have been provided (e.g.with ReadSourceMoments). Called before a solve that reads them, not at construction, because they are provided after the problem is created. Collective.
-
std::vector<double> &GetPhiOldLocal()
Read/write access to last updated flux vector.
-
const std::vector<double> &GetPhiOldLocal() const
Read access to last updated flux vector.
-
std::vector<double> &GetPhiNewLocal()
Read/write access to newest updated flux vector.
-
const std::vector<double> &GetPhiNewLocal() const
Read access to newest updated flux vector.
-
std::vector<double> &GetPrecursorsNewLocal()
Read/write access to newest updated precursors vector.
-
const std::vector<double> &GetPrecursorsNewLocal() const
Read access to newest updated precursors vector.
-
std::vector<double> &GetPrecursorsOldLocal()
Read/write access to previous time step’s precursors vector.
-
const std::vector<double> &GetPrecursorsOldLocal() const
Read access to previous time step’s precursors vector.
-
SetSourceFunction GetActiveSetSourceFunction() const
-
virtual std::pair<std::uint64_t, std::uint64_t> GetNumPhiIterativeUnknowns()
Gets the local and global number of iterative unknowns.
This is typically only the flux moments, however, the sweep based solvers might include delayed angular fluxes in this number.
-
std::shared_ptr<FieldFunctionGridBased> CreateScalarFluxFieldFunction(unsigned int g, unsigned int m = 0)
Field-function and postprocessing helpers.
Returns a flux-moment field function for a given group and moment.
The returned field function is created on demand from the current
phi_newstate.
-
std::shared_ptr<FieldFunctionGridBased> CreateFieldFunction(const std::string &name, const std::string &xs_name, double power_normalization_target = -1.0)
Creates a named field function from a 1D XS or the special case
power.
-
double ComputeFieldFunctionPowerScaleFactor(double power_normalization_target) const
Returns the scale factor (power_normalization_target / global total power) that CreateFieldFunction(…, “power”, power_normalization_target) applies internally.
Exposed directly so callers can apply consistent power normalization to their own derived quantities without needing a field function.
-
bool ReadRestartData(const RestartDataHook &extra_reader = {}, const std::filesystem::path &read_path = {}, bool allow_transient_initialization_from_steady = false)
-
bool WriteRestartData(const RestartDataHook &extra_writer = {})
-
inline bool HasPendingInitialCondition() const
Returns true while
read_initial_condition_pathis set and no solver has loaded it yet.
-
inline void MarkInitialConditionLoaded()
Records that a solver has loaded the initial condition from
read_initial_condition_path.Later solver initializations continue from the problem’s current state.
-
inline bool TriggerRestartDump() const
-
inline void UpdateRestartWriteTime()
-
std::vector<double> MakeSourceMomentsFromPhi()
Makes a source-moments vector from scattering and fission based on the latest phi-solution.
-
inline virtual void ReorientAdjointSolution()
A method for post-processing an adjoint solution.
Note
This does nothing for diffusion-based solvers.
Public Static Functions
-
static InputParameters GetInputParameters()
Returns the input parameters for this object.
-
static InputParameters GetOptionsBlock()
-
static InputParameters GetXSMapEntryBlock()
Public Static Attributes
-
static std::uint32_t max_dofs_gpu = 10
Max number of DOFs per cell that the sweep kernel on GPU can handle.
Protected Functions
-
explicit LBSProblem(const InputParameters ¶ms)
Input parameters based construction.
-
void BuildRuntime()
Validates parsed configuration, builds common and derived runtime data, validates the built state, and finally marks the problem built.
Collective.
-
inline virtual void BuildRuntimeData()
Builds the runtime data of a derived problem type. Overrides must call the base version.
-
virtual void CheckConfigurationErrors(std::vector<std::string> &errors) const
Appends a message for each problem rule the problem violates.
Call the base implementation, read only input settings (not data derived from them), and keep collective operations unconditional.
-
template<typename T>
inline void ValidateChange(T &member, T value) Validates the problem as if
memberhadvalue, then restoresmember.A rule rejection leaves
memberunchanged. This does not roll back other objects or a later rebuild failure. Collective.
-
virtual void RebuildRuntimeObjects()
Rebuilds objects that depend on mutable configuration.
Setters call this after committing a value. Overrides call the base version first. Rebuild failure is not transactional.
-
virtual void PrintSimHeader()
-
inline virtual void ResetDerivedSolutionVectors()
-
void ComputeUnitIntegrals()
-
virtual void InitializeSpatialDiscretization()
-
inline virtual void InitializeBoundaries()
Initializes boundaries.
-
void SetActiveSetSourceFunction(SetSourceFunction source_function)
-
std::shared_ptr<FieldFunctionGridBased> CreateEmptyFieldFunction(const std::string &name) const
-
std::string MakeFieldFunctionName(const std::string &base_name) const
-
void UpdateScalarFluxFieldFunction(FieldFunctionGridBased &ff, unsigned int g, unsigned int m)
-
void UpdateDerivedFieldFunction(FieldFunctionGridBased &ff, const std::string &xs_name, double power_normalization_target)
-
virtual std::optional<std::vector<double>> ComputeDerivedFieldFunctionData(const std::string &xs_name) const
-
virtual bool ReadProblemRestartData(hid_t file_id, bool allow_transient_initialization_from_steady, bool repartitioned)
-
virtual bool WriteProblemRestartData(hid_t file_id) const
Protected Attributes
-
LBSOptions options_
-
double time_ = 0.0
-
double theta_ = 1.0
-
double dt_ = 1.0
-
GeometryType geometry_type_ = GeometryType::INVALID
-
unsigned int num_moments_ = 0
-
unsigned int num_groups_ = 0
-
unsigned int scattering_order_ = 0
-
unsigned int num_precursors_ = 0
-
unsigned int max_precursors_per_material_ = 0
-
std::shared_ptr<SweepCommunicator> sweep_communicator_ = nullptr
-
std::vector<LBSGroupset> groupsets_
-
BlockID2XSMap block_id_to_xs_map_
-
std::vector<std::shared_ptr<PointSource>> point_sources_
-
std::vector<std::shared_ptr<VolumetricSource>> volumetric_sources_
-
std::shared_ptr<MeshContinuum> grid_
-
std::shared_ptr<SpatialDiscretization> discretization_ = nullptr
-
std::vector<CellFaceNodalMapping> grid_nodal_mappings_
-
std::vector<UnitCellMatrices> unit_cell_matrices_
-
std::map<uint64_t, UnitCellMatrices> unit_ghost_cell_matrices_
-
std::vector<CellLBSView> cell_transport_views_
-
OutflowBank outflow_bank_
-
std::vector<CellOutflowView> cell_outflow_views_
-
bool store_internal_outflows_ = false
-
UnknownManager flux_moments_uk_man_
-
unsigned int max_cell_dof_count_ = 0
-
unsigned int min_cell_dof_count_ = 0
-
uint64_t local_node_count_ = 0
-
std::uint64_t global_node_count_ = 0
-
std::vector<double> q_moments_local_
-
std::vector<double> ext_src_moments_local_
-
std::vector<double> phi_new_local_
-
std::vector<double> phi_old_local_
-
std::vector<double> precursor_new_local_
-
std::vector<double> precursor_old_local_
-
SetSourceFunction active_set_source_function_
-
std::shared_ptr<TotalXSCarrier> total_xs_carrier_ = nullptr
Data carriers needed to run the sweep on GPU.
-
std::shared_ptr<OutflowCarrier> outflow_carrier_ = nullptr
-
std::shared_ptr<MeshCarrier> mesh_carrier_ = nullptr
-
std::shared_ptr<DeviceVectorMirror<double>> source_pinner_ = nullptr
Memory pinners for source moments and destination phi.
-
std::shared_ptr<DeviceVectorMirror<double>> phi_pinner_ = nullptr
-
bool use_gpus_
Flag indicating if GPU acceleration is enabled.
Protected Static Functions
-
template<typename T>
static inline InputParameters MakeInputParameters(const std::string &object_type, const ParameterBlock ¶ms) Assigns
paramsto T’s input parameters for constructing a T.
Completes the creation of a newly constructed problem with BuildRuntime() and returns it.
-
using RestartDataHook = std::function<bool(hid_t)>