FieldStencilSimple< Functor, Expression > Struct Template Reference

There are potentially many ways to construct field stencils. More...

#include <FieldStencil.h>

List of all members.

Public Types

enum  { outputDim = Expression::dimensions }
typedef Expression::MeshTag_t MeshTag_t
typedef Functor::OutputElement_t OutputElement_t
typedef StencilEngine< Functor,
Expression
OutputEngineTag_t
typedef Field< MeshTag_t,
OutputElement_t,
OutputEngineTag_t
Type_t
typedef Engine< outputDim,
OutputElement_t,
OutputEngineTag_t
SEngine_t

Static Public Member Functions

static Type_t make (const Functor &stencil, const Expression &f)
 Create a Field with the appropriate StencilEngine from the stencil functor and the expression f.
static Type_t make (const Functor &stencil, const Expression &f, const Interval< outputDim > &domain)
 Create a Field with the appropriate StencilEngine from the stencil functor, the expression f and the specified output domain.
template<class Accumulate >
static Type_t make (const Expression &f, const std::vector< FieldOffsetList< outputDim > > &nn, const Centering< outputDim > &outputCentering, Accumulate accumulate=Accumulate())


Detailed Description

template<class Functor, class Expression>
struct FieldStencilSimple< Functor, Expression >

There are potentially many ways to construct field stencils.

FieldStencilSimple assumes that you just need to construct the output field and stick ONE stencil engine into it. Maybe this class can be generalized for fields that contain multiple stencil engines.

FieldStencil is used to wrap a user-defined field-based stencil class. The idea is to encapsulate the majority of the crazy type manipulations required to generate the output Field.

To create a stencil, users must create a class similar to the one below, which computes a central difference divergence of a vertex-centered Field and maps it to a cell-centered Field:

 template<class T2, int Dim, class TM>
 class DivVertToCell<Vector<Dim, T2>, UniformRectilinearMesh<Dim, TM> >
 {
 public:

 typedef T2   OutputElement_t;

 Centering<Dim> outputCentering() const 
 {
   return canonicalCentering<Dim>(CellType, Continuous, AllDim);
 }

 Centering<Dim> inputCentering() const 
 {
   return canonicalCentering<Dim>(VertexType, Continuous, AllDim);
 }

 // Constructors.

 // default version is required by default stencil engine constructor.

 DivVertToCell()
 {
   for (int d = 0; d < Dim; ++d)
   {
      fact_m(d) = 1.0;
   }
 }

 template<class FE>
 DivVertToCell(const FE &fieldEngine)
 {
   for (int d = 0; d < Dim; ++d)
   {
      fact_m(d) = 1 / fieldEngine.mesh().spacings()(d);
   }
 }

 // Methods.

 int lowerExtent(int d) const { return 0; }
 int upperExtent(int d) const { return 1; }

 template<class F>
 inline OutputElement_t
 operator()(const F &f, int i1) const
 {
   return OutputElement_t
     (fact_m(0)*(f.read(i1+1)(0) - f.read(i1)(0)));
 }

 // and versions for 2d and 3d

 private:
 Vector<Dim, TM> fact_m;
 };
 

There is one required typedefs: OutputElement_t. These export the type of the type resulting from applying the stencil at a point.

There are two required methods returning the input and output centering.

Then, there are two accessors: lowerExtent(int dir) and upperExtent(int dir). These return the extent of the stencil as a function of direction. As another example, a forward difference would have a lower extent of 0 and an upper extent of 1. Finally, a series of inline apply() functions, which take a Field of some sort and a set indices, must be supplied. This is what actually computes the stencil.

A Field that contains a StencilEngine that operates on a Field f, is constructed by using make() from FieldStencilSimple:

FieldStencilSimple<DivVertToCell<T, Mesh>, Field<Mesh, T, EngineTag> > make(DivVertToCell<T, Mesh>(f.fieldEngine()), f);


Member Typedef Documentation

template<class Functor , class Expression >
typedef Expression::MeshTag_t FieldStencilSimple< Functor, Expression >::MeshTag_t

template<class Functor , class Expression >
typedef Functor::OutputElement_t FieldStencilSimple< Functor, Expression >::OutputElement_t

template<class Functor , class Expression >
typedef StencilEngine<Functor, Expression> FieldStencilSimple< Functor, Expression >::OutputEngineTag_t

template<class Functor , class Expression >
typedef Field<MeshTag_t, OutputElement_t, OutputEngineTag_t> FieldStencilSimple< Functor, Expression >::Type_t

template<class Functor , class Expression >
typedef Engine<outputDim, OutputElement_t, OutputEngineTag_t> FieldStencilSimple< Functor, Expression >::SEngine_t


Member Enumeration Documentation

template<class Functor , class Expression >
anonymous enum

Enumerator:
outputDim 


Member Function Documentation

template<class Functor , class Expression >
static Type_t FieldStencilSimple< Functor, Expression >::make ( const Functor &  stencil,
const Expression f 
) [inline, static]

Create a Field with the appropriate StencilEngine from the stencil functor and the expression f.

Uses the physical domain of f as the output domain for the StencilEngine.

Referenced by sum().

template<class Functor , class Expression >
static Type_t FieldStencilSimple< Functor, Expression >::make ( const Functor &  stencil,
const Expression f,
const Interval< outputDim > &  domain 
) [inline, static]

Create a Field with the appropriate StencilEngine from the stencil functor, the expression f and the specified output domain.

The output domain is the (total) domain of the resulting field.

References Field< Mesh, T, EngineTag >::fieldEngine().

template<class Functor , class Expression >
template<class Accumulate >
static Type_t FieldStencilSimple< Functor, Expression >::make ( const Expression f,
const std::vector< FieldOffsetList< outputDim > > &  nn,
const Centering< outputDim > &  outputCentering,
Accumulate  accumulate = Accumulate() 
) [inline, static]


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

Generated on Wed Mar 16 06:20:11 2011 for FreePOOMA by  doxygen 1.5.9