Function opensn::ComputeSurfaceResponses
Defined in File surface_response_data.h
Function Documentation
-
std::vector<SurfaceResponse> opensn::ComputeSurfaceResponses(const DistributedSurfaceData &forward, const DistributedSurfaceData &adjoint, const std::vector<std::string> &surfaces, const mpi::Communicator &comm)
Evaluate the surface inner products of forward and adjoint angular fluxes.
For a surface S with faces f, R = sum_{f in S} sum_{d in D_f} mu_{f,d} w_d sum_ij M_{f,ij} sum_g psi_f(i, d, g) psi^dagger_f(j, d, g), with mu_{f,d} the cosine of direction d with the normal n_f of face f. The forward tags of the forward data define the surfaces, classified by the kind the writer records for each tag (SurfaceShard::interior), not by its name:
A boundary: n_f is the outward normal, D_f holds every direction, and both fluxes are upwind face values from the boundary tag of each data set. For the outflow directions (mu_{f,d} > 0) they are the forward flux of the face’s cell and the adjoint boundary-condition value (0 for a vacuum boundary), which is upwind for the adjoint because it travels along -Omega_d; for the inflow directions, the forward boundary-condition value and the adjoint flux of the cell. This is the boundary term of the discrete adjoint identity, so it is exact for the discretization like an interior surface, and the totals of all boundaries sum to <q, psi^dagger> - <q^dagger, psi> for the volumetric sources q and q^dagger.
An interior surface, with both interior tags
X_uandX_din the forward data: the faces are those ofX_u, n_f is theX_unormal (the positive axis), and D_f holds every direction. The forward flux comes from the side upwind of the direction (X_ufor mu_{f,d} > 0,X_dfor mu_{f,d} < 0) and the adjoint flux from the other side, which is upwind for the adjoint. Requested asXorX_u, R is measured along theX_unormal; requested asX_d, along theX_dnormal (the negative axis), which gives -R and swaps and negatesoutgoingandincoming. Each response is split intooutgoing(mu_{f,d} > 0) andincoming(mu_{f,d} < 0) parts; the response is their sum (SurfaceResponse::Total). Each direction is weighted by W w_d, with W the sum of the quadrature weights (1 for OpenSn quadratures), because moment sources enter each direction divided by W. So for an adjoint problem driven by a volumetric, material, or point response source, R equals the response it carries across the surface. Forward and adjoint directions are paired by equal direction vectors and must have equal weights. Face nodes are paired by location.
Collective over
comm. Throwsstd::invalid_argumentfor incompatible data sets, unknown surfaces, a surface requested more than once, a side of an interior surface without its other side, or an adjoint tag whose kind differs from its forward surface, andstd::logic_error, on all ranks, if any face lacks a matching face in another required tag or matching faces have different node locations.- Parameters:
forward – Forward data. Must not be adjoint.
adjoint – Adjoint data. Must be adjoint and must be distributed over
comm.surfaces – Surfaces to evaluate: boundary names and interior surface names (
X, orX_uorX_dto choose the normal). Each surface may be requested once. If empty, every surface of the forward data is evaluated, interior surfaces along theirX_unormals.comm – Communicator both data sets were distributed over.
- Returns:
One surface response per surface, in name order when
surfacesis empty and in the given order otherwise. Values are global sums.