Using the laplacian operator, , as a case-study, this example shows how to create a function template to compute the 3D laplacian on compatible field types.
- Illustrate how to use stencil operators
- Illustrate type inference from fields to operators
- There are a number of predefined operators/stencils in SpatialOps. The simplest way to obtain these is via the BasicOpTypes struct.
- Stencils can be stored and retrieved in the OperatorDatabase which provides simple storage and retrieval of operators by type.
- Using type inference, highly generic code can be written that is also very robust.
- See also
- Some natively supported field types
Inferring operator types
Using stencils with fields
template< typename FieldT >
const FieldT& src,
FieldT& dest )
dest <<= divX( gradX( src ) )
+ divY( gradY( src ) )
+ divZ( gradZ( src ) );