Function opensn::ComputeSurfaceResponses

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_u and X_d in the forward data: the faces are those of X_u, n_f is the X_u normal (the positive axis), and D_f holds every direction. The forward flux comes from the side upwind of the direction (X_u for mu_{f,d} > 0, X_d for mu_{f,d} < 0) and the adjoint flux from the other side, which is upwind for the adjoint. Requested as X or X_u, R is measured along the X_u normal; requested as X_d, along the X_d normal (the negative axis), which gives -R and swaps and negates outgoing and incoming. Each response is split into outgoing (mu_{f,d} > 0) and incoming (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. Throws std::invalid_argument for 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, and std::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, or X_u or X_d to choose the normal). Each surface may be requested once. If empty, every surface of the forward data is evaluated, interior surfaces along their X_u normals.

  • comm – Communicator both data sets were distributed over.

Returns:

One surface response per surface, in name order when surfaces is empty and in the given order otherwise. Values are global sums.