PlasCom2  1.0
XPACC Multi-physics simluation application
plascom2::operators::sbp Namespace Reference

Namespace for SBP operators and associated data structures. More...

Detailed Description

Namespace for SBP operators and associated data structures.

Typedefs

typedef stencilset base
 The sbp::base is an SBP-specific stencilset. More...
 

Functions

bool IsValidOrder (int overallOrder)
 
int Initialize (base &stencilSet, int interiorOrder)
 Initialize the sbp::base stencilset with the SBP operator of given order. More...
 
void OperatorSetup (base &stencilSet, int interiorOrder, int boundaryDepth, int boundaryWidth, double boundaryWeight, std::vector< double > centralWeightsRight, std::vector< std::vector< double > > leftWeights, std::vector< int > leftOrders)
 Setup the SBP operator given the appropriate coefficients – called from Initialize. More...
 
int BruteTest1 (base &inOperator, int interiorOrder, int numDim, int numComponents, int numTrials, std::vector< bool > &testResults)
 Brute-force accuracy test for SBP operators. More...
 
int CreateStencilConnectivity (int numDim, size_t *dimSizes, size_t *opInterval, int boundaryDepth, int *stencilID, bool fortranInterval=false)
 Creates simple stencil connectivity assuming all domain boundaries are physical boundaries. More...
 
int CreateStencilConnectivity (int numDim, size_t *dimSizes, size_t *opInterval, int boundaryDepth, int *periodicDirs, int *stencilID, bool fortranInterval=false)
 Creates simple stencil connectivity assuming all domain boundaries are either periodic or physical boundaries. More...
 
int InvertStencilConnectivity (int numDim, size_t *dimSizes, size_t *opInterval, int numStencils, int *stencilID, size_t *dualStencilConn, size_t *numPointsStencil, bool fortranInterval=false)
 Inverts stencil connectivity to populate the so-called dual stencil connectivity More...
 
int BoundaryStencilConnectivity (std::vector< size_t > &bufferSizes, pcpp::IndexIntervalType &partitionInterval, pcpp::IndexIntervalType &partitionBufferInterval, pcpp::IndexIntervalType &boundaryInterval, int boundaryDepth, int boundaryDirection, int *stencilConnectivity)
 Update a stencil connectivity with a boundary. More...
 
int HoleStencilConnectivity (std::vector< size_t > &bufferSizes, pcpp::IndexIntervalType &partitionInterval, pcpp::IndexIntervalType &partitionBufferInterval, pcpp::IndexIntervalType &holeInterval, int holeStencil, int *stencilConnectivity)
 Update a stencil connectivity with a hole. More...
 
int MaskStencilConnectivity (int numDim, size_t *dimSizes, size_t *opInterval, int boundaryDepth, int boundaryStart, int holeBit, int *inMask, int *stencilID)
 
int DetectHoles (int numDim, size_t *dimSizes, size_t *opInterval, int boundaryDepth, int holeBit, int *inMask, int *stencilID)
 Detect unstructured holes and set up boundary stencil id's accordingly. More...
 
size_t IntervalSize (int numDim, size_t *opInterval)
 
size_t BufferSize (int numDim, size_t *dimSize)
 
int StructuredHole (int numDim, size_t *dimSizes, size_t *opInterval, size_t *holeInterval, int boundaryDepth, int boundaryStart, int holeBit, int *inMask, int *stencilID)
 

Typedef Documentation

◆ base

typedef stencilset base

The sbp::base is an SBP-specific stencilset.

SBPStencilSet.png
The sbp::base stencilset

The SBP stencilset (i.e. sbp::base) is a plascom2::operator::stencilset that contains all of the stencils implementing an SBP scheme of a given spatial order N_M (e.g. 1_2, 2_4, 4_8, etc), where N is the order of the boundary stencil and M the interior spatial order. Each scheme has an internal stencil (I) implementing an M-order finite difference (FD) operator, and some number $N_b$ of biased boundary stencils of order N for each of the left and right boundaries ( $B_l$ and $B_r$, resp), where $N_b$ is the so-called boundary depth.

The total number of stencils in the SBP stencilset is $2N_b + 1$, and they are arranged in the data structures in the following order:

{Interior, $B_l$, $B_l+1$, $B_l+2$,..., $B_l + (N_b-1)$, $R_b$, $R_b-1$, $R_b-2$,..., $R_b-(N_b-1)$}.

Definition at line 141 of file Stencil.H.

Function Documentation

◆ BoundaryStencilConnectivity()

int BoundaryStencilConnectivity ( std::vector< size_t > &  bufferSizes,
pcpp::IndexIntervalType partitionInterval,
pcpp::IndexIntervalType partitionBufferInterval,
pcpp::IndexIntervalType boundaryInterval,
int  boundaryDepth,
int  boundaryDirection,
int *  stencilConnectivity 
)

Update a stencil connectivity with a boundary.

Given a stencil connectivity, boundary interval, depth, and direction, this function populates the stencil connectivity with the stencil id that corresponds to the SBP biased boundary stencils needed to respect the specified boundary. This routine is not (yet) thread-safe.

Parameters
[in]bufferSizesstd::vector<size_t> that indicates the number of points in each dimension
[in]partitionIntervalpcpp::IndexIntervalType that indicates the local partition
[in]partitionBufferIntervalpcpp::IndexIntervalType that indicates the buffer interval for the lcoal partition
[in]boundaryIntervalpcpp::IndexIntervalType that indicates the boundary interval (wrt the global grid size)
[in]boundaryDepthinteger indicating the boundary depth for this SBP operator
[in]boundaryDirectiondirection points into the domain from the boundary
[out]stencilConnectivitythe stencil connectivity that is update with the boundary stencils on return
Returns
0 on success, non-zero otherwise

Definition at line 1114 of file Stencil.C.

References bufferInterval, sizeextent::GetFlatIndices(), sizeextent::InitSimple(), sizeextent::NNodes(), numPointsBuffer, and sizeextent::Overlap().

Referenced by rhs< GridT, StateT, OperatorT >::SetDomainBoundaries().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BruteTest1()

int BruteTest1 ( base inOperator,
int  interiorOrder,
int  numDim,
int  numComponents,
int  numTrials,
std::vector< bool > &  testResults 
)

Brute-force accuracy test for SBP operators.

This test uses the brute force ApplyOperator kernel to test the accuracy of SBP finite difference operators. It applies the indicated operator of interior order M to the N-dimensional domain $[.5,1.5]^N$, with test functions $F(x^n)$ with $ 0 \leq n \leq (M+1) $. The operator is applied in each dimension using numTrials grid refinements with $\Delta{x}_t = \frac{1.0}{(2^t)20} | 0 \leq t \leq (numTrials-1)$ to ensure that the truncation error has the proper order dependence on $\Delta{x}$.

The test results are as follows:

  • Interior stencil in dimension 1 (I1) [A := (accurate/exact?)] (pass/fail)
  • Interior stencil in dimension 2 (I2) [O := (order == interior order?)] (pass/fail)
  • (I3) [A] (pass/fail)
  • (I3) [O] (pass/fail)
  • Left boundary stencil in dimension 1 ( $B1_{l}$) [A] (pass/fail)
  • ( $B1_{l}$) [O] (pass/fail)
  • First biased stencil for left boundary
  • ( $B1_{(l+1)}$) [A] (pass/fail)
  • ( $B1_{(l+1)}$) [O] (pass/fail)
  • Left boundary stencil in dimension 2 ( $B2_{(l+1)}$) [A] (pass/fail)
  • (....)
  • ( $B(nDim)_{(l+(N_b-1))}$) [A][O] (pass/fail)
  • Right boundary stencils results
  • ( $B1_{r}$) - ( $B(nDim)_{(r-(N_b-1))}$) [A][O] (pass/fail)

In short, testResults contains: for each stencil, for each dimension, for each test (i.e. accuracy + order) the test results.

Parameters
[in]inOperatorplascom2::operator::sbp::base stencilset encapsulating the operator
[in]interiorOrderindicates the order of accuracy for the interior stencil
[in]numDimindicates the number of dimensions in which to test
[in]numComponentsindicates the number of vector components for the test function
[in]numTrialsindicates the number of successive grid refinements to use in the test
[out]testResultsa vector of boolean test results (true for pass, false for fail)

Definition at line 625 of file Stencil.C.

References operators::applyoperator(), stencilset::boundaryDepth, stencilset::boundaryWidth, CreateStencilConnectivity(), FC_MODULE(), GetFunctionOrder(), numComponents, numPoints, numStencils, stencilset::numStencils, stencilset::numValues, opDir, opInterval, stencilID, stencilset::stencilOffsets, stencilset::stencilOrders, stencilset::stencilSizes, stencilset::stencilStarts, and stencilset::stencilWeights.

Referenced by TestOperatorSBP12(), TestOperatorSBP24(), and TestOperatorSBP36().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BufferSize()

size_t plascom2::operators::sbp::BufferSize ( int  numDim,
size_t *  dimSize 
)

Definition at line 1300 of file Stencil.C.

Referenced by parallel_blockstructured::FlagData(), and InvertStencilConnectivity().

Here is the caller graph for this function:

◆ CreateStencilConnectivity() [1/2]

int CreateStencilConnectivity ( int  numDim,
size_t *  dimSizes,
size_t *  opInterval,
int  boundaryDepth,
int *  stencilID,
bool  fortranInterval = false 
)

Creates simple stencil connectivity assuming all domain boundaries are physical boundaries.

This function populates the stencilID with the ID (1-numStencils) assuming an SBP operator stencilset. An example SBP stencilset with boundaryDepth=4 has the stencil ID's arranged as follows:

  • 1: Interior stencil
  • 2: Left boundary stencil
  • 3: Left boundary + 1 biased stencil
  • 4: Left boundary + 2 biased stencil
  • 5: Left boundary + 3 biased stencil
  • 6: Right boundary stencil
  • 7: Right boundary - 1 biased stencil
  • 8: Right boundary - 2 biased stencil
  • 9: Right boundary - 3 biased stencil
Parameters
[in]numDimindicates the number of spatial dimensions
[in]dimSizesarray of size (numDim) that indicates the number of points in each dimension [Nx Ny Nz]
[in]opIntervalarray of size (2*numDim) indicating the range of indices over which to determine stencilIDs
[in]boundaryDepthindicates the boundary depth as described above
[out]stencilIDarray of pre-sized to (numDim*numPoints) which on output contains the determined stencil IDs for each dimension
[in]fortranIntervalindicates whether the opInterval is 1-based (true) or not (false). DEFAULT=false
Returns
0 on success, non-zero otherwise
Note
Holes and other non-domain boundaries not yet supported - but support will be added here (or similar)

Definition at line 840 of file Stencil.C.

References numPoints.

Referenced by BruteTest1(), rhs< GridT, StateT, OperatorT >::SetupStencilConnectivities(), TestApplyOperatorAppl(), TestApplyOperatorBlobs(), TestCurlOperator(), TestEulerKernels(), TestGrid_CurvilinearMetric(), TestGrid_CurvilinearVGWavy(), TestGrid_RectilinearMetric(), TestHoleDetection(), TestMaxwellRHS_Bfield(), and TestMaxwellRHS_Dfield().

Here is the caller graph for this function:

◆ CreateStencilConnectivity() [2/2]

int CreateStencilConnectivity ( int  numDim,
size_t *  dimSizes,
size_t *  opInterval,
int  boundaryDepth,
int *  periodicDirs,
int *  stencilID,
bool  fortranInterval = false 
)

Creates simple stencil connectivity assuming all domain boundaries are either periodic or physical boundaries.

This function populates the stencilID with the ID (1-numStencils) assuming an SBP operator stencilset. An example SBP stencilset with boundaryDepth=4 has the stencil ID's arranged as follows:

  • 1: Interior stencil
  • 2: Left boundary stencil
  • 3: Left boundary + 1 biased stencil
  • 4: Left boundary + 2 biased stencil
  • 5: Left boundary + 3 biased stencil
  • 6: Right boundary stencil
  • 7: Right boundary - 1 biased stencil
  • 8: Right boundary - 2 biased stencil
  • 9: Right boundary - 3 biased stencil
Parameters
[in]numDimindicates the number of spatial dimensions
[in]dimSizesarray of size (numDim) that indicates the number of points in each dimension [Nx Ny Nz]
[in]opIntervalarray of size (2*numDim) indicating the range of indices over which to determine stencilIDs
[in]boundaryDepthindicates the boundary depth as described above
[in]periodicDirsindicates the periodic directions
[out]stencilIDarray of pre-sized to (numDim*numPoints) which on output contains the determined stencil IDs for each dimension
[in]fortranIntervalindicates whether the opInterval is 1-based (true) or not (false). DEFAULT=false
Returns
0 on success, non-zero otherwise
Note
Holes and other non-domain boundaries (besides periodic) not yet supported - but support will be added here (or similar)

Definition at line 968 of file Stencil.C.

References numPoints.

◆ DetectHoles()

int DetectHoles ( int  numDim,
size_t *  dimSizes,
size_t *  opInterval,
int  boundaryDepth,
int  holeBit,
int *  inMask,
int *  stencilID 
)

Detect unstructured holes and set up boundary stencil id's accordingly.

Definition at line 1454 of file Stencil.C.

References bufferInterval, sizeextent::GetFlatIndices(), numPointsBuffer, numStencils, and opInterval.

Referenced by rhs< GridT, StateT, OperatorT >::SetDomainBCs(), and TestHoleDetection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HoleStencilConnectivity()

int HoleStencilConnectivity ( std::vector< size_t > &  bufferSizes,
pcpp::IndexIntervalType partitionInterval,
pcpp::IndexIntervalType partitionBufferInterval,
pcpp::IndexIntervalType holeInterval,
int  holeStencil,
int *  stencilConnectivity 
)

Update a stencil connectivity with a hole.

Sets stencil connectivity for all points inside a "hole" or iblanked region.

Given a stencil connectivity, and a hole interval, this function populates the stencil connectivity with the stencil id that corresponds to the specified hole stencil which is usually the number of SBP stencils + 1. This routine is not (yet) thread-safe.

Parameters
[in]bufferSizesstd::vector<size_t> that indicates the number of points in each dimension
[in]partitionIntervalpcpp::IndexIntervalType that indicates the local partition
[in]partitionBufferIntervalpcpp::IndexIntervalType that indicates the buffer interval for the lcoal partition
[in]holeIntervalpcpp::IndexIntervalType that indicates the interval of the hole (wrt the global grid size)
[in]holeStencilinteger to which to set the stencil connectivity
[out]stencilConnectivitythe stencil connectivity that is update with the boundary stencils on return
Returns
0 on success, non-zero otherwise

This routine takes the partition and hole global intervals and sets a hole stencil on every point inside the hole.

Definition at line 1230 of file Stencil.C.

References bufferInterval, sizeextent::GetFlatIndices(), sizeextent::InitSimple(), sizeextent::NNodes(), numPointsBuffer, and sizeextent::Overlap().

Referenced by rhs< GridT, StateT, OperatorT >::SetDomainBoundaries().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Initialize()

◆ IntervalSize()

size_t plascom2::operators::sbp::IntervalSize ( int  numDim,
size_t *  opInterval 
)

Definition at line 1293 of file Stencil.C.

Referenced by InvertStencilConnectivity().

Here is the caller graph for this function:

◆ InvertStencilConnectivity()

int InvertStencilConnectivity ( int  numDim,
size_t *  dimSizes,
size_t *  opInterval,
int  numStencils,
int *  stencilID,
size_t *  dualStencilConn,
size_t *  numPointsStencil,
bool  fortranInterval = false 
)

Inverts stencil connectivity to populate the so-called dual stencil connectivity

Given a whole stencil connectivity (i.e. wrt all partition points), this function populates the dual stencil connectivity with the points to which each stencil should be applied. The dual stencil connectivity array (dualStencilConn) must have size numDim*numPointsInterval, where numPointsInterval is inferred from the opInterval argument. The numPointsStencil array must be of size (numDim*numStencils). On output, the dualStencilConn contains a list of point id's for each stencil for each dimension.

Parameters
[in]numDimindicates the number of spatial dimensions
[in]dimSizesarray of size (numDim) that indicates the number of points in each dimension [Nx Ny Nz]
[in]opIntervalarray of size (2*numDim) indicating the range of indices over which to determine stencilIDs
[in]numStencilsindicates the number of stencils represented in the stencilID
[in]stencilIDarray of (numDim*numPoints) elements where numPoints = dimSize[0]*dimSize[1]....*dimSize[nDim-1]
[out]dualStencilConnarray of size (numDim*numPointsInterval) to store dual stencil connectivity on output
[out]numPointsStencilarray of size (numDim*numStencils) to store the number of points for each stencil in each dimension
[in]fortranIntervalindicates whether the opInterval is 1-based (true) or not (false). DEFAULT=false
Returns
0 on success, non-zero otherwise

Definition at line 1739 of file Stencil.C.

References BufferSize(), IntervalSize(), numPointsBuffer, numStencils, and opInterval.

Referenced by TestApplyOperatorBlobs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsValidOrder()

bool IsValidOrder ( int  overallOrder)

Definition at line 352 of file Stencil.C.

Referenced by application::ConfigureSimulation().

Here is the caller graph for this function:

◆ MaskStencilConnectivity()

int MaskStencilConnectivity ( int  numDim,
size_t *  dimSizes,
size_t *  opInterval,
int  boundaryDepth,
int  boundaryStart,
int  holeBit,
int *  inMask,
int *  stencilID 
)

Definition at line 1381 of file Stencil.C.

References sizeextent::GetFlatIndices(), and numPoints.

Here is the call graph for this function:

◆ OperatorSetup()

void OperatorSetup ( base stencilSet,
int  interiorOrder,
int  boundaryDepth,
int  boundaryWidth,
double  boundaryWeight,
std::vector< double >  centralWeightsRight,
std::vector< std::vector< double > >  leftWeights,
std::vector< int >  leftOrders 
)

Setup the SBP operator given the appropriate coefficients – called from Initialize.

Definition at line 485 of file Stencil.C.

References stencilset::boundaryDepth, stencilset::boundaryWeight, stencilset::boundaryWidth, stencilset::numStencils, stencilset::numValues, stencilset::overallOrder, stencilset::ownData, stencilset::stencilOffsets, stencilset::stencilOrders, stencilset::stencilSizes, stencilset::stencilStarts, and stencilset::stencilWeights.

Referenced by Initialize().

Here is the caller graph for this function:

◆ StructuredHole()

int plascom2::operators::sbp::StructuredHole ( int  numDim,
size_t *  dimSizes,
size_t *  opInterval,
size_t *  holeInterval,
int  boundaryDepth,
int  boundaryStart,
int  holeBit,
int *  inMask,
int *  stencilID 
)

Definition at line 1307 of file Stencil.C.

References sizeextent::GetFlatIndices(), numPoints, and sizeextent::Overlap().

Here is the call graph for this function: