walberla::field::Field< T, fSize_ > Class Template Reference

Detailed Description

template<typename T, uint_t fSize_>
class walberla::field::Field< T, fSize_ >

A four dimensional field/lattice.

Implemented as a vector style container using consecutive memory to provide fixed time access to any member. The four coordinates are labeled x,y,z,f. Two memory layouts (linearization strategies) are offered, see Layout

layout.png
Two possible field layouts

Template Parameters:

  • T type that is stored in the field
  • fSize size of the f coordinate

See also Overview of Field Module

#include <FieldIterator.h>

+ Inheritance diagram for walberla::field::Field< T, fSize_ >:

Public Member Functions

Construction & Destruction
 Field (uint_t xSize, uint_t ySize, uint_t zSize, const Layout &layout=zyxf, const shared_ptr< FieldAllocator< T > > &alloc=shared_ptr< FieldAllocator< T > >())
 Creates an uninitialized field of given size. More...
 
 Field (uint_t xSize, uint_t ySize, uint_t zSize, const T &initValue, const Layout &layout=zyxf, const shared_ptr< FieldAllocator< T > > &alloc=shared_ptr< FieldAllocator< T > >())
 Creates a field and initializes it with constant. More...
 
 Field (uint_t xSize, uint_t ySize, uint_t zSize, const std::vector< T > &fValues, const Layout &layout=zyxf, const shared_ptr< FieldAllocator< T > > &alloc=shared_ptr< FieldAllocator< T > >())
 Creates a field and initializes f coordinate with vector values. More...
 
virtual ~Field ()
 Destructor, using Allocator template parameter. More...
 
void init (uint_t xSize, uint_t ySize, uint_t zSize, const Layout &layout=zyxf, shared_ptr< FieldAllocator< T > > alloc=shared_ptr< FieldAllocator< T > >(), uint_t innerGhostLayerSizeForAlignedAlloc=0)
 Initializes the field with a given size, in a given layout. More...
 
virtual void resize (uint_t xSize, uint_t ySize, uint_t zSize)
 Deletes all stored data, and resizes the field. More...
 
Field< T, fSize_ > * clone () const
 Returns a deep copy of the current field. More...
 
Field< T, fSize_ > * cloneUninitialized () const
 Creates a new field that has equal size and layout as this field. More...
 
Field< T, fSize_ > * cloneShallowCopy () const
 Returns a shallow copy of the current field. More...
 
Element Access
T & get (cell_idx_t x, cell_idx_t y, cell_idx_t z)
 get function with only (x,y,z) coordinates, assumes fSize=1 More...
 
const T & get (cell_idx_t x, cell_idx_t y, cell_idx_t z) const
 get function with only (x,y,z) coordinates, assumes fSize=1 More...
 
T & get (cell_idx_t x, cell_idx_t y, cell_idx_t z, cell_idx_t f)
 Non-Const variant of get() More...
 
const T & get (cell_idx_t x, cell_idx_t y, cell_idx_t z, cell_idx_t f) const
 Accesses the value at given coordinate. More...
 
T & get (cell_idx_t x, cell_idx_t y, cell_idx_t z, uint_t f)
 get() variant which takes a uint_t as last coordinate, as for example Stencil::toIdx() returns More...
 
const T & get (cell_idx_t x, cell_idx_t y, cell_idx_t z, uint_t f) const
 get() variant which takes a uint_t as last coordinate, as for example Stencil::toIdx() returns More...
 
T & get (const Cell &cell)
 get overload using a cell as input, only possible if fSize=1 More...
 
const T & get (const Cell &cell) const
 get overload using a cell as input, only possible if fSize=1 More...
 
T & get (const Cell &c, cell_idx_t f)
 
const T & get (const Cell &c, cell_idx_t f) const
 
T & get (const Cell &c, uint_t f)
 
const T & get (const Cell &c, uint_t f) const
 
T & get (const base_iterator &iter)
 get overload, where position is specified using an iterator of another field with equal size More...
 
const T & get (const base_iterator &iter) const
 get overload, where position is specified using an iterator of another field with equal size More...
 
T & operator() (cell_idx_t x, cell_idx_t y, cell_idx_t z)
 
const T & operator() (cell_idx_t x, cell_idx_t y, cell_idx_t z) const
 
T & operator() (cell_idx_t x, cell_idx_t y, cell_idx_t z, cell_idx_t f)
 
const T & operator() (cell_idx_t x, cell_idx_t y, cell_idx_t z, cell_idx_t f) const
 
T & operator() (cell_idx_t x, cell_idx_t y, cell_idx_t z, uint_t f)
 
const T & operator() (cell_idx_t x, cell_idx_t y, cell_idx_t z, uint_t f) const
 
T & operator() (const Cell &cell)
 
const T & operator() (const Cell &cell) const
 
T & operator() (const Cell &cell, cell_idx_t f)
 
const T & operator() (const Cell &cell, cell_idx_t f) const
 
T & operator() (const Cell &cell, uint_t f)
 
const T & operator() (const Cell &cell, uint_t f) const
 
T & operator() (const base_iterator &iter)
 
const T & operator() (const base_iterator &iter) const
 
T & getNeighbor (cell_idx_t x, cell_idx_t y, cell_idx_t z, stencil::Direction d)
 returns neighboring value of cell in the given direction More...
 
const T & getNeighbor (cell_idx_t x, cell_idx_t y, cell_idx_t z, stencil::Direction d) const
 returns neighboring value of cell in the given direction More...
 
T & getNeighbor (cell_idx_t x, cell_idx_t y, cell_idx_t z, uint_t f, stencil::Direction d)
 returns neighboring value of cell in the given direction More...
 
const T & getNeighbor (cell_idx_t x, cell_idx_t y, cell_idx_t z, uint_t f, stencil::Direction d) const
 returns neighboring value of cell in the given direction More...
 
T & getNeighbor (const Cell &cell, stencil::Direction d)
 get overload using a cell as input, only possible if fSize=1, with neighbor access More...
 
const T & getNeighbor (const Cell &cell, stencil::Direction d) const
 get overload using a cell as input, only possible if fSize=1, with neighbor access More...
 
T & getF (T *const xyz0, const cell_idx_t f)
 
const T & getF (const T *const xyz0, const cell_idx_t f) const
 
T & getF (T *const xyz0, const uint_t f)
 
const T & getF (const T *const xyz0, const uint_t f) const
 
void set (const T &value)
 Sets all entries of the field to given value. More...
 
void set (const std::vector< T > &fValues)
 Initializes the f coordinate to values from vector Sets the entry (x,y,z,f) to fValues[f]. More...
 
void set (const Field< T, fSize_ > &other)
 Copies all entries of the given field to this field. More...
 
void set (const Field< T, fSize_ > *other)
 
void swapDataPointers (Field< T, fSize_ > &other)
 Swap two fields efficiently by exchanging only values_ pointer The two fields have to have identical sizes and same layout. More...
 
void swapDataPointers (Field< T, fSize_ > *other)
 
Equality Checks
bool operator== (const Field< T, fSize_ > &other) const
 Equality operator compares element-wise. More...
 
bool operator!= (const Field< T, fSize_ > &other) const
 Inequality operator compares element-wise. More...
 
bool hasSameAllocSize (const Field< T, fSize_ > &other) const
 True if allocation sizes of all dimensions match. More...
 
bool hasSameSize (const Field< T, fSize_ > &other) const
 True if sizes of all dimensions match. More...
 
Iterators
iterator begin ()
 Returns iterator, which can iterate over complete field in a suitable order depending on layout. More...
 
const_iterator begin () const
 Returns const_iterator, see begin() More...
 
iterator beginXYZ ()
 Iterates only over XYZ coordinate, f is always 0. More...
 
const_iterator beginXYZ () const
 Const version of beginXYZ() More...
 
iterator beginSlice (cell_idx_t xBeg, cell_idx_t yBeg, cell_idx_t zBeg, cell_idx_t fBeg, cell_idx_t xEnd, cell_idx_t yEnd, cell_idx_t zEnd, cell_idx_t fEnd)
 Returns iterator which iterates over a sub-block of the field. More...
 
const_iterator beginSlice (cell_idx_t xBeg, cell_idx_t yBeg, cell_idx_t zBeg, cell_idx_t fBeg, cell_idx_t xEnd, cell_idx_t yEnd, cell_idx_t zEnd, cell_idx_t fEnd) const
 Const variant of beginSlice() More...
 
iterator beginSliceXYZ (const CellInterval &interval, cell_idx_t f=0)
 Returns iterator which iterates over a slice, but only in x,y,z coordinates. More...
 
const_iterator beginSliceXYZ (const CellInterval &interval, cell_idx_t f=0) const
 Const variant of beginSliceXYZ() More...
 
const iteratorend ()
 
const const_iteratorend () const
 
Reverse Iterators
reverse_iterator rbegin ()
 Returns reverse iterator, which can iterate over complete field in a suitable order depending on layout. More...
 
const_reverse_iterator rbegin () const
 Returns const_reverse_iterator, see begin() More...
 
reverse_iterator rbeginXYZ ()
 Iterates only over XYZ coordinate, f is always 0. More...
 
const_reverse_iterator rbeginXYZ () const
 Const version of beginXYZ() More...
 
const reverse_iteratorrend ()
 
const const_reverse_iteratorrend () const
 
Size and Layout Information
uint_t xSize () const
 
uint_t ySize () const
 
uint_t zSize () const
 
uint_t fSize () const
 
uint_t size (uint_t coord) const
 
uint_t xAllocSize () const
 
uint_t yAllocSize () const
 
uint_t zAllocSize () const
 
uint_t fAllocSize () const
 
uint_t allocSize () const
 
CellInterval xyzSize () const
 
CellInterval xyzAllocSize () const
 
Layout layout () const
 
cell_idx_t xStride () const
 
cell_idx_t yStride () const
 
cell_idx_t zStride () const
 
cell_idx_t fStride () const
 
cell_idx_t xOff () const
 
cell_idx_t yOff () const
 
cell_idx_t zOff () const
 
bool coordinatesValid (cell_idx_t x, cell_idx_t y, cell_idx_t z, cell_idx_t f) const
 
Slicing
Field< T, fSize_ > * getSlicedField (const CellInterval &interval) const
 Create a different "view" of the field, where the created field has the size of the given sliceInterval. More...
 
virtual void slice (const CellInterval &interval)
 Changes the coordinate system of the field. More...
 
virtual void shiftCoordinates (cell_idx_t cx, cell_idx_t cy, cell_idx_t cz)
 
Pointer to internal memory - use with care!
T * data ()
 
const T * data () const
 
T * dataInner ()
 
const T * dataInner () const
 
shared_ptr< FieldAllocator< T > > getAllocator () const
 Returns internal data allocator. More...
 

Static Public Attributes

Static cached end iterators
static const const_iterator staticConstEnd = ForwardFieldIterator<const T,fSize_>()
 Const end iterator, see end() More...
 
static const iterator staticEnd = ForwardFieldIterator<T,fSize_>()
 End iterator, can be used with begin() and beginBlock() More...
 
static const const_reverse_iterator staticConstREnd = ReverseFieldIterator<const T,fSize_>()
 Const end iterator, see end() More...
 
static const reverse_iterator staticREnd = ReverseFieldIterator<T,fSize_>()
 End iterator, can be used with begin() and beginBlock() More...
 

Protected Member Functions

 Field ()
 Creates an uninitialized field of size zero (no allocated memory) More...
 
Shallow Copy
 Field (const Field &other)
 Private copy constructor that creates a shallow copy i.e. More...
 
virtual uint_t referenceCount () const
 Returns the number of objects that internally use the same data. More...
 
virtual Field< T, fSize_ > * cloneShallowCopyInternal () const
 Does the same as cloneShallowCopy (but is virtual) More...
 
Changing Offsets
void setOffsets (uint_t xOffset, uint_t xSize, uint_t yOffset, uint_t ySize, uint_t zOffset, uint_t zSizes)
 Moves the coordinate system of the field. More...
 
shared_ptr< FieldAllocator< T > > allocator () const
 
bool addressInsideAllocedSpace (const T *const value) const
 
void assertValidCoordinates (cell_idx_t x, cell_idx_t y, cell_idx_t z, cell_idx_t f) const
 

Private Member Functions

Fieldoperator= (const Field &)
 

Private Attributes

T * values_
 Linearized, 1-dimensional representation of the 4D data grid. More...
 
T * valuesWithOffset_
 set by setOffsets(), to allow derived classes to change the offset More...
 
cell_idx_t xOff_
 Offset of the xSize() to xAllocSize() More...
 
cell_idx_t yOff_
 Offset of the ySize() to yAllocSize() More...
 
cell_idx_t zOff_
 Offset of the zSize() to zAllocSize() More...
 
uint_t xSize_
 Number of cells in x-dimension (excluding padded cells) More...
 
uint_t ySize_
 Number of cells in y-dimension (excluding padded cells) More...
 
uint_t zSize_
 Number of cells in z-dimension (excluding padded cells) More...
 
uint_t xAllocSize_
 Number of cells in x-dimension (including padded cells) More...
 
uint_t yAllocSize_
 Number of cells in y-dimension (including padded cells) More...
 
uint_t zAllocSize_
 Number of cells in z-dimension (including padded cells) More...
 
uint_t fAllocSize_
 Number of cells in f-dimension (including padded cells) More...
 
Layout layout_
 Determines in which order the values are stored. More...
 
uint_t allocSize_
 The overall size of the T* (padding included) More...
 
cell_idx_t ffact_
 Access multiplication factor for the f-dimension. More...
 
cell_idx_t xfact_
 Access multiplication factor for the x-dimension. More...
 
cell_idx_t yfact_
 Access multiplication factor for the y-dimension. More...
 
cell_idx_t zfact_
 Access multiplication factor for the z-dimension. More...
 
shared_ptr< FieldAllocator< T > > allocator_
 Allocator for the field. More...
 

Friends

class FieldIterator< T, fSize_ >
 
class FieldIterator< const T, fSize_ >
 

Type Definitions

typedef T value_type
 
typedef ForwardFieldIterator< T, fSize_ > iterator
 
typedef ForwardFieldIterator< const T, fSize_ > const_iterator
 
typedef ReverseFieldIterator< T, fSize_ > reverse_iterator
 
typedef ReverseFieldIterator< const T, fSize_ > const_reverse_iterator
 
typedef FieldIterator< T, fSize_ > base_iterator
 
typedef FieldIterator< const T, fSize_ > const_base_iterator
 
typedef FieldPointer< Field< T, fSize_ >, Field< T, fSize_ >, T > Ptr
 
typedef FieldPointer< Field< T, fSize_ >, const Field< T, fSize_ >, const T > ConstPtr
 
static const uint_t F_SIZE = fSize_
 

Monitoring

typedef boost::function< void(cell_idx_t x, cell_idx_t y, cell_idx_t z, cell_idx_t f, const T &value) > MonitorFunction
 
void addMonitoringFunction (const MonitorFunction &func)
 Registers a monitoring function. More...
 

Member Typedef Documentation

template<typename T , uint_t fSize_>
typedef FieldIterator<T,fSize_ > walberla::field::Field< T, fSize_ >::base_iterator
template<typename T , uint_t fSize_>
typedef FieldIterator<const T,fSize_ > walberla::field::Field< T, fSize_ >::const_base_iterator
template<typename T , uint_t fSize_>
typedef ForwardFieldIterator<const T,fSize_> walberla::field::Field< T, fSize_ >::const_iterator
template<typename T , uint_t fSize_>
typedef ReverseFieldIterator<const T,fSize_> walberla::field::Field< T, fSize_ >::const_reverse_iterator
template<typename T , uint_t fSize_>
typedef FieldPointer<Field<T,fSize_>, const Field<T,fSize_>, const T > walberla::field::Field< T, fSize_ >::ConstPtr
template<typename T , uint_t fSize_>
typedef ForwardFieldIterator<T,fSize_> walberla::field::Field< T, fSize_ >::iterator
template<typename T , uint_t fSize_>
typedef boost::function< void ( cell_idx_t x, cell_idx_t y, cell_idx_t z, cell_idx_t f, const T & value) > walberla::field::Field< T, fSize_ >::MonitorFunction
template<typename T , uint_t fSize_>
typedef FieldPointer<Field<T,fSize_>, Field<T,fSize_>, T > walberla::field::Field< T, fSize_ >::Ptr
template<typename T , uint_t fSize_>
typedef ReverseFieldIterator<T,fSize_> walberla::field::Field< T, fSize_ >::reverse_iterator
template<typename T , uint_t fSize_>
typedef T walberla::field::Field< T, fSize_ >::value_type

Constructor & Destructor Documentation

template<typename T , uint_t fSize_>
walberla::field::Field< T, fSize_ >::Field ( uint_t  _xSize,
uint_t  _ySize,
uint_t  _zSize,
const Layout l = zyxf,
const shared_ptr< FieldAllocator< T > > &  alloc = shared_ptr<FieldAllocator<T> >() 
)

Creates an uninitialized field of given size.

Parameters
xSizesize of x dimension
ySizesize of y dimension
zSizesize of z dimension
layoutmemory layout of the field (see Field::Layout)
allocclass that describes how to allocate memory for the field, see FieldAllocator
template<typename T , uint_t fSize_>
walberla::field::Field< T, fSize_ >::Field ( uint_t  _xSize,
uint_t  _ySize,
uint_t  _zSize,
const T &  initVal,
const Layout l = zyxf,
const shared_ptr< FieldAllocator< T > > &  alloc = shared_ptr<FieldAllocator<T> >() 
)

Creates a field and initializes it with constant.

Parameters
xSizesize of x dimension
ySizesize of y dimension
zSizesize of z dimension
initValevery element of the field is set to initVal
layoutmemory layout of the field (see Field::Layout)
allocclass that describes how to allocate memory for the field, see FieldAllocator
template<typename T , uint_t fSize_>
walberla::field::Field< T, fSize_ >::Field ( uint_t  _xSize,
uint_t  _ySize,
uint_t  _zSize,
const std::vector< T > &  fValues,
const Layout l = zyxf,
const shared_ptr< FieldAllocator< T > > &  alloc = shared_ptr<FieldAllocator<T> >() 
)

Creates a field and initializes f coordinate with vector values.

Parameters
xSizesize of x dimension
ySizesize of y dimension
zSizesize of z dimension
fValuesinitializes f coordinate with values from vector (see set(std::vector&) )
layoutmemory layout of the field (see Field::Layout)
allocclass that describes how to allocate memory for the field, see FieldAllocator
template<typename T , uint_t fSize>
walberla::field::Field< T, fSize >::~Field ( )
virtual

Destructor, using Allocator template parameter.

template<typename T , uint_t fSize_>
walberla::field::Field< T, fSize_ >::Field ( )
protected

Creates an uninitialized field of size zero (no allocated memory)

This field has to be initialized before it can be used using the init() method

template<typename T , uint_t fSize_>
walberla::field::Field< T, fSize_ >::Field ( const Field< T, fSize_ > &  other)
protected

Private copy constructor that creates a shallow copy i.e.

reuses the memory of the copied field

Member Function Documentation

template<typename T , uint_t fSize>
void walberla::field::Field< T, fSize >::addMonitoringFunction ( const MonitorFunction func)

Registers a monitoring function.

Monitoring works only if compiled with WALBERLA_FIELD_MONITORED_ACCESS. When a field is accessed either by get() or operator() the monitoring function is called

template<typename T , uint_t fSize_>
bool walberla::field::Field< T, fSize_ >::addressInsideAllocedSpace ( const T *const  value) const
inlineprotected
template<typename T , uint_t fSize_>
shared_ptr<FieldAllocator<T> > walberla::field::Field< T, fSize_ >::allocator ( ) const
inlineprotected
template<typename T , uint_t fSize_>
uint_t walberla::field::Field< T, fSize_ >::allocSize ( ) const
inline
template<typename T , uint_t fSize_>
void walberla::field::Field< T, fSize_ >::assertValidCoordinates ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z,
cell_idx_t  f 
) const
protected
template<typename T , uint_t fSize_>
Field< T, fSize_ >::iterator walberla::field::Field< T, fSize_ >::begin ( )
inline

Returns iterator, which can iterate over complete field in a suitable order depending on layout.

Use this when iterating over a complete field, faster than 4 nested loops and operator() calls in the innermost loop because no index calculations have to be done.

template<typename T , uint_t fSize_>
Field< T, fSize_ >::const_iterator walberla::field::Field< T, fSize_ >::begin ( ) const
inline

Returns const_iterator, see begin()

template<typename T , uint_t fSize_>
Field< T, fSize_ >::iterator walberla::field::Field< T, fSize_ >::beginSlice ( cell_idx_t  xBeg,
cell_idx_t  yBeg,
cell_idx_t  zBeg,
cell_idx_t  fBeg,
cell_idx_t  xEnd,
cell_idx_t  yEnd,
cell_idx_t  zEnd,
cell_idx_t  fEnd 
)
inline

Returns iterator which iterates over a sub-block of the field.

  • Iterator over block defined by ( xBeg <= x < xEnd, yBeg <= y < yEnd, ....)
  • layout aware
template<typename T , uint_t fSize_>
Field< T, fSize_ >::const_iterator walberla::field::Field< T, fSize_ >::beginSlice ( cell_idx_t  xBeg,
cell_idx_t  yBeg,
cell_idx_t  zBeg,
cell_idx_t  fBeg,
cell_idx_t  xEnd,
cell_idx_t  yEnd,
cell_idx_t  zEnd,
cell_idx_t  fEnd 
) const
inline

Const variant of beginSlice()

template<typename T , uint_t fSize_>
Field< T, fSize_ >::iterator walberla::field::Field< T, fSize_ >::beginSliceXYZ ( const CellInterval &  ci,
cell_idx_t  f = 0 
)
inline

Returns iterator which iterates over a slice, but only in x,y,z coordinates.

Parameters
ffixed value of f coordinate, where iterator points to in each cell
template<typename T , uint_t fSize_>
Field< T, fSize_ >::const_iterator walberla::field::Field< T, fSize_ >::beginSliceXYZ ( const CellInterval &  interval,
cell_idx_t  f = 0 
) const
inline

Const variant of beginSliceXYZ()

template<typename T , uint_t fSize_>
Field< T, fSize_ >::iterator walberla::field::Field< T, fSize_ >::beginXYZ ( )
inline

Iterates only over XYZ coordinate, f is always 0.

template<typename T , uint_t fSize_>
Field< T, fSize_ >::const_iterator walberla::field::Field< T, fSize_ >::beginXYZ ( ) const
inline

Const version of beginXYZ()

template<typename T , uint_t fSize_>
Field< T, fSize_ > * walberla::field::Field< T, fSize_ >::clone ( ) const

Returns a deep copy of the current field.

The data is copied over.

Returns
a new field, that has to be freed by caller
template<typename T , uint_t fSize_>
Field< T, fSize_ > * walberla::field::Field< T, fSize_ >::cloneShallowCopy ( ) const

Returns a shallow copy of the current field.

Shallow copy means, that the new field internally uses the same memory as this field.

Returns
a new field, that has to be freed by caller
template<typename T , uint_t fSize_>
Field< T, fSize_ > * walberla::field::Field< T, fSize_ >::cloneShallowCopyInternal ( ) const
protectedvirtual

Does the same as cloneShallowCopy (but is virtual)

This version has to be implemented by derived classes. The cloneShallowCopy() itself cannot be virtual, since the implementation of cloneShallowCopy() of derived classes has a different signature.

Reimplemented in walberla::field::GhostLayerField< T, fSize_ >, walberla::field::GhostLayerField< T, 1 >, and walberla::field::FlagField< T >.

template<typename T , uint_t fSize_>
Field< T, fSize_ > * walberla::field::Field< T, fSize_ >::cloneUninitialized ( ) const

Creates a new field that has equal size and layout as this field.

The memory of the new field is uninitialized.

Returns
a new field, that has to be freed by caller
template<typename T , uint_t fSize_>
bool walberla::field::Field< T, fSize_ >::coordinatesValid ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z,
cell_idx_t  f 
) const
template<typename T , uint_t fSize_>
T* walberla::field::Field< T, fSize_ >::data ( )
inline
template<typename T , uint_t fSize_>
const T* walberla::field::Field< T, fSize_ >::data ( ) const
inline
template<typename T , uint_t fSize_>
T* walberla::field::Field< T, fSize_ >::dataInner ( )
inline
template<typename T , uint_t fSize_>
const T* walberla::field::Field< T, fSize_ >::dataInner ( ) const
inline
template<typename T , uint_t fSize_>
const Field< T, fSize_ >::iterator & walberla::field::Field< T, fSize_ >::end ( )
inline
template<typename T , uint_t fSize_>
const Field< T, fSize_ >::const_iterator & walberla::field::Field< T, fSize_ >::end ( ) const
inline
template<typename T , uint_t fSize_>
uint_t walberla::field::Field< T, fSize_ >::fAllocSize ( ) const
inline
template<typename T , uint_t fSize_>
uint_t walberla::field::Field< T, fSize_ >::fSize ( ) const
inline
template<typename T , uint_t fSize_>
cell_idx_t walberla::field::Field< T, fSize_ >::fStride ( ) const
inline
template<typename T , uint_t fSize_>
T & walberla::field::Field< T, fSize_ >::get ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z 
)
inline

get function with only (x,y,z) coordinates, assumes fSize=1

template<typename T , uint_t fSize_>
const T & walberla::field::Field< T, fSize_ >::get ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z 
) const
inline

get function with only (x,y,z) coordinates, assumes fSize=1

template<typename T , uint_t fSize_>
T & walberla::field::Field< T, fSize_ >::get ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z,
cell_idx_t  f 
)
inline

Non-Const variant of get()

template<typename T , uint_t fSize_>
const T & walberla::field::Field< T, fSize_ >::get ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z,
cell_idx_t  f 
) const
inline

Accesses the value at given coordinate.

When WALBERLA_FIELD_MONITORED_ACCESS is defined, all registered monitor functions are executed when get is called

Note
operator() is equivalent to this function
template<typename T , uint_t fSize_>
T & walberla::field::Field< T, fSize_ >::get ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z,
uint_t  f 
)
inline

get() variant which takes a uint_t as last coordinate, as for example Stencil::toIdx() returns

template<typename T , uint_t fSize_>
const T & walberla::field::Field< T, fSize_ >::get ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z,
uint_t  f 
) const
inline

get() variant which takes a uint_t as last coordinate, as for example Stencil::toIdx() returns

template<typename T , uint_t fSize_>
T & walberla::field::Field< T, fSize_ >::get ( const Cell &  cell)
inline

get overload using a cell as input, only possible if fSize=1

template<typename T , uint_t fSize_>
const T & walberla::field::Field< T, fSize_ >::get ( const Cell &  cell) const
inline

get overload using a cell as input, only possible if fSize=1

template<typename T , uint_t fSize_>
T& walberla::field::Field< T, fSize_ >::get ( const Cell &  c,
cell_idx_t  f 
)
inline
template<typename T , uint_t fSize_>
const T& walberla::field::Field< T, fSize_ >::get ( const Cell &  c,
cell_idx_t  f 
) const
inline
template<typename T , uint_t fSize_>
T& walberla::field::Field< T, fSize_ >::get ( const Cell &  c,
uint_t  f 
)
inline
template<typename T , uint_t fSize_>
const T& walberla::field::Field< T, fSize_ >::get ( const Cell &  c,
uint_t  f 
) const
inline
template<typename T , uint_t fSize_>
T & walberla::field::Field< T, fSize_ >::get ( const base_iterator iter)
inline

get overload, where position is specified using an iterator of another field with equal size

Do not use this for iterator that belong to this field, here *iterator is more convenient

Parameters
iterIterator that belongs to another field that has equal size
template<typename T , uint_t fSize_>
const T & walberla::field::Field< T, fSize_ >::get ( const base_iterator iter) const
inline

get overload, where position is specified using an iterator of another field with equal size

template<typename T , uint_t fSize_>
shared_ptr< FieldAllocator< T > > walberla::field::Field< T, fSize_ >::getAllocator ( ) const

Returns internal data allocator.

The allocator can for example be used to prevent free() on the field data when class is deleted. This is useful if you keep a pointer to the internal data, to make sure it remains valid ( also after possible swapDataPointers() etc. )

field->getAllocator()->incrementReferenceCount( field->data() ); Use the data pointer field->getAllocator()->decrementReferenceCount( field->data() );

template<typename T , uint_t fSize_>
T & walberla::field::Field< T, fSize_ >::getF ( T *const  xyz0,
const cell_idx_t  f 
)
inline
template<typename T , uint_t fSize_>
const T & walberla::field::Field< T, fSize_ >::getF ( const T *const  xyz0,
const cell_idx_t  f 
) const
inline
template<typename T , uint_t fSize_>
T& walberla::field::Field< T, fSize_ >::getF ( T *const  xyz0,
const uint_t  f 
)
inline
template<typename T , uint_t fSize_>
const T& walberla::field::Field< T, fSize_ >::getF ( const T *const  xyz0,
const uint_t  f 
) const
inline
template<typename T , uint_t fSize_>
T & walberla::field::Field< T, fSize_ >::getNeighbor ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z,
stencil::Direction  d 
)
inline

returns neighboring value of cell in the given direction

template<typename T , uint_t fSize_>
const T & walberla::field::Field< T, fSize_ >::getNeighbor ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z,
stencil::Direction  d 
) const
inline

returns neighboring value of cell in the given direction

template<typename T , uint_t fSize_>
T & walberla::field::Field< T, fSize_ >::getNeighbor ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z,
uint_t  f,
stencil::Direction  d 
)
inline

returns neighboring value of cell in the given direction

template<typename T , uint_t fSize_>
const T & walberla::field::Field< T, fSize_ >::getNeighbor ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z,
uint_t  f,
stencil::Direction  d 
) const
inline

returns neighboring value of cell in the given direction

template<typename T , uint_t fSize_>
T & walberla::field::Field< T, fSize_ >::getNeighbor ( const Cell &  cell,
stencil::Direction  d 
)
inline

get overload using a cell as input, only possible if fSize=1, with neighbor access

template<typename T , uint_t fSize_>
const T & walberla::field::Field< T, fSize_ >::getNeighbor ( const Cell &  cell,
stencil::Direction  d 
) const
inline

get overload using a cell as input, only possible if fSize=1, with neighbor access

template<typename T , uint_t fSize_>
Field< T, fSize_ > * walberla::field::Field< T, fSize_ >::getSlicedField ( const CellInterval &  interval) const

Create a different "view" of the field, where the created field has the size of the given sliceInterval.

The ownership of the returned pointer is transfered to the caller i.e. the caller is responsible for deleting the returned object.

The returned field uses the same data as the original field. However the returned field has a different coordinate system defined by the given slice-interval. Modifying the returned slice field modifies also the original field! The sliced field has the size as given by the slice-interval.

template<typename T , uint_t fSize_>
bool walberla::field::Field< T, fSize_ >::hasSameAllocSize ( const Field< T, fSize_ > &  other) const
inline

True if allocation sizes of all dimensions match.

template<typename T , uint_t fSize_>
bool walberla::field::Field< T, fSize_ >::hasSameSize ( const Field< T, fSize_ > &  other) const
inline

True if sizes of all dimensions match.

template<typename T , uint_t fSize_>
void walberla::field::Field< T, fSize_ >::init ( uint_t  _xSize,
uint_t  _ySize,
uint_t  _zSize,
const Layout l = zyxf,
shared_ptr< FieldAllocator< T > >  alloc = shared_ptr<FieldAllocator<T> >(),
uint_t  innerGhostLayerSizeForAlignedAlloc = 0 
)

Initializes the field with a given size, in a given layout.

Must be called exactly once! This is automatically called by all constructors that take at least one argument

Parameters
xSizesize of x dimension
ySizesize of y dimension
zSizesize of z dimension
layoutmemory layout of the field (see Field::Layout)
allocthe allocator to use. If a NULL shared pointer is given, a sensible default is selected, depending on layout
innerGhostLayerSizeForAlignedAllocThis parameter should be set to zero for field that have no ghost layers. This parameter is passed to the allocator and can there be used to ensure alignment of the first INNER cell in each line
template<typename T , uint_t fSize_>
Layout walberla::field::Field< T, fSize_ >::layout ( ) const
inline
template<typename T , uint_t fSize_>
bool walberla::field::Field< T, fSize_ >::operator!= ( const Field< T, fSize_ > &  other) const
inline

Inequality operator compares element-wise.

template<typename T , uint_t fSize_>
T& walberla::field::Field< T, fSize_ >::operator() ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z 
)
inline
template<typename T , uint_t fSize_>
const T& walberla::field::Field< T, fSize_ >::operator() ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z 
) const
inline
template<typename T , uint_t fSize_>
T& walberla::field::Field< T, fSize_ >::operator() ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z,
cell_idx_t  f 
)
inline
template<typename T , uint_t fSize_>
const T& walberla::field::Field< T, fSize_ >::operator() ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z,
cell_idx_t  f 
) const
inline
template<typename T , uint_t fSize_>
T& walberla::field::Field< T, fSize_ >::operator() ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z,
uint_t  f 
)
inline
template<typename T , uint_t fSize_>
const T& walberla::field::Field< T, fSize_ >::operator() ( cell_idx_t  x,
cell_idx_t  y,
cell_idx_t  z,
uint_t  f 
) const
inline
template<typename T , uint_t fSize_>
T& walberla::field::Field< T, fSize_ >::operator() ( const Cell &  cell)
inline
template<typename T , uint_t fSize_>
const T& walberla::field::Field< T, fSize_ >::operator() ( const Cell &  cell) const
inline
template<typename T , uint_t fSize_>
T& walberla::field::Field< T, fSize_ >::operator() ( const Cell &  cell,
cell_idx_t  f 
)
inline
template<typename T , uint_t fSize_>
const T& walberla::field::Field< T, fSize_ >::operator() ( const Cell &  cell,
cell_idx_t  f 
) const
inline
template<typename T , uint_t fSize_>
T& walberla::field::Field< T, fSize_ >::operator() ( const Cell &  cell,
uint_t  f 
)
inline
template<typename T , uint_t fSize_>
const T& walberla::field::Field< T, fSize_ >::operator() ( const Cell &  cell,
uint_t  f 
) const
inline
template<typename T , uint_t fSize_>
T& walberla::field::Field< T, fSize_ >::operator() ( const base_iterator iter)
inline
template<typename T , uint_t fSize_>
const T& walberla::field::Field< T, fSize_ >::operator() ( const base_iterator iter) const
inline
template<typename T , uint_t fSize_>
Field& walberla::field::Field< T, fSize_ >::operator= ( const Field< T, fSize_ > &  )
private
template<typename T , uint_t fSize_>
bool walberla::field::Field< T, fSize_ >::operator== ( const Field< T, fSize_ > &  other) const
inline

Equality operator compares element-wise.

template<typename T , uint_t fSize_>
Field< T, fSize_ >::reverse_iterator walberla::field::Field< T, fSize_ >::rbegin ( )
inline

Returns reverse iterator, which can iterate over complete field in a suitable order depending on layout.

template<typename T , uint_t fSize_>
Field< T, fSize_ >::const_reverse_iterator walberla::field::Field< T, fSize_ >::rbegin ( ) const
inline

Returns const_reverse_iterator, see begin()

template<typename T , uint_t fSize_>
Field< T, fSize_ >::reverse_iterator walberla::field::Field< T, fSize_ >::rbeginXYZ ( )
inline

Iterates only over XYZ coordinate, f is always 0.

template<typename T , uint_t fSize_>
Field< T, fSize_ >::const_reverse_iterator walberla::field::Field< T, fSize_ >::rbeginXYZ ( ) const
inline

Const version of beginXYZ()

template<typename T , uint_t fSize_>
uint_t walberla::field::Field< T, fSize_ >::referenceCount ( ) const
protectedvirtual

Returns the number of objects that internally use the same data.

template<typename T , uint_t fSize_>
const Field< T, fSize_ >::reverse_iterator & walberla::field::Field< T, fSize_ >::rend ( )
inline
template<typename T , uint_t fSize_>
const Field< T, fSize_ >::const_reverse_iterator & walberla::field::Field< T, fSize_ >::rend ( ) const
inline
template<typename T , uint_t fSize_>
void walberla::field::Field< T, fSize_ >::resize ( uint_t  _xSize,
uint_t  _ySize,
uint_t  _zSize 
)
virtual

Deletes all stored data, and resizes the field.

The resized field is uninitialized.

Reimplemented in walberla::field::GhostLayerField< T, fSize_ >, and walberla::field::GhostLayerField< T, 1 >.

template<typename T , uint_t fSize_>
void walberla::field::Field< T, fSize_ >::set ( const T &  value)

Sets all entries of the field to given value.

Works only in the regions specified by size(), not in the complete allocated region as specified by allocSize()

template<typename T , uint_t fSize_>
void walberla::field::Field< T, fSize_ >::set ( const std::vector< T > &  fValues)

Initializes the f coordinate to values from vector Sets the entry (x,y,z,f) to fValues[f].

Works only in the regions specified by size(), not in the complete allocated region as specified by allocSize()

template<typename T , uint_t fSize_>
void walberla::field::Field< T, fSize_ >::set ( const Field< T, fSize_ > &  other)
inline

Copies all entries of the given field to this field.

Only works when xSize(), ySize(), zSize() and allocSize() are equal Copies complete allocated region as specified by allocSize()

template<typename T , uint_t fSize_>
void walberla::field::Field< T, fSize_ >::set ( const Field< T, fSize_ > *  other)
inline
template<typename T , uint_t fSize_>
void walberla::field::Field< T, fSize_ >::setOffsets ( uint_t  xOffset,
uint_t  xs,
uint_t  yOffset,
uint_t  ys,
uint_t  zOffset,
uint_t  zs 
)
protected

Moves the coordinate system of the field.

Can be used by derived classes, to use only a subset of the field. The complete field remains accessible, but now has coordinates smaller than 0 or bigger than [xyzf]Size() This is used for example in the constructor of the GhostLayerField

Internally this is implementing by adding an offset to the values_ pointer, and by adapting the size_ members.

Parameters
xOffThe x coordinate that is afterwards mapped to zero
xsThe new size of the x coordinate. Has to be smaller than (old xSize())-xOff
template<typename T , uint_t fSize_>
void walberla::field::Field< T, fSize_ >::shiftCoordinates ( cell_idx_t  cx,
cell_idx_t  cy,
cell_idx_t  cz 
)
virtual
template<typename T , uint_t fSize_>
uint_t walberla::field::Field< T, fSize_ >::size ( uint_t  coord) const
inline
template<typename T , uint_t fSize_>
void walberla::field::Field< T, fSize_ >::slice ( const CellInterval &  interval)
virtual

Changes the coordinate system of the field.

The origin of the new coordinates is at the cell given by min() of the CellInterval. The new size of the field, is the size of the the CellInterval, however the alloc size does not change. Cells that are not in this cell interval can still be accessed ( by coordinates smaller 0, or bigger than [xyz]Size)

Reimplemented in walberla::field::GhostLayerField< T, fSize_ >, and walberla::field::GhostLayerField< T, 1 >.

template<typename T , uint_t fSize_>
void walberla::field::Field< T, fSize_ >::swapDataPointers ( Field< T, fSize_ > &  other)
inline

Swap two fields efficiently by exchanging only values_ pointer The two fields have to have identical sizes and same layout.

template<typename T , uint_t fSize_>
void walberla::field::Field< T, fSize_ >::swapDataPointers ( Field< T, fSize_ > *  other)
inline
template<typename T , uint_t fSize_>
uint_t walberla::field::Field< T, fSize_ >::xAllocSize ( ) const
inline
template<typename T , uint_t fSize_>
cell_idx_t walberla::field::Field< T, fSize_ >::xOff ( ) const
inline
template<typename T , uint_t fSize_>
uint_t walberla::field::Field< T, fSize_ >::xSize ( ) const
inline
template<typename T , uint_t fSize_>
cell_idx_t walberla::field::Field< T, fSize_ >::xStride ( ) const
inline
template<typename T , uint_t fSize_>
CellInterval walberla::field::Field< T, fSize_ >::xyzAllocSize ( ) const
inline
template<typename T , uint_t fSize_>
CellInterval walberla::field::Field< T, fSize_ >::xyzSize ( ) const
inline
template<typename T , uint_t fSize_>
uint_t walberla::field::Field< T, fSize_ >::yAllocSize ( ) const
inline
template<typename T , uint_t fSize_>
cell_idx_t walberla::field::Field< T, fSize_ >::yOff ( ) const
inline
template<typename T , uint_t fSize_>
uint_t walberla::field::Field< T, fSize_ >::ySize ( ) const
inline
template<typename T , uint_t fSize_>
cell_idx_t walberla::field::Field< T, fSize_ >::yStride ( ) const
inline
template<typename T , uint_t fSize_>
uint_t walberla::field::Field< T, fSize_ >::zAllocSize ( ) const
inline
template<typename T , uint_t fSize_>
cell_idx_t walberla::field::Field< T, fSize_ >::zOff ( ) const
inline
template<typename T , uint_t fSize_>
uint_t walberla::field::Field< T, fSize_ >::zSize ( ) const
inline
template<typename T , uint_t fSize_>
cell_idx_t walberla::field::Field< T, fSize_ >::zStride ( ) const
inline

Friends And Related Function Documentation

template<typename T , uint_t fSize_>
friend class FieldIterator< const T, fSize_ >
friend
template<typename T , uint_t fSize_>
friend class FieldIterator< T, fSize_ >
friend

Member Data Documentation

template<typename T , uint_t fSize_>
shared_ptr<FieldAllocator<T> > walberla::field::Field< T, fSize_ >::allocator_
private

Allocator for the field.

template<typename T , uint_t fSize_>
uint_t walberla::field::Field< T, fSize_ >::allocSize_
private

The overall size of the T* (padding included)

template<typename T , uint_t fSize_>
const uint_t walberla::field::Field< T, fSize_ >::F_SIZE = fSize_
static
template<typename T , uint_t fSize_>
uint_t walberla::field::Field< T, fSize_ >::fAllocSize_
private

Number of cells in f-dimension (including padded cells)

template<typename T , uint_t fSize_>
cell_idx_t walberla::field::Field< T, fSize_ >::ffact_
private

Access multiplication factor for the f-dimension.

template<typename T , uint_t fSize_>
Layout walberla::field::Field< T, fSize_ >::layout_
private

Determines in which order the values are stored.

template<typename T , uint_t fSize_>
const ForwardFieldIterator< const T, fSize_ > walberla::field::Field< T, fSize_ >::staticConstEnd = ForwardFieldIterator<const T,fSize_>()
static

Const end iterator, see end()

template<typename T , uint_t fSize_>
const ReverseFieldIterator< const T, fSize_ > walberla::field::Field< T, fSize_ >::staticConstREnd = ReverseFieldIterator<const T,fSize_>()
static

Const end iterator, see end()

template<typename T , uint_t fSize_>
const ForwardFieldIterator< T, fSize_ > walberla::field::Field< T, fSize_ >::staticEnd = ForwardFieldIterator<T,fSize_>()
static

End iterator, can be used with begin() and beginBlock()

template<typename T , uint_t fSize_>
const ReverseFieldIterator< T, fSize_ > walberla::field::Field< T, fSize_ >::staticREnd = ReverseFieldIterator<T,fSize_>()
static

End iterator, can be used with begin() and beginBlock()

template<typename T , uint_t fSize_>
T* walberla::field::Field< T, fSize_ >::values_
private

Linearized, 1-dimensional representation of the 4D data grid.

template<typename T , uint_t fSize_>
T* walberla::field::Field< T, fSize_ >::valuesWithOffset_
private

set by setOffsets(), to allow derived classes to change the offset

template<typename T , uint_t fSize_>
uint_t walberla::field::Field< T, fSize_ >::xAllocSize_
private

Number of cells in x-dimension (including padded cells)

template<typename T , uint_t fSize_>
cell_idx_t walberla::field::Field< T, fSize_ >::xfact_
private

Access multiplication factor for the x-dimension.

template<typename T , uint_t fSize_>
cell_idx_t walberla::field::Field< T, fSize_ >::xOff_
private

Offset of the xSize() to xAllocSize()

template<typename T , uint_t fSize_>
uint_t walberla::field::Field< T, fSize_ >::xSize_
private

Number of cells in x-dimension (excluding padded cells)

template<typename T , uint_t fSize_>
uint_t walberla::field::Field< T, fSize_ >::yAllocSize_
private

Number of cells in y-dimension (including padded cells)

template<typename T , uint_t fSize_>
cell_idx_t walberla::field::Field< T, fSize_ >::yfact_
private

Access multiplication factor for the y-dimension.

template<typename T , uint_t fSize_>
cell_idx_t walberla::field::Field< T, fSize_ >::yOff_
private

Offset of the ySize() to yAllocSize()

template<typename T , uint_t fSize_>
uint_t walberla::field::Field< T, fSize_ >::ySize_
private

Number of cells in y-dimension (excluding padded cells)

template<typename T , uint_t fSize_>
uint_t walberla::field::Field< T, fSize_ >::zAllocSize_
private

Number of cells in z-dimension (including padded cells)

template<typename T , uint_t fSize_>
cell_idx_t walberla::field::Field< T, fSize_ >::zfact_
private

Access multiplication factor for the z-dimension.

template<typename T , uint_t fSize_>
cell_idx_t walberla::field::Field< T, fSize_ >::zOff_
private

Offset of the zSize() to zAllocSize()

template<typename T , uint_t fSize_>
uint_t walberla::field::Field< T, fSize_ >::zSize_
private

Number of cells in z-dimension (excluding padded cells)


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