Goal of this example
This example will show how to create a field in SpatialOps
A SpatialField is comprised of a few things:
- A MemoryWindow object describes the logical layout of the field in memory. Among other things, a window contains a description of the domain size.
- A BoundaryCellInfo object describes the behavior of a field at a boundary. For face fields on structured meshes, the (+) face on the side of the domain has an extra storage location. We will explore this more later.
- A GhostData object describes the number of ghost cells on each face of the domain. These ghost cells are used to exchange data between patches on different nodes and for stencil calculations. We will explore this more later.
- A pointer to the raw block of memory for the field and its StorageMode (ExternalStorage or InternalStorage) This can either be supplied (for externally managed memory) or it will be created internally. For internally created fields, the supplied memory block will be ignored and can be NULL.
- The location of the field (CPU, GPU, etc.). Fields can be created on a CPU, GPU, etc. and moved between these devices. In fact, a field can be on multiple devices at once.
For now, don't worry about these details - they will be covered in more detail in later examples.
- A SpatialField is strongly typed. There are several supported field types defined for fields associated with structured meshes listed here. This will also be explored more in later examples.
- The SpatialFieldStore can be used to quickly build fields. It returns SpatFldPtr objects that have pointer semantics and are reference-counted.
# define LOCATION GPU_INDEX
# define LOCATION CPU_INDEX
const bool bcx=true, bcy=true, bcz=true;
bcInfo = BoundaryCellInfo::build<FieldT>( bcx, bcy, bcz );
fieldDim( 10, 9, 8 );
FieldT f( window, bcInfo, nghost, NULL, InternalStorage, LOCATION );