Class LBSProblem

Inheritance Relationships

Base Types

  • public opensn::Problem (Class Problem)

  • public std::enable_shared_from_this< LBSProblem >

Derived Type

Class Documentation

class LBSProblem : public opensn::Problem, public std::enable_shared_from_this<LBSProblem>

Base class for all Linear Boltzmann Solvers.

Problems are created through derived-class factory functions. The factory function performs all constructor-time parsing and calls BuildRuntime before returning the shared pointer, so public methods operate on a fully built problem.

Subclassed by opensn::DiscreteOrdinatesProblem

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.

void SetForward()

Set the problem to forward mode.

bool IsAdjoint() const

Returns true if the problem is in adjoint mode.

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 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
void AddPointSource(std::shared_ptr<PointSource> point_source)

Problem runtime reconfiguration.

These methods are the public mutators available after construction. They refresh the runtime data owned by the problem where needed. Other mutable state accessors below are exposed for solvers and low-level I/O, not as general user-facing methods. Adds a point source to the solver.

void ClearPointSources()

Clears all the point sources from the solver.

const std::vector<std::shared_ptr<PointSource>> &GetPointSources() const

Constant accessor to the list of point sources.

void AddVolumetricSource(std::shared_ptr<VolumetricSource> volumetric_source)

Adds a volumetric source to the solver.

void ClearVolumetricSources()

Clears all the volumetric sources from the solver.

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.

virtual 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.

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.

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.

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_new state.

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.

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 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 &params)

Input parameters based construction.

void BuildRuntime()

Internal factory step: build runtime data after constructor-time configuration is complete.

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 bool ReadProblemRestartData(hid_t file_id, bool allow_transient_initialization_from_steady)
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::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::shared_ptr<MPICommunicatorSet> grid_local_comm_set_ = nullptr
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_
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_
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.