SpatialOps
SpatialOps::SpatialFieldStore Class Reference

Provides a common interface to obtain temporary (work) fields. More...

#include <SpatialFieldStore.h>

Static Public Member Functions

template<typename FieldT >
static SpatFldPtr< FieldT > get_from_window (const MemoryWindow &w, const BoundaryCellInfo &bc, const GhostData &ghost, const short int deviceIndex=CPU_INDEX)
 Obtain a temporary field. More...
 
template<typename FieldT , typename ProtoT >
static SpatFldPtr< FieldT > get (const ProtoT &f, short int deviceIndex=-9999)
 Obtain a temporary field. More...
 
template<typename FieldT >
static void restore_field (const short int deviceIndex, FieldT &f)
 Restores a field to the store for future use. More...
 

Detailed Description

Provides a common interface to obtain temporary (work) fields.

Author
James C. Sutherland
Date
May, 2007

The SpatialFieldStore class provides a mechanism to generate temporary SpatialField objects. This prevents multiple allocation/deallocation of such objects that would be required otherwise. It is implemented as a singleton, and provides a method:

SpatFldPtr<FieldT> field = SpatialFieldStore::get<FieldT>( const FieldT& f )

to return a field with the same dimensions as the provided template field. Note that the field will not necessarily have the same values as the provided field. The supplied field is simply used to provide information needed to construct clones.

Note that the returned type, SpatFldPtr<FieldT>, should not be dereferenced and saved as a SpatialField. Doing so can cause serious memory corruption.

Thread-Parallelism Issues:

NOTE: this could get us into big trouble if we have threads running concurrently, since we would not be able to guarantee that two threads didn't use the same memory.

Definition at line 206 of file SpatialFieldStore.h.

Member Function Documentation

◆ get()

template<typename FieldT , typename ProtoT >
static SpatFldPtr<FieldT> SpatialOps::SpatialFieldStore::get ( const ProtoT &  f,
short int  deviceIndex = -9999 
)
inlinestatic

Obtain a temporary field.

Parameters
fA field to model this one after.
deviceIndexThe device location to obtain this field on. Defaults to the location where the prototype field is located. For CPU, use CPU_INDEX.

Note that you should not dereference the SpatFldPtr object to store a SpatialField reference. Doing so can cause memory corruption.

Definition at line 242 of file SpatialFieldStore.h.

References SpatialOps::is_same_type().

Here is the call graph for this function:

◆ get_from_window()

template<typename FieldT >
SpatFldPtr< FieldT > SpatialOps::SpatialFieldStore::get_from_window ( const MemoryWindow w,
const BoundaryCellInfo bc,
const GhostData ghost,
const short int  deviceIndex = CPU_INDEX 
)
inlinestatic

Obtain a temporary field.

Parameters
wA memory window describing the desired field dimensions
bcthe information on boundaries
ghostghost information
deviceIndexuse CPU_INDEX for CPU or specify which GPU to locate the field on

Note that you should not dereference the SpatFldPtr object to store a SpatialField reference. Doing so can cause memory corruption.

Definition at line 434 of file SpatialFieldStore.h.

Referenced by SpatialOps::SpatFldPtr< FieldT >::detach().

Here is the caller graph for this function:

◆ restore_field()

template<typename FieldT >
void SpatialOps::SpatialFieldStore::restore_field ( const short int  deviceIndex,
FieldT &  f 
)
inlinestatic

Restores a field to the store for future use.

Parameters
deviceIndexthe device location to restore the field to
fthe field to be restored to the store

Note that this method is should only be called by SpatFldPtr objects. Calling it anywhere else can result in memory corruption.

Definition at line 480 of file SpatialFieldStore.h.

References SpatialOps::Pool< T >::put().

Referenced by SpatialOps::SpatFldPtr< FieldT >::detach().

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

The documentation for this class was generated from the following file: