Class DiscreteOrdinatesProblemIO
Defined in File discrete_ordinates_problem_io.h
Nested Relationships
Nested Types
Class Documentation
-
class DiscreteOrdinatesProblemIO
Public Types
-
using FaceCentroidKey = std::tuple<int64_t, int64_t, int64_t>
Surface Angular flux.
Public Static Functions
-
static UncollidedFluxData ReadUncollidedFlux(const DiscreteOrdinatesProblem &do_problem, const std::string &file_name)
-
static bool ReadRestartData(DiscreteOrdinatesProblem &do_problem, hid_t file_id, bool allow_transient_initialization_from_steady, bool repartitioned)
-
static bool WriteRestartData(const DiscreteOrdinatesProblem &do_problem, hid_t file_id)
-
static void WriteAngularFluxes(DiscreteOrdinatesProblem &do_problem, const std::string &file_base, std::optional<const std::reference_wrapper<std::vector<std::vector<double>>>> opt_src = std::nullopt, FluxSolutionRole role = FluxSolutionRole::UNSPECIFIED, AdjointFluxOrientation orientation = AdjointFluxOrientation::UNSPECIFIED)
Write an angular flux vector to a file.
Each groupset records its quadrature directions and weights so that a reader can check them.
- Parameters:
do_problem – Discrete ordinates problem
file_base – File name base
opt_src – Optional angular flux source vector
role – Solution role. For problem-owned data, unspecified is inferred from the problem.
orientation – Adjoint orientation. For problem-owned data, unspecified is inferred.
-
static void ReadAngularFluxes(DiscreteOrdinatesProblem &do_problem, const std::string &file_base, std::optional<std::reference_wrapper<std::vector<std::vector<double>>>> opt_dest = std::nullopt, FluxSolutionRole expected_role = FluxSolutionRole::UNSPECIFIED, AdjointFluxOrientation expected_orientation = AdjointFluxOrientation::UNSPECIFIED)
Read an angular flux vector from a file.
The file must have been written with the same rank count, partition, and quadrature; files that record their quadrature are checked against the problem’s. Collective: a file that cannot be read or does not match the problem raises an error on every rank, and the destination is left unchanged.
- Parameters:
do_problem – Discrete ordinates problem
file_base – File name base
opt_dest – Optional angular flux destination vector
expected_role – Required solution role, or unspecified to accept any role.
expected_orientation – Required orientation of a file that records the adjoint role, or unspecified to accept any. Files of other roles, and files without provenance, pass.
-
static FaceCentroidKey MakeFaceCentroidKey(std::vector<Vector3> nodes, const std::array<double, 3> ¢roid_origin, double centroid_spacing, const std::string &context)
Key a surface face by its centroid.
The centroid is summed over the nodes in a canonical (sorted) order, so the same face yields a bit-identical key from either side of an interior surface and in every file written for the same mesh. Each component is
llround((centroid - centroid_origin) / centroid_spacing).- Parameters:
nodes – Face node locations, in any order. Must not be empty.
centroid_origin – Origin subtracted from the centroid.
centroid_spacing – Key spacing. Must be positive and finite.
context – Description of the face source, used in error messages.
-
static void WriteSurfaceAngularFluxes(DiscreteOrdinatesProblem &do_problem, const std::string &file_base, const std::vector<std::string> &boundary_surfs, const std::map<std::string, std::pair<std::string, double>> &interior_surfs)
Write surface angular flux vector(s) to a file.
Collective over all ranks. Surface selections may differ by rank, but each file contains only its rank’s tags, and DistributeSurfaceAngularFluxes requires every requested tag in every file of a set. Plane-matching tolerances are relative to the global mesh extent. Each rank writes
<file_base><rank>.h5, which records the file format version (format_version, see SURFACE_FILE_FORMAT_VERSION), whether the problem is in adjoint mode, the number of files written (num_partitions), and an identifier shared by the files of the set (file_set_id). Each groupset records its first group. Boundary tags also store the upwind face values (upwind_flux; see SurfaceData), taken from the problem’s boundary conditions for the directions that enter the domain.Requires
options.save_angular_flux=true. An adjoint problem must hold its solution in the physical orientation (IsAdjointSolutionReoriented()), which an adjoint steady-state or k-eigenvalue solve leaves. Restart data are loaded in the internal sweep orientation, so an adjoint solver must be executed after a restart read. Throwsstd::invalid_argumentotherwise.- Parameters:
do_problem – Discrete ordinates problem
file_base – File name base
boundary_surfs – Boundary surface names
interior_surfs – Interior surface definitions, keyed by name, as an axis (“x”, “y”, or “z”) and a coordinate. Each surface must lie inside the mesh, on cell faces (it must not cut through a cell), must match at least one cell face, must not coincide with an exterior boundary, and must not share a plane with another requested surface. Each surface is written with an
_utag for face normals aligned with the positive specified axis and a_dtag for the opposite orientation; neither these tags nor the surface name may equal a requested boundary name. Each tag’smesh/<tag>group records in itsinteriorattribute whether the tag is one side of an interior surface or a boundary, so boundaries may have any name.
-
static std::vector<SurfaceAngularFlux> ReadSurfaceAngularFluxes(const std::string &file_base, uint64_t partition, const std::vector<std::string> &surfaces)
Read surface angular fluxes from one file of a file set.
Returns one entry per groupset and resolved tag, groupset-major, with
surface_nameset to the tag. The file must have format version SURFACE_FILE_FORMAT_VERSION and carry every attribute written by the current WriteSurfaceAngularFluxes, includingnum_partitions, which must exceedpartition. Every dataset size is checked against the face-node counts before data are read, the data must be finite, and face centroid keys must be unique within each surface. The data are not checked against a problem, so any rank can read any file of a set, whatever number of ranks or partitioning wrote it. Not collective. Throwsstd::invalid_argumentfor an emptysurfacesandstd::logic_errorfor a missing, malformed, or inconsistent file.- Parameters:
file_base – File name base
partition – File index; the file
<file_base><partition>.h5is read.surfaces – Surface names to read. Must be non-empty. A name that is a stored tag reads that tag: a boundary name, or one side of an interior surface (
_ufor face normals aligned with the positive specified axis,_dfor the opposite orientation). Any other name must be an interior surface whose tags<name>_uand<name>_dboth exist and are recorded as interior; both are read,_ufirst. Each tag must be present in the file, possibly without faces, and the names must not resolve to the same tag twice.
Public Static Attributes
-
static uint64_t SURFACE_FILE_FORMAT_VERSION = 1
Version of the surface angular flux file format, stored in the
format_versionattribute of every file.Increase it whenever the stored attributes or datasets change.
-
struct SurfaceAngularFlux
Public Members
-
int groupset_id = 0
-
bool adjoint = false
True when the data were written from an adjoint problem.
-
uint64_t num_partitions = 0
Number of files in the file set, one per writing rank.
-
uint64_t file_set_id = 0
Random identifier shared by the files written by one WriteSurfaceAngularFluxes call.
-
uint64_t num_directions = 0
Direction and group counts of the groupset, also set when the surface has no local faces.
-
uint64_t num_groups = 0
-
uint64_t first_group = 0
First group of the groupset.
-
std::string surface_name
-
bool interior = false
True when the tag is one side,
<name>_uor<name>_d, of an interior surface; false for a boundary, whatever its name.
-
std::shared_ptr<const SurfaceMap> mapping
Face geometry of the tag, shared by the entries of every groupset of the tag.
-
SurfaceData data
-
int groupset_id = 0
-
struct SurfaceData
Angular-flux data of one surface tag and groupset.
omegaholds the groupset’s direction vectors, three components per direction, andweightsits quadrature weights. The cosine of direction d with the normal of face f isomega_d . normal_f.psiholds the face-node values of the problem’s stored angular flux on the cell that owns the face, ordered by face node (as in SurfaceMap), direction, and group: the value of node k, direction d, and group g ispsi[(k * num_directions + d) * num_groups + g]. The two sides of an interior surface are stored under separate tags. For an adjoint problem the writer requires the physical orientation that an adjoint solve leaves, so the stored angular flux is the adjoint flux for the listed direction and forward and adjoint data with the same indices refer to the same direction.upwind_psi, read for boundary tags only and laid out likepsi, holds the face value upwind of each direction along the direction the data transport in (Omega_dfor forward data,-Omega_dfor adjoint data): the cell value ofpsifor a direction that leaves the domain and the boundary-condition value the solve used for one that enters it (0 for vacuum, the incoming flux for isotropic and arbitrary boundaries, the reflected final-iterate angular flux for reflecting boundaries), as recorded by DiscreteOrdinatesProblem::RecordBoundaryInflow. It is empty for interior tags.
-
struct SurfaceMap
Geometry and finite-element data of the faces of one surface tag, shared by all groupsets.
Faces are stored in file order.
num_face_nodesgives the node count n_f of each face, and the node arrays (nodes_x,nodes_y,nodes_z,fe_shape) list the nodes of every face in turn.normalsholds the outward normal of each face’s cell, three components per face, andmass_matrixthe n_f x n_f face mass matrix of each face in turn, row-major by face node.fe_shapeholds the face integral of each node’s shape function. Face integrals include the angular extent of curvilinear coordinates. All arrays are empty when the tag has no faces in the file.Public Members
-
std::vector<uint64_t> cell_ids
-
std::vector<uint64_t> num_face_nodes
-
std::array<double, 3> centroid_origin = {0.0, 0.0, 0.0}
Origin subtracted from face centroids.
-
double centroid_spacing = 1.0e-6
Spacing used to key faces by centroid: 1e-9 times the global mesh extent.
-
std::map<FaceCentroidKey, uint64_t> cell_map
Surface face index keyed by the face centroid, with centroid_origin subtracted from each coordinate before division by centroid_spacing and rounding to the nearest integer.
The same face yields the same key from either side of an interior surface and in every file written for the same mesh.
-
std::vector<double> nodes_x
-
std::vector<double> nodes_y
-
std::vector<double> nodes_z
-
std::vector<double> normals
-
std::vector<double> fe_shape
-
std::vector<double> mass_matrix
-
std::vector<uint64_t> cell_ids
-
using FaceCentroidKey = std::tuple<int64_t, int64_t, int64_t>