FreePOOMA  2.4.1
Classes | Functions
FieldOffset.h File Reference

specifies a relative cell offset and subfield number More...

#include "Domain/Loc.h"
#include <iostream>
#include <vector>
#include "Field/Field.h"
Include dependency graph for FieldOffset.h:
This graph shows which files directly or indirectly include this file:

Classes

class  FieldOffset< Dim >
 Given a field f, a Loc loc, and a field offset (offset,num), a field value can be obtained. More...
class  FieldOffsetList< Dim >
 A set of FieldOffset's can be stored in a FieldOffsetList. More...
struct  fomin< T >
 Return the minimum value of the field locations. More...
struct  fomax< T >
 Return the maximum value of the field locations. More...

Functions

template<int Dim>
std::ostream & operator<< (std::ostream &o, const FieldOffset< Dim > &fieldOffset)
 Overload the << operator to print a FieldOffset to a stream.
template<int Dim>
bool operator== (const FieldOffset< Dim > &fieldOffset1, const FieldOffset< Dim > &fieldOffset2)
 Define equality and inequality operators for FieldOffsets/.
template<int Dim>
bool operator!= (const FieldOffset< Dim > &fieldOffset1, const FieldOffset< Dim > &fieldOffset2)
template<int Dim>
std::ostream & operator<< (std::ostream &o, const FieldOffsetList< Dim > &fieldOffsetList)
 Overload the << operator to print a FieldOffsetList to a stream.
template<class GeometryTag , class T , class Expr , int Dim>
View2< Field< GeometryTag, T,
Expr >, std::vector
< FieldOffset< Dim >
>, Centering< Dim > >::Type_t 
replicate (const Field< GeometryTag, T, Expr > &field, const std::vector< FieldOffsetList< Dim > > &vec, const Centering< Dim > &centering)
 Copy field values to the specified locations.
FieldOffsetList<Dim> Reductions

FIXME: What do we do for data-parallel statements?

Many computations using `FieldOffsetList's perform similar computations. The provided reduction functions support these computations. All take a field, a FieldOffsetList, and a Loc. The Loc specifies a cell within the given field. Together with a FieldOffsetList and a field, a field value is specified. The reduction function combines all the specified field values corresponding to `FieldOffset's in the list. The list must not be empty.

accumulate: Sequentially applies the given binary function to all field offsets in the list. sum: Adds the values indicated by the field offset list. av: Averages the values indicated by the field offset list. Note the division is computed using the element type, e.g., integral or floating point division. min: Returns the smallest of the indicated values. max: Returns the largest of the indicated values.

template<class GeometryTag , class T , class Expr , int Dim, class BinaryFunction >
accumulate (BinaryFunction binary_op, const Field< GeometryTag, T, Expr > &field, const FieldOffsetList< Dim > &lst, const Loc< Dim > &loc)
 Accumulate all the specified field locations using the supplied STL binary function.
template<class GeometryTag , class T , class Expr , int Dim>
sum (const Field< GeometryTag, T, Expr > &field, const FieldOffsetList< Dim > &lst, const Loc< Dim > &loc)
 Sum all the values at the field locations.
template<class GeometryTag , class T , class Expr , int Dim>
av (const Field< GeometryTag, T, Expr > &field, const FieldOffsetList< Dim > &lst, const Loc< Dim > &loc)
 Average all the values at the field locations.
template<class GeometryTag , class T , class Expr , int Dim>
min (const Field< GeometryTag, T, Expr > &field, const FieldOffsetList< Dim > &lst, const Loc< Dim > &loc)
template<class GeometryTag , class T , class Expr , int Dim>
max (const Field< GeometryTag, T, Expr > &field, const FieldOffsetList< Dim > &lst, const Loc< Dim > &loc)

Detailed Description

specifies a relative cell offset and subfield number

FieldOffset


Function Documentation

template<int Dim>
std::ostream& operator<< ( std::ostream &  o,
const FieldOffset< Dim > &  fieldOffset 
)

Overload the << operator to print a FieldOffset to a stream.

References FieldOffset< Dim >::cellOffset(), and FieldOffset< Dim >::subFieldNumber().

template<int Dim>
bool operator== ( const FieldOffset< Dim > &  fieldOffset1,
const FieldOffset< Dim > &  fieldOffset2 
) [inline]

Define equality and inequality operators for FieldOffsets/.

References FieldOffset< Dim >::cellOffset(), and FieldOffset< Dim >::subFieldNumber().

template<int Dim>
bool operator!= ( const FieldOffset< Dim > &  fieldOffset1,
const FieldOffset< Dim > &  fieldOffset2 
) [inline]
template<int Dim>
std::ostream& operator<< ( std::ostream &  o,
const FieldOffsetList< Dim > &  fieldOffsetList 
)

Overload the << operator to print a FieldOffsetList to a stream.

References std::endl(), and FieldOffsetList< Dim >::size().

template<class GeometryTag , class T , class Expr , int Dim, class BinaryFunction >
T accumulate ( BinaryFunction  binary_op,
const Field< GeometryTag, T, Expr > &  field,
const FieldOffsetList< Dim > &  lst,
const Loc< Dim > &  loc 
) [inline]

Accumulate all the specified field locations using the supplied STL binary function.

Then, for each FieldOffset fo in the list, result = binary_op(result, fv), where fv is the corresponding field value. FIXME: Add data-parallel code.

References CTAssert, PInsist, and FieldOffsetList< Dim >::size().

Referenced by FieldStencilSimple< Functor, Expression >::make(), max(), min(), and sum().

template<class GeometryTag , class T , class Expr , int Dim>
T sum ( const Field< GeometryTag, T, Expr > &  field,
const FieldOffsetList< Dim > &  lst,
const Loc< Dim > &  loc 
) [inline]

Sum all the values at the field locations.

References accumulate(), and CTAssert.

template<class GeometryTag , class T , class Expr , int Dim>
T av ( const Field< GeometryTag, T, Expr > &  field,
const FieldOffsetList< Dim > &  lst,
const Loc< Dim > &  loc 
) [inline]

Average all the values at the field locations.

Note the return value has the same type as the field types so integer division may be used.

References CTAssert, FieldOffsetList< Dim >::size(), and sum().

template<class GeometryTag , class T , class Expr , int Dim>
T min ( const Field< GeometryTag, T, Expr > &  field,
const FieldOffsetList< Dim > &  lst,
const Loc< Dim > &  loc 
) [inline]

References accumulate(), and CTAssert.

template<class GeometryTag , class T , class Expr , int Dim>
T max ( const Field< GeometryTag, T, Expr > &  field,
const FieldOffsetList< Dim > &  lst,
const Loc< Dim > &  loc 
) [inline]

References accumulate(), and CTAssert.

template<class GeometryTag , class T , class Expr , int Dim>
View2<Field<GeometryTag, T, Expr>, std::vector<FieldOffset<Dim> >, Centering<Dim> >::Type_t replicate ( const Field< GeometryTag, T, Expr > &  field,
const std::vector< FieldOffsetList< Dim > > &  vec,
const Centering< Dim > &  centering 
) [inline]

Copy field values to the specified locations.

The first field parameter specifies the field supplying the values to replicate. The second std::vector<FieldOffsetList> parameter specifies, for each value in the returned field, which input field value to use. The vector's length must match the number of values in each output field's cell. For example, the output field's first value is copied from the location specified by the vector's first list. The third parameter indicates the returned field's centering.

References CTAssert, PInsist, and Centering< Dim >::size().