Class DiscreteOrdinatesProblem

Inheritance Relationships

Base Type

Derived Type

Class Documentation

class DiscreteOrdinatesProblem : public opensn::LBSProblem

Base class for discrete ordinates solvers.

Subclassed by opensn::DiscreteOrdinatesCurvilinearProblem

Sweep dependency data

std::map<std::shared_ptr<AngularQuadrature>, SweepOrderGroupingInfo> quadrature_unq_so_grouping_map_
std::map<std::shared_ptr<AngularQuadrature>, std::vector<std::shared_ptr<SPDS>>> quadrature_spds_map_
std::map<std::shared_ptr<AngularQuadrature>, std::vector<std::unique_ptr<FLUDSCommonData>>> quadrature_fluds_commondata_map_
std::vector<int> verbose_sweep_angles_
const std::string sweep_type_

Boundary data

BoundaryBank boundary_bank_
std::map<uint64_t, std::shared_ptr<SweepBoundary>> sweep_boundaries_
std::map<uint64_t, BoundaryDefinition> boundary_definitions_
std::shared_ptr<BoundaryCarrier> boundary_carrier_ = nullptr
std::optional<ParameterBlock> boundary_conditions_block_
bool boundary_runtime_data_initialized_ = false
bool has_reflecting_boundaries_ = false
bool has_time_dependent_boundaries_ = false

Sweep size metadata

std::size_t max_level_size_ = 0

Max level size.

std::size_t max_angleset_size_ = 0

Max angle-set size.

unsigned int max_groupset_size_ = 0

Max group-set size.

std::shared_ptr<GridFaceHistogram> grid_face_histogram_ = nullptr

Max level size.

std::vector<std::vector<double>> psi_new_local_

Max level size.

std::vector<std::vector<double>> psi_old_local_

Max level size.

std::optional<SweepChunkMode> sweep_chunk_mode_

Max level size.

std::shared_ptr<AGSLinearSolver> ags_solver_

Max level size.

std::vector<std::shared_ptr<WGSContext>> wgs_contexts_

Max level size.

std::vector<std::shared_ptr<LinearSolver>> wgs_solvers_

Max level size.

Construction and transport-mode controls

inline virtual bool IsTimeDependent() const override

Returns true if the problem is currently in time-dependent mode.

virtual void SetTimeDependentMode() override

Set the problem to time-dependent mode.

virtual void SetSteadyStateMode() override

Set the problem to steady-state mode.

virtual void SetTime(double time) override

Sets simulation time in seconds for time dependent problems.

Problem metadata and solver access

inline const std::string &GetSweepType() const
virtual std::pair<std::uint64_t, std::uint64_t> GetNumPhiIterativeUnknowns() override

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<AGSLinearSolver> GetAGSSolver()
std::shared_ptr<LinearSolver> GetWGSSolver(size_t groupset_id)
size_t GetNumWGSSolvers()
WGSContext &GetWGSContext(int groupset_id)

Balance and output helpers

BalanceTable ComputeBalanceTable(double scaling_factor = 1.0)

Returns the sweep boundaries as a read-only reference.

void ComputeBalance(double scaling_factor = 1.0)

Returns the sweep boundaries as a read-only reference.

virtual void PrintSimHeader() override

Returns the sweep boundaries as a read-only reference.

const std::map<uint64_t, std::shared_ptr<SweepBoundary>> &GetSweepBoundaries() const

Returns the sweep boundaries as a read-only reference.

const std::map<uint64_t, BoundaryDefinition> &GetBoundaryDefinitions() const

Returns the sweep boundaries as a read-only reference.

virtual void ReorientAdjointSolution() override

Reorient an adjoint solution to account for backwards streaming.

void ZeroOutflowBalanceVars(LBSGroupset &groupset)

Zeroes all the outflow data-structures required to compute balance.

std::vector<std::shared_ptr<FieldFunctionGridBased>> CreateAngularFluxFieldFunctionList(const std::vector<unsigned int> &groups, const std::vector<size_t> &angles)

Create angular flux field functions for the given groups and angles.

Angles are indices into the groupset quadrature associated with each group.

Construction and setup

explicit DiscreteOrdinatesProblem(const InputParameters &params)

Factory-only constructor.

void BuildRuntime()

Internal factory step: build sweep/runtime data once base runtime data is available.

virtual void InitializeBoundaries() override

Factory-only constructor.

Solver and sweep state

void InitializeSolverSchemes()

Rebuild WGS/AGS solver schemes after runtime configuration changes.

void ReinitializeSolverSchemes()

Rebuild WGS/AGS solver schemes after runtime configuration changes.

void SetSweepChunkMode(SweepChunkMode mode)

Rebuild WGS/AGS solver schemes after runtime configuration changes.

inline void ResetSweepChunkMode()

Rebuild WGS/AGS solver schemes after runtime configuration changes.

void ResetMode(SweepChunkMode target_mode)

Rebuild WGS/AGS solver schemes after runtime configuration changes.

void InitializeWGSContexts()

Rebuild WGS/AGS solver schemes after runtime configuration changes.

void InitializeWGSSolvers()

Initializes Within-GroupSet solvers.

void InitializeBoundaryCarrier()

Rebuild WGS/AGS solver schemes after runtime configuration changes.

void SortAngleSetsAngleIndices()

Sort the angle indices within each angle set so that one set maps exactly to another under all reflected angle mappings.

void ResetBoundaryCarrier()

Rebuild WGS/AGS solver schemes after runtime configuration changes.

void InitializeSweepDataStructures()

This routine initializes basic sweep datastructures that are agnostic of the number of groups and essentially the groupsets.

The routine rebuilds the data structures i) quadrature_unq_so_grouping_map_, ii) quadrature_spds_map_ and iii) quadrature_fluds_templates_map_. i) is a mapping, per quadrature, to a collection of angle-index-sets where all the angles in a particular angleset share the same sweep ordering. ii) is a mapping, per quadrature, to a collection of SPDSs where each SPDS mirrors an angle-index-set in i) iii) is again a mapping, per quadrature, to a collection of Template FLUDS where each FLUDS mirrors a SPDS in ii).

void InitFluxDataStructures(LBSGroupset &groupset)

Initializes fluds_ data structures.

void ResetSweepOrderings(LBSGroupset &groupset)

Clears all the sweep orderings for a groupset in preparation for another.

virtual std::shared_ptr<SweepChunk> SetSweepChunk(LBSGroupset &groupset)

Sets up the sweep chunk for the given discretization method.

inline std::shared_ptr<SweepChunk> CreateSweepChunk(LBSGroupset &groupset)

Rebuild WGS/AGS solver schemes after runtime configuration changes.

Restart and runtime reconfiguration

virtual bool ReadProblemRestartData(hid_t file_id, bool allow_transient_initialization_from_steady) override
virtual bool WriteProblemRestartData(hid_t file_id) const override
virtual void ResetDerivedSolutionVectors() override
void UpdateBoundaryDefinition(const InputParameters &params)
void RebuildBoundaryRuntimeData()

Factory interface

static InputParameters GetInputParameters()
static InputParameters GetBoundaryOptionsBlock()
static std::shared_ptr<DiscreteOrdinatesProblem> Create(const ParameterBlock &params)

Public Types

enum class SweepChunkMode

Values:

enumerator DEFAULT
enumerator STEADY_STATE
enumerator TIME_DEPENDENT

Public Functions

~DiscreteOrdinatesProblem() override
std::vector<std::vector<double>> &GetPsiNewLocal()

Internal angular-flux state access.

These mutable references are used by sweep chunks, transient solvers, acceleration, restart I/O, and angular-flux I/O. User-facing Python APIs expose copies or field functions rather than mutable access to this storage. Read/write access to newest updated angular flux vector.

const std::vector<std::vector<double>> &GetPsiNewLocal() const

Read access to newest updated angular flux vector.

std::vector<std::vector<double>> &GetPsiOldLocal()

Read/write access to newest updated angular flux vector.

const std::vector<std::vector<double>> &GetPsiOldLocal() const

Read access to previous angular flux vector.

void ZeroPsi()
inline bool SaveAngularFluxEnabled() const
size_t GetMaxLevelSize() const
size_t GetMaxGroupsetSize() const
size_t GetMaxAngleSetSize() const
void UpdatePsiOld()

Copy psi_new to psi_old.

void SetSaveAngularFlux(bool save)

Supported runtime discrete-ordinates reconfiguration.

These methods update the dependent sweep, boundary, acceleration, and solver data owned by the problem. Lower-level sweep chunk and solver-scheme controls remain protected implementation details.

virtual void SetBlockID2XSMap(const BlockID2XSMap &xs_map) override

Replaces the map of block ids to XSs and refreshes material data.

void SetBoundaryOptions(const std::vector<InputParameters> &boundary_params, bool clear_existing)
virtual void ClearBoundaries() override

Clears all the boundary conditions from the solver.

inline BoundaryCarrier *GetBoundaryCarrier()
inline const BoundaryCarrier *GetBoundaryCarrier() const
void CopyPhiAndSrcToDevice()
void CopyPhiAndOutflowBackToHost()
void TransferDeviceBoundaryData(int groupset_id, bool host_to_device, bool force = false)

Transfer data in boundary to device or vice-versa.

Parameters:
  • groupset_id – Groupset ID.

  • host_to_device – Flag indicating the direction of transfer.

  • force – Force update.

Protected Types

using SweepOrderGroupingInfo = std::pair<UniqueSOGroupings, DirIDToSOMap>