Static Space

The StaticSpace object is the basis of structured grid management in turboWAVE. It is the root of the space-time mesh inheritance tree.

  • StaticSpace - basic topology and indexing that stays constant throughout a simulation

  • DynSpace - adds coordinates or parameters that may evolve during a simulation

  • MetricSpace - adds metric information geared toward finite volume methods

Owing to the nature of particle-in-cell, there is a tight coupling between certain concepts associated with particles and the StaticSpace object.

Boundary Conditions

namespace bc

boundary conditions

Enums

enum class par

boundary conditions for particles

Values:

enumerator none
enumerator periodic
enumerator reflecting
enumerator absorbing
enumerator emitting
enumerator axisymmetric
enum class fld

boundary conditions for fields

Values:

enumerator none
enumerator periodic
enumerator normalFluxFixed
enumerator dirichletWall
enumerator neumannWall
enumerator dirichletCell
enumerator natural

Functions

inline std::map<std::string, par> par_map()

Maps input file identifiers to particle B.C. enumeration identifiers.

inline std::map<std::string, fld> fld_map()

Maps input file identifiers to field B.C. enumeration identifiers.

Grid Axes

namespace grid

Types and maps for working with grid axes.

Enums

enum geometry

Values:

enumerator cartesian
enumerator cylindrical
enumerator spherical
enum axis

Values:

enumerator t
enumerator x
enumerator y
enumerator z
enumerator mass
enumerator px
enumerator py
enumerator pz
enumerator g
enumerator gbx
enumerator gby
enumerator gbz
enumerator Qp
enum side

Values:

enumerator low
enumerator high

Functions

inline std::map<std::string, axis> axis_map()
inline std::string pretty_axis_label(const tw::grid::axis &axis)
inline tw::Int naxis(const tw::grid::axis &axis)
inline axis enumaxis(tw::Int ax)

Particle Primitives

struct Primitive

Abstraction for location on a grid.

Public Members

tw::Int cell

The reference cell encoded as a single integer.

float x[4]

This is the relative position in a space-time cell, referenced to the interval [-0.5,0.5). The components can represent arbitrary coordinates. The time component x[0] is not involved with cell encoding.

struct Particle

Data describing any kind of particle.

Public Functions

inline Particle(const float number, const Primitive &q, const tw::vec4 &p, const tw::vec4 &s, const uint64_t tag, const tw::Float &Qparam) noexcept

Constructor, parameters shadow the member variables.

Public Members

float number

particles per macroparticle divided by n_0(c/wp)^3

Primitive q

abstraction for the spatial coordinate

tw::vec4 p

momentum , always known in Cartesian coordinates

tw::vec4 s

polarization, always known in Cartesian coordinates

uint64_t tag

unique identifier, low 32 bits is the node of origin

Friends

inline friend bool operator<(const Particle &p1, const Particle &p2)

Used to define the ordering of particles for std::sort

struct ParticleRef

Used to create sorting map within a thread for subsets of particle lists.

struct TransferParticle

Used to pack data for message passing of particles The destination information is computed on the source node and packaged with the particle. No floating point operations other than copying should be needed.

Public Members

tw::Int dst[4]

dst[0] is rank of starting domain upon construction; gets set to destination domain later. dst[1..3] are -1, 0, or 1, giving direction of movement or no movement.

float number

particles per macroparticle divided by n_0(c/wp)^3

tw::Int ijk[4]

topological indices referenced on the source node

float x[4]

for transfers, the relative cell position can be kept without change

tw::vec4 p

for tansfers, momentum can be kept unchanged

tw::vec4 s

for transfers, polarization can be kept unchanged

uint64_t tag

for transfers, tag can be kept unchanged

struct weights_3D

This holds the coefficients used to spread the particle cloud across 3x3x3 grid cells. Due to assumptions of separability this only requires storing 3x3 coefficients.

Public Members

tw::Float w[3][3]

The weights are packed in a 3x3 matrix. The first index (row) selects a cell from a 3-cell strip along a given axis, the second index (column) selects the axis, and the value is the weight factor in the cell.

tw::Int cell

Encoded representation of the cell in which the particle center resides.

StaticSpace Object

struct StaticSpace

This object is an indexing and interpolation scheme for a 5D structured grid. The five dimensions are spacetime plus an internal dimension such as vector components. Cells in the space are addressed as (t,x,y,z,c).

StaticSpace should only contain data that can be assumed to be static throughout a simulation. Spaces with evolving properties are reserved for derivative objects.

Consider first the topological indices, defined as follows.

Let ax be an axis index, numbered from 0 to 3 (leave out 4). Consider a one dimensional strip of cells lined up along axis ax. Suppose this axis uses L ghost cell layers. Then, for any such strip,

  • Interior cells are labeled [1,...,dim[ax]]

  • Lower ghost cells are labeled [1-L,...,0]

  • Upper ghost cells are labeled [dim[ax]+1,...,dim[ax]+L].

The internal dimension labeled 4 is different. For the internal space ghost cells have no meaning. So this axis has elements labeled [0,...,dim[4]-1] in all cases.

The topological indices are independent of all storage patterns, In other words, no matter what storage pattern is used, toplogical index (t0,x0,y0,z0,c0) will always refer to the same cell.

Storage patterns are dictated by the packing array, which in turn provides a cell encoding that maps the topological indices to a memory location.

Subclassed by Driver, DynSpace, Field

Public Functions

inline StaticSpace()

Create an empty StaticSpace

inline StaticSpace(const tw::node5 &dim, const tw::vec4 &size, const tw::node5 &packing, const tw::node4 &ghostCellLayers)

Create a StaticSpace with purely local coordinates.

inline StaticSpace ax0(const tw::Int &n) const

Make a copy of this StaticSpace and change the number of time levels.

inline StaticSpace ax4(const tw::Int &c) const

Make a copy of this StaticSpace and change the number of components.

inline StaticSpace Repack(const tw::node5 &packing) const

Make a copy of this StaticSpace and change the packing.

void Resize(const tw::node5 &domains, const tw::node5 &gdim, const tw::vec4 &gsize, const tw::node5 &packing, const tw::node4 &ghostCellLayers)

Resize a StaticSpace with the given global parameters.

inline tw::Int EncodeCell(tw::Int n, tw::Int i, tw::Int j, tw::Int k) const

Encode cell with topological indices (n,i,j,k,0)

inline void EncodeCell(tw::Int cell[tw::max_bundle_size], const tw::Int topo[4][tw::max_bundle_size]) const

Bundle version of EncodeCell

inline void DecodeCell(const tw::Int &cell, tw::Int topo[4]) const

Decode cell to produce topological indices (topo[0..4]) assuming topo[4]==0.

inline void DecodeCell(const tw::Int cell[tw::max_bundle_size], tw::Int topo[4][tw::max_bundle_size]) const

Bundle version of DecodeCell

inline void DecodeCell(const Primitive &q, tw::Int topo[4]) const

Decode q to produce topological indices (topo[0..4]).

inline void MinimizePrimitive(Primitive &q) const

Change the reference cell to the one containing the particle centroid. This leaves x[ax] within the normal range [-.5,.5) except when the particle has left the extended domain. In the latter case the reference cell is pegged to the current extended domain, leaving x[ax] out of normal range.

inline void MinimizePrimitive(tw::Int cell[tw::max_bundle_size], tw::Int topo[4][tw::max_bundle_size], float x[4][tw::max_bundle_size], float domainMask[tw::max_bundle_size]) const

Bundle version of MinimizePrimitive. The bundle version also sets the domainMask to 0 for particles out of the interior domain, 1 otherwise. Also the topological indices are loaded for further use.

Protected Attributes

tw::vec4 spacing

center-to-center cell separation along each axis (uniform grids only)

tw::vec4 freq

inverse of spacing component by component (uniform grids only)

tw::node5 dim

dim[0..5] are the number of cells along each axis. At this level we have only a static view into an empty spacetime. We will often have dim[0] = 1, i.e., the view being considered is a snapshot.

tw::node5 num

num is similar to dim, except ghost cells are included.

tw::node5 encodingStride

Parameters of the cell encoding. The encodingStride is 0 along an ignorable axis resulting in a many-one mapping, i.e., ghost cells and the one interior cell map to the same cell for the ignorable axis.

tw::node5 decodingStride

The decodingStride differs from the encodingStride only in that ignorable axes have unit strides.

tw::node5 packing

Map of axes in order of large stride to small stride, it is not required, but very desirable, that the internal dimension always be the largest stride. In that case iterators are compatible with any Field object that shares the same spatio-temporal structure.

tw::node4 lfg

indices of lower far ghost cells, no internal axis

tw::node4 ufg

indices of upper far ghost cells, no internal axis

tw::node4 lng

indices of lower near ghost cells, no internal axis

tw::node4 ung

indices of upper near ghost cells, no internal axis

tw::node4 layers

number of ghost cell layers, no internal axis

tw::node5 ignorable

1 if axis is ignorable, 0 otherwise