BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Related Functions | List of all members
Bempp::GridFunction< BasisFunctionType, ResultType > Class Template Reference

Function defined on a grid. More...

#include </home/wojtek/Projects/BEM/bempp-sven/bempp/lib/assembly/grid_function.hpp>

Public Types

enum  DataType { COEFFICIENTS, PROJECTIONS }
 
enum  ConstructionMode { APPROXIMATE, INTERPOLATE }
 
typedef Fiber::ScalarTraits
< ResultType >::RealType 
CoordinateType
 
typedef Fiber::ScalarTraits
< ResultType >::RealType 
MagnitudeType
 

Public Member Functions

 GridFunction ()
 Constructor. More...
 
 GridFunction (const shared_ptr< const Context< BasisFunctionType, ResultType > > &context, const shared_ptr< const Space< BasisFunctionType > > &space, const arma::Col< ResultType > &coefficients)
 
 GridFunction (const shared_ptr< const Context< BasisFunctionType, ResultType > > &context, const shared_ptr< const Space< BasisFunctionType > > &space, const shared_ptr< const Space< BasisFunctionType > > &dualSpace, const arma::Col< ResultType > &projections)
 
 GridFunction (const shared_ptr< const Context< BasisFunctionType, ResultType > > &context, const shared_ptr< const Space< BasisFunctionType > > &space, const shared_ptr< const Space< BasisFunctionType > > &dualSpace, const Function< ResultType > &function, ConstructionMode mode=APPROXIMATE)
 Constructor. More...
 
BEMPP_DEPRECATED GridFunction (const shared_ptr< const Context< BasisFunctionType, ResultType > > &context, const shared_ptr< const Space< BasisFunctionType > > &space, const shared_ptr< const Space< BasisFunctionType > > &dualSpace, const arma::Col< ResultType > &data, DataType dataType)
 Constructor. More...
 
BEMPP_DEPRECATED GridFunction (const shared_ptr< const Context< BasisFunctionType, ResultType > > &context, const shared_ptr< const Space< BasisFunctionType > > &space, const shared_ptr< const Space< BasisFunctionType > > &dualSpace, const arma::Col< ResultType > &coefficients, const arma::Col< ResultType > &projections)
 Constructor. More...
 
bool isInitialized () const
 Return whether this function has been properly initialized.
 
bool wasInitializedFromCoefficients () const
 Returns true if the GridFunction was initialized with a list of coefficients and false if it was initialized with a list of projections. More...
 
shared_ptr< const Gridgrid () const
 Grid on which this function is defined. More...
 
shared_ptr< const Space
< BasisFunctionType > > 
space () const
 Space in which this function is expanded.
 
shared_ptr< const Space
< BasisFunctionType > > 
dualSpace () const
 Space dual to the space in which this function is expanded. More...
 
shared_ptr< const Context
< BasisFunctionType,
ResultType > > 
context () const
 Assembly context used to retrieve the strategy for evaluating any necessary integrals.
 
int componentCount () const
 Number of components of this function. More...
 
const arma::Col< ResultType > & coefficients () const
 Vector of expansion coefficients of this function in the basis of its expansion space. More...
 
arma::Col< ResultType > projections (const shared_ptr< const Space< BasisFunctionType > > &dualSpace_) const
 Vector of scalar products of this function with the basis functions of dualSpace. More...
 
void setCoefficients (const arma::Col< ResultType > &coeffs)
 Reset the expansion coefficients of this function in the basis of its primal space. More...
 
void setProjections (const shared_ptr< const Space< BasisFunctionType > > &dualSpace_, const arma::Col< ResultType > &projects)
 Reinitialize the function by specifying the vector of its scalar products with the basis functions of dualSpace. More...
 
MagnitudeType L2Norm () const
 Return the $L^2$-norm of the grid function. More...
 
const Fiber::Shapeset
< BasisFunctionType > & 
shapeset (const Entity< 0 > &element) const
 Return the shapeset associated with the given element. More...
 
const BEMPP_DEPRECATED
Fiber::Basis
< BasisFunctionType > & 
basis (const Entity< 0 > &element) const
 Return the shapeset associated with the given element. More...
 
void getLocalCoefficients (const Entity< 0 > &element, std::vector< ResultType > &coeffs) const
 Retrieve the expansion coefficients of this function on a single element. More...
 
void evaluateAtSpecialPoints (VtkWriter::DataType dataType, arma::Mat< ResultType > &result_) const
 Evaluate function at either vertices or barycentres. More...
 
void evaluateAtSpecialPoints (VtkWriter::DataType dataType, arma::Mat< CoordinateType > &points, arma::Mat< ResultType > &values) const
 
void evaluate (const Entity< 0 > &element, const arma::Mat< CoordinateType > &local, arma::Mat< ResultType > &values) const
 Evaluate function at specific points lying on a given element. More...
 
BEMPP_DEPRECATED arma::Col
< ResultType > 
projections (const Space< BasisFunctionType > &dualSpace_) const
 Vector of scalar products of this function with the basis functions of dualSpace. More...
 
BEMPP_DEPRECATED arma::Col
< ResultType > 
projections () const
 Vector of scalar products of this function with the basis functions of its dual space. More...
 
BEMPP_DEPRECATED void setProjections (const Space< BasisFunctionType > &dualSpace_, const arma::Col< ResultType > &projects)
 Reinitialize the function by specifying the vector of its scalar products with the basis functions of dualSpace. More...
 
BEMPP_DEPRECATED void setProjections (const arma::Col< ResultType > &projects)
 Reset the vector of scalar products of this function with the basis functions of its dual space. More...
 
BEMPP_DEPRECATED void exportToVtk (VtkWriter::DataType dataType, const char *dataLabel, const char *fileNamesBase, const char *filesPath=0, VtkWriter::OutputType type=VtkWriter::ASCII) const
 Export this function to a VTK file. More...
 
BEMPP_DEPRECATED void exportToGmsh (const char *dataLabel, const char *fileName) const
 Export this function to a Gmsh (.msh) file. More...
 

Private Member Functions

void initializeFromCoefficients (const shared_ptr< const Context< BasisFunctionType, ResultType > > &context, const shared_ptr< const Space< BasisFunctionType > > &space, const arma::Col< ResultType > &coefficients)
 
void initializeFromProjections (const shared_ptr< const Context< BasisFunctionType, ResultType > > &context, const shared_ptr< const Space< BasisFunctionType > > &space, const shared_ptr< const Space< BasisFunctionType > > &dualSpace, const arma::Col< ResultType > &projections)
 
void updateProjectionsFromCoefficients (const shared_ptr< const Space< BasisFunctionType > > &dualSpace_) const
 
void updateCoefficientsFromProjections () const
 

Private Attributes

shared_ptr< const Context
< BasisFunctionType,
ResultType > > 
m_context
 
shared_ptr< const Space
< BasisFunctionType > > 
m_space
 
shared_ptr< const Space
< BasisFunctionType > > 
m_dualSpace
 
shared_ptr< const arma::Col
< ResultType > > 
m_coefficients
 
shared_ptr< const arma::Col
< ResultType > > 
m_projections
 
bool m_wasInitializedFromCoefficients
 

Related Functions

(Note that these are not member functions.)

template<typename BasisFunctionType , typename ResultType >
GridFunction
< BasisFunctionType,
ResultType > 
operator+ (const GridFunction< BasisFunctionType, ResultType > &g)
 Return a copy of the passed function g.
 
template<typename BasisFunctionType , typename ResultType >
GridFunction
< BasisFunctionType,
ResultType > 
operator- (const GridFunction< BasisFunctionType, ResultType > &g)
 Return the grid function representing the function g multipled by -1. More...
 
template<typename BasisFunctionType , typename ResultType >
GridFunction
< BasisFunctionType,
ResultType > 
operator+ (const GridFunction< BasisFunctionType, ResultType > &g1, const GridFunction< BasisFunctionType, ResultType > &g2)
 Return a grid function representing the sum of the operands. More...
 
template<typename BasisFunctionType , typename ResultType >
GridFunction
< BasisFunctionType,
ResultType > 
operator- (const GridFunction< BasisFunctionType, ResultType > &g1, const GridFunction< BasisFunctionType, ResultType > &g2)
 Return a grid function representing the difference of the operands. More...
 
template<typename BasisFunctionType , typename ResultType , typename ScalarType >
GridFunction
< BasisFunctionType,
ResultType > 
operator* (const GridFunction< BasisFunctionType, ResultType > &g, const ScalarType &scalar)
 Return the grid function representing the function g multiplied by scalar. More...
 
template<typename BasisFunctionType , typename ResultType , typename ScalarType >
boost::enable_if< typename
boost::mpl::has_key
< boost::mpl::set< float,
double, std::complex< float >
, std::complex< double >
>, ScalarType >, GridFunction
< BasisFunctionType,
ResultType > >::type 
operator* (const ScalarType &scalar, const GridFunction< BasisFunctionType, ResultType > &g)
 Return the grid function representing the function g multiplied by scalar. More...
 
template<typename BasisFunctionType , typename ResultType , typename ScalarType >
GridFunction
< BasisFunctionType,
ResultType > 
operator/ (const GridFunction< BasisFunctionType, ResultType > &g1, const ScalarType &scalar)
 Return the grid function representing the function g divided by scalar. More...
 
template<typename BasisFunctionType , typename ResultType >
void exportToVtk (const GridFunction< BasisFunctionType, ResultType > &gridFunction, VtkWriter::DataType dataType, const char *dataLabel, const char *fileNamesBase, const char *filesPath=0, VtkWriter::OutputType type=VtkWriter::ASCII)
 Export this function to a VTK file. More...
 
template<typename BasisFunctionType , typename ResultType >
void exportToGmsh (const GridFunction< BasisFunctionType, ResultType > &gridFunction, const char *dataLabel, const char *fileName)
 Export this function to a Gmsh (.msh) file. More...
 
template<typename BasisFunctionType , typename ResultType >
ScalarTraits
< BasisFunctionType >
::RealType 
L2NormOfDifference (const GridFunction< BasisFunctionType, ResultType > &gridFunction, const Fiber::Function< ResultType > &refFunction, const Fiber::QuadratureStrategy< BasisFunctionType, ResultType, GeometryFactory > &quadStrategy, const EvaluationOptions &options=EvaluationOptions())
 Calculate the $L^2$-norm of the difference between a GridFunction and a Function. More...
 
template<typename BasisFunctionType , typename ResultType >
void estimateL2Error (const GridFunction< BasisFunctionType, ResultType > &gridFunction, const Fiber::Function< ResultType > &refFunction, const Fiber::QuadratureStrategy< BasisFunctionType, ResultType, GeometryFactory > &quadStrategy, const EvaluationOptions &options, typename ScalarTraits< BasisFunctionType >::RealType &absError, typename ScalarTraits< BasisFunctionType >::RealType &relError)
 Calculate the absolute and relative $L^2$ errors of a solution. More...
 
template<typename BasisFunctionType , typename ResultType >
void estimateL2Error (const GridFunction< BasisFunctionType, ResultType > &gridFunction, const Fiber::Function< ResultType > &refFunction, const Fiber::QuadratureStrategy< BasisFunctionType, ResultType, GeometryFactory > &quadStrategy, typename ScalarTraits< BasisFunctionType >::RealType &absError, typename ScalarTraits< BasisFunctionType >::RealType &relError)
 Calculate the absolute and relative $L^2$ errors of a solution. More...
 

Detailed Description

template<typename BasisFunctionType, typename ResultType>
class Bempp::GridFunction< BasisFunctionType, ResultType >

Function defined on a grid.

This class represents a function defined on a grid and expanded in a particular function space.

Constructor & Destructor Documentation

template<typename BasisFunctionType , typename ResultType >
Bempp::GridFunction< BasisFunctionType, ResultType >::GridFunction ( )

Constructor.

Construct an uninitialized grid function. The only way to initialize it later is using the assignment operator.

template<typename BasisFunctionType, typename ResultType>
Bempp::GridFunction< BasisFunctionType, ResultType >::GridFunction ( const shared_ptr< const Context< BasisFunctionType, ResultType > > &  context,
const shared_ptr< const Space< BasisFunctionType > > &  space,
const arma::Col< ResultType > &  coefficients 
)

Constructor.

Parameters
[in]contextAssembly context from which a quadrature strategy can be retrieved.
[in]spaceFunction space to expand the grid function in.
[in]coefficientsVector of length space.globalDofCount() containing the expansion coefficients of the grid function in the space space.

This constructor builds a grid function from its coefficients in a function space.

template<typename BasisFunctionType, typename ResultType>
Bempp::GridFunction< BasisFunctionType, ResultType >::GridFunction ( const shared_ptr< const Context< BasisFunctionType, ResultType > > &  context,
const shared_ptr< const Space< BasisFunctionType > > &  space,
const shared_ptr< const Space< BasisFunctionType > > &  dualSpace,
const arma::Col< ResultType > &  projections 
)

Constructor.

Parameters
[in]contextAssembly context from which a quadrature strategy can be retrieved.
[in]spaceFunction space to expand the grid function in.
[in]dualSpaceFunction space dual to space.
[in]projectionsVector of length dualSpace.globalDofCount() containing the scalar products of the grid function and the basis functions of the space dualSpace.

This constructor builds a grid function expanded in the basis of the space space from the projections of this function on the basis functions of another space dualSpace. Both spaces must be defined on the same grid.

template<typename BasisFunctionType, typename ResultType>
Bempp::GridFunction< BasisFunctionType, ResultType >::GridFunction ( const shared_ptr< const Context< BasisFunctionType, ResultType > > &  context,
const shared_ptr< const Space< BasisFunctionType > > &  space,
const shared_ptr< const Space< BasisFunctionType > > &  dualSpace,
const Function< ResultType > &  function,
ConstructionMode  mode = APPROXIMATE 
)

Constructor.

Parameters
[in]contextAssembly context from which a quadrature strategy can be retrieved.
[in]spaceFunction space to expand the grid function in.
[in]dualSpaceFunction space dual to space.
[in]functionFunction object whose values on space.grid() will be used to construct the new grid function.
[in]modeDetermines the way the expansion coefficients of the function are determined. Can be set to #APPROXIMATE or #INTERPOLATE. These options are discussed below.

This constructor builds a grid function belonging to the space space and approximating the function $f$ defined by the object function.

If mode is set to #APPROXIMATE, the approximate coefficients $\{f_i\}$ of function in the basis $\{\phi_i\}$ of space are determined by solving the equation

\[ \sum_j \langle \psi_i, \phi_j \rangle f_i = \langle \psi_i, f \rangle \]

in the least-squares sense, with $\{\psi_i\}$ denoting the set of basis functions of dualSpace. The two spaces must be defined on the same grid.

Otherwise (if mode is set to #INTERPOLATE), the approximate coefficients $\{f_i\}$ are determined by evaluating function at the interpolation points of the global degrees of freedom of space (see Space::getGlobalDofInterpolationPoints() for more details).

References Bempp::GridFunction< BasisFunctionType, ResultType >::setCoefficients(), and Bempp::GridFunction< BasisFunctionType, ResultType >::setProjections().

template<typename BasisFunctionType, typename ResultType>
Bempp::GridFunction< BasisFunctionType, ResultType >::GridFunction ( const shared_ptr< const Context< BasisFunctionType, ResultType > > &  context,
const shared_ptr< const Space< BasisFunctionType > > &  space,
const shared_ptr< const Space< BasisFunctionType > > &  dualSpace,
const arma::Col< ResultType > &  data,
DataType  dataType 
)

Constructor.

Parameters
[in]contextAssembly context from which a quadrature strategy can be retrieved.
[in]spaceFunction space to expand the grid function in.
[in]dualSpaceFunction space dual to space.
[in]dataIf dataType == COEFFICIENTS, the vector data should have length space.globalDofCount() and contain the expansion coefficients of the grid function in the space space. Otherwise, if dataType == PROJECTIONS, data should have length dualSpace.globalDofCount() contain the scalar products of the grid function and the basis functions of the space dualSpace.
[in]dataTypeInterpretation of the vector passed via the argument data.

This constructor builds a grid function from either its coefficients in a function space or from its projections on the basis functions of another (dual) function space. If the other type of data turns out to be needed later (for example, the projections vector if coefficients were supplied in the constructor), it is calculated automatically. The Context object given in the constructor is then used to determine the strategy for evaluating any necessary integrals.

space and dualSpace must be defined on the same grid.

Deprecated:
This constructor is deprecated. In new code, use one of the other constructors.
template<typename BasisFunctionType, typename ResultType>
Bempp::GridFunction< BasisFunctionType, ResultType >::GridFunction ( const shared_ptr< const Context< BasisFunctionType, ResultType > > &  context,
const shared_ptr< const Space< BasisFunctionType > > &  space,
const shared_ptr< const Space< BasisFunctionType > > &  dualSpace,
const arma::Col< ResultType > &  coefficients,
const arma::Col< ResultType > &  projections 
)

Constructor.

Parameters
[in]contextAssembly context from which a quadrature strategy can be retrieved.
[in]spaceFunction space to expand the grid function in.
[in]dualSpaceFunction space dual to space.
[in]coefficientsVector of length space.globalDofCount() containing the expansion coefficients of the grid function in the space space.
[in]projectionsVector of length dualSpace.globalDofCount() containing the scalar products of the grid function and the basis functions of the space dualSpace.

space and dualSpace must be defined on the same grid.

Deprecated:
This constructor is deprecated. In new code, use one of the other constructors.

Member Function Documentation

template<typename BasisFunctionType , typename ResultType >
const Fiber::Basis< BasisFunctionType > & Bempp::GridFunction< BasisFunctionType, ResultType >::basis ( const Entity< 0 > &  element) const

Return the shapeset associated with the given element.

Deprecated:
This function is deprecated. Use shapeset() instead.
template<typename BasisFunctionType , typename ResultType >
const arma::Col< ResultType > & Bempp::GridFunction< BasisFunctionType, ResultType >::coefficients ( ) const

Vector of expansion coefficients of this function in the basis of its expansion space.

An exception is thrown if this function is called on an uninitialized GridFunction object (one constructed with the default constructor).

Referenced by Bempp::AssembledPotentialOperator< BasisFunctionType, ResultType >::apply(), Bempp::BoundaryOperator< BasisFunctionType, ResultType >::apply(), Bempp::GridFunction< BasisFunctionType, ResultType >::operator*(), Bempp::GridFunction< BasisFunctionType, ResultType >::operator+(), and Bempp::GridFunction< BasisFunctionType, ResultType >::operator-().

template<typename BasisFunctionType , typename ResultType >
int Bempp::GridFunction< BasisFunctionType, ResultType >::componentCount ( ) const

Number of components of this function.

Note
An exception is thrown if this function is called on an uninitialized GridFunction object.

Referenced by Bempp::GridFunction< BasisFunctionType, ResultType >::exportToGmsh().

template<typename BasisFunctionType , typename ResultType >
shared_ptr< const Space< BasisFunctionType > > Bempp::GridFunction< BasisFunctionType, ResultType >::dualSpace ( ) const

Space dual to the space in which this function is expanded.

Deprecated:
This function is provided only for backward compatibility reasons. It returns the shared pointer to the dual space of the GridFunction, if one was supplied during the construction of the latter, or a null pointer otherwise.

Referenced by Bempp::GridFunction< BasisFunctionType, ResultType >::operator*(), Bempp::GridFunction< BasisFunctionType, ResultType >::operator+(), and Bempp::GridFunction< BasisFunctionType, ResultType >::operator-().

template<typename BasisFunctionType , typename ResultType>
void Bempp::GridFunction< BasisFunctionType, ResultType >::evaluate ( const Entity< 0 > &  element,
const arma::Mat< CoordinateType > &  local,
arma::Mat< ResultType > &  values 
) const

Evaluate function at specific points lying on a given element.

Parameters
[in]elementAn element belonging to the grid on which function is defined.
[in]localA 2D array whose (i,j)th element is the ith coordinate of the jth point at which the grid function should be evaluated, in the local coordinate system of element.
[in]valuesA 2D array whose (i,j)th element is the ith component of function evaluated at the jth point.

References Fiber::CollectionOfShapesetTransformations< CoordinateType_ >::addDependencies(), Fiber::Shapeset< BasisFunctionType >::evaluate(), Fiber::CollectionOfShapesetTransformations< CoordinateType_ >::evaluate(), Bempp::Entity< 0 >::geometry(), Fiber::CollectionOfShapesetTransformations< CoordinateType_ >::resultDimension(), Fiber::Shapeset< BasisFunctionType >::size(), and Fiber::CollectionOfShapesetTransformations< CoordinateType_ >::transformationCount().

Referenced by Bempp::GridFunction< BasisFunctionType, ResultType >::exportToGmsh().

template<typename BasisFunctionType , typename ResultType>
void Bempp::GridFunction< BasisFunctionType, ResultType >::evaluateAtSpecialPoints ( VtkWriter::DataType  dataType,
arma::Mat< ResultType > &  result_ 
) const

Evaluate function at either vertices or barycentres.

Note
The results of calling this function on an uninitialized GridFunction object are undefined.

Referenced by Bempp::GridFunction< BasisFunctionType, ResultType >::exportToVtk().

template<typename BasisFunctionType , typename ResultType >
void Bempp::GridFunction< BasisFunctionType, ResultType >::exportToGmsh ( const char *  dataLabel,
const char *  fileName 
) const

Export this function to a Gmsh (.msh) file.

Parameters
[in]dataLabelLabel used to identify the function in the Gmsh file.
[in]fileNameName of the file to be written.
Note
An exception is thrown if this function is called on an uninitialized GridFunction object.
Currently this function treats all elements as independent from each other, so that for example each internal mesh node is output as many times as there are elements adjacent to it. This makes it possible to export GridFunctions expanded in spaces with discontinuous bases. However, it also means that a .msh file generated by exportToGmsh cannot be imported back by BEM++ and used to create a Grid object.
Deprecated:
This member function is deprecated. Use the standalone function exportToGmsh() instead.
template<typename BasisFunctionType , typename ResultType >
void Bempp::GridFunction< BasisFunctionType, ResultType >::exportToVtk ( VtkWriter::DataType  dataType,
const char *  dataLabel,
const char *  fileNamesBase,
const char *  filesPath = 0,
VtkWriter::OutputType  type = VtkWriter::ASCII 
) const

Export this function to a VTK file.

Parameters
[in]dataTypeDetermines whether data are attaches to vertices or cells.
[in]dataLabelLabel used to identify the function in the VTK file.
[in]fileNamesBaseBase name of the output files. It should not contain any directory part or filename extensions.
[in]filesPathOutput directory. Can be set to NULL, in which case the files are output in the current directory.
[in]typeOutput type (default: ASCII). See Dune reference manual for more details.
Note
An exception is thrown if this function is called on an uninitialized GridFunction object.
Deprecated:
This member function is deprecated. Use the standalone function exportToVtk() instead.
template<typename BasisFunctionType , typename ResultType>
void Bempp::GridFunction< BasisFunctionType, ResultType >::getLocalCoefficients ( const Entity< 0 > &  element,
std::vector< ResultType > &  coeffs 
) const

Retrieve the expansion coefficients of this function on a single element.

Parameters
[in]elementAn element belonging to the grid space.grid().
[out]coeffsVector of the expansion coefficients of this function corresponding to the basis functions of the primal space living on element element.
Note
The results of calling this function on an uninitialized GridFunction object are undefined.
template<typename BasisFunctionType , typename ResultType >
shared_ptr< const Grid > Bempp::GridFunction< BasisFunctionType, ResultType >::grid ( ) const
template<typename BasisFunctionType , typename ResultType >
GridFunction< BasisFunctionType, ResultType >::MagnitudeType Bempp::GridFunction< BasisFunctionType, ResultType >::L2Norm ( ) const

Return the $L^2$-norm of the grid function.

Note
For better accuracy, prefer to use L2NormOfDifference() or estimateL2Error() to calculate the norm of the difference between a grid function and a function defined by an analytical expression.

References Bempp::NO_TRANSPOSE.

template<typename BasisFunctionType, typename ResultType >
arma::Col< ResultType > Bempp::GridFunction< BasisFunctionType, ResultType >::projections ( const shared_ptr< const Space< BasisFunctionType > > &  dualSpace_) const

Vector of scalar products of this function with the basis functions of dualSpace.

dualSpace must be defined on the same grid as the space in which the GridFunction is expanded.

An exception is thrown if this function is called on an uninitialized GridFunction object (one constructed with the default constructor).

Referenced by Bempp::BoundaryOperator< BasisFunctionType, ResultType >::apply(), Bempp::GridFunction< BasisFunctionType, ResultType >::operator*(), Bempp::GridFunction< BasisFunctionType, ResultType >::operator+(), and Bempp::GridFunction< BasisFunctionType, ResultType >::operator-().

template<typename BasisFunctionType, typename ResultType >
arma::Col< ResultType > Bempp::GridFunction< BasisFunctionType, ResultType >::projections ( const Space< BasisFunctionType > &  dualSpace_) const

Vector of scalar products of this function with the basis functions of dualSpace.

dualSpace must be defined on the same grid as the space in which the GridFunction is expanded.

An exception is thrown if this function is called on an uninitialized GridFunction object (one constructed with the default constructor).

Deprecated:
This function is deprecated; use the variant taking a shared pointer to the dual space instead.
template<typename BasisFunctionType, typename ResultType >
arma::Col< ResultType > Bempp::GridFunction< BasisFunctionType, ResultType >::projections ( ) const

Vector of scalar products of this function with the basis functions of its dual space.

Deprecated:
This function is provided only for backward compatibility purposes. It works only if the dual space was specified during the construction of the GridFunction. In new code the other overload of projections() should be used.

An exception is thrown if this function is called on an uninitialized GridFunction object (one constructed with the default constructor).

template<typename BasisFunctionType , typename ResultType>
void Bempp::GridFunction< BasisFunctionType, ResultType >::setCoefficients ( const arma::Col< ResultType > &  coeffs)

Reset the expansion coefficients of this function in the basis of its primal space.

As a side effect, any internally stored vector of the projections of this grid function on the basis functions of its dual space is marked as invalid and recalculated on the next call to projections().

Referenced by Bempp::GridFunction< BasisFunctionType, ResultType >::GridFunction().

template<typename BasisFunctionType, typename ResultType>
void Bempp::GridFunction< BasisFunctionType, ResultType >::setProjections ( const shared_ptr< const Space< BasisFunctionType > > &  dualSpace_,
const arma::Col< ResultType > &  projects 
)

Reinitialize the function by specifying the vector of its scalar products with the basis functions of dualSpace.

dualSpace must be defined on the same grid as the space in which the GridFunction is expanded.

Referenced by Bempp::BoundaryOperator< BasisFunctionType, ResultType >::apply(), and Bempp::GridFunction< BasisFunctionType, ResultType >::GridFunction().

template<typename BasisFunctionType, typename ResultType>
void Bempp::GridFunction< BasisFunctionType, ResultType >::setProjections ( const Space< BasisFunctionType > &  dualSpace_,
const arma::Col< ResultType > &  projects 
)

Reinitialize the function by specifying the vector of its scalar products with the basis functions of dualSpace.

dualSpace must be defined on the same grid as the space in which the GridFunction is expanded.

Deprecated:
This function is deprecated. Use the other variant taking a shared pointer to the dual space. If you use this function, it is your responsibility to ensure that dualSpace_ is not destroyed as long as this GridFunction object is alive.
template<typename BasisFunctionType, typename ResultType>
void Bempp::GridFunction< BasisFunctionType, ResultType >::setProjections ( const arma::Col< ResultType > &  projects)

Reset the vector of scalar products of this function with the basis functions of its dual space.

Deprecated:
This function is provided only for backward compatibility purposes. It works only if the dual space was specified during the construction of the GridFunction. In new code the other overload of setProjections() should be used.
template<typename BasisFunctionType , typename ResultType >
const Fiber::Shapeset< BasisFunctionType > & Bempp::GridFunction< BasisFunctionType, ResultType >::shapeset ( const Entity< 0 > &  element) const

Return the shapeset associated with the given element.

Note
The results of calling this function on an uninitialized GridFunction object are undefined.
template<typename BasisFunctionType , typename ResultType >
bool Bempp::GridFunction< BasisFunctionType, ResultType >::wasInitializedFromCoefficients ( ) const

Returns true if the GridFunction was initialized with a list of coefficients and false if it was initialized with a list of projections.

This means that the other quantity (projections or coefficients, respectively) is a derived quantity and may therefore be less accurate.

Referenced by Bempp::GridFunction< BasisFunctionType, ResultType >::operator*(), Bempp::GridFunction< BasisFunctionType, ResultType >::operator+(), and Bempp::GridFunction< BasisFunctionType, ResultType >::operator-().

Friends And Related Function Documentation

template<typename BasisFunctionType , typename ResultType >
void estimateL2Error ( const GridFunction< BasisFunctionType, ResultType > &  gridFunction,
const Fiber::Function< ResultType > &  refFunction,
const Fiber::QuadratureStrategy< BasisFunctionType, ResultType, GeometryFactory > &  quadStrategy,
const EvaluationOptions options,
typename ScalarTraits< BasisFunctionType >::RealType &  absError,
typename ScalarTraits< BasisFunctionType >::RealType &  relError 
)
related

Calculate the absolute and relative $L^2$ errors of a solution.

This function calculates the absolute and relative $L^2$ norms of the difference between a GridFunction (typically a numerical solution of an integral equation) and a Function (typically a known analytical solution.

The quadrature strategy quadStrategy is used to evaluate any necessary integrals; the options object controls the level of parallelism. The results are returned in the output arguments absError and relError.

Note
If you use the numerical quadrature strategy, you may need to increase the quadrature order for regular integrals on single elements by at least 2 to ensure that this function produces results with sufficient accuracy.
template<typename BasisFunctionType , typename ResultType >
void estimateL2Error ( const GridFunction< BasisFunctionType, ResultType > &  gridFunction,
const Fiber::Function< ResultType > &  refFunction,
const Fiber::QuadratureStrategy< BasisFunctionType, ResultType, GeometryFactory > &  quadStrategy,
typename ScalarTraits< BasisFunctionType >::RealType &  absError,
typename ScalarTraits< BasisFunctionType >::RealType &  relError 
)
related

Calculate the absolute and relative $L^2$ errors of a solution.

This is an overloaded version, provided for convenience. It is equivalent to the six-parameter version with options set to EvaluationOptions().

template<typename BasisFunctionType , typename ResultType >
void exportToGmsh ( const GridFunction< BasisFunctionType, ResultType > &  gridFunction,
const char *  dataLabel,
const char *  fileName 
)
related

Export this function to a Gmsh (.msh) file.

Parameters
[in]dataLabelLabel used to identify the function in the Gmsh file.
[in]fileNameName of the file to be written.
Note
An exception is thrown if this function is called on an uninitialized GridFunction object.
Currently this function treats all elements as independent from each other, so that for example each internal mesh node is output as many times as there are elements adjacent to it. This makes it possible to export GridFunctions expanded in spaces with discontinuous bases. However, it also means that a .msh file generated by exportToGmsh cannot be imported back by BEM++ and used to create a Grid object.

References Bempp::GridFunction< BasisFunctionType, ResultType >::componentCount(), Bempp::GridView::entityIterator(), Bempp::GridFunction< BasisFunctionType, ResultType >::evaluate(), Bempp::Entity< 0 >::geometry(), Bempp::Geometry::local2global(), Bempp::GridFunction< BasisFunctionType, ResultType >::space(), and Bempp::Entity< 0 >::type().

template<typename BasisFunctionType , typename ResultType >
void exportToVtk ( const GridFunction< BasisFunctionType, ResultType > &  gridFunction,
VtkWriter::DataType  dataType,
const char *  dataLabel,
const char *  fileNamesBase,
const char *  filesPath = 0,
VtkWriter::OutputType  type = VtkWriter::ASCII 
)
related

Export this function to a VTK file.

Parameters
[in]dataTypeDetermines whether data are attaches to vertices or cells.
[in]dataLabelLabel used to identify the function in the VTK file.
[in]fileNamesBaseBase name of the output files. It should not contain any directory part or filename extensions.
[in]filesPathOutput directory. Can be set to NULL, in which case the files are output in the current directory.
[in]typeOutput type (default: ASCII). See Dune reference manual for more details.
Note
An exception is thrown if this function is called on an uninitialized GridFunction object.

References Bempp::GridFunction< BasisFunctionType, ResultType >::evaluateAtSpecialPoints(), Bempp::GridFunction< BasisFunctionType, ResultType >::space(), and Bempp::GridView::vtkWriter().

template<typename BasisFunctionType , typename ResultType >
ScalarTraits< BasisFunctionType >::RealType L2NormOfDifference ( const GridFunction< BasisFunctionType, ResultType > &  gridFunction,
const Fiber::Function< ResultType > &  refFunction,
const Fiber::QuadratureStrategy< BasisFunctionType, ResultType, GeometryFactory > &  quadStrategy,
const EvaluationOptions options = EvaluationOptions() 
)
related

Calculate the $L^2$-norm of the difference between a GridFunction and a Function.

This function can be used to estimate the absolute error of a numerical solution gridFunction against a known analytical solution refFunction.

The quadrature strategy quadStrategy is used to evaluate any necessary integrals; the options object controls the level of parallelism.

Note
If you use the numerical quadrature strategy, you may need to increase the quadrature order for regular integrals on single elements by at least 2 to ensure that this function produces results with sufficient accuracy.
template<typename BasisFunctionType , typename ResultType , typename ScalarType >
GridFunction< BasisFunctionType, ResultType > operator* ( const GridFunction< BasisFunctionType, ResultType > &  g,
const ScalarType &  scalar 
)
related
template<typename BasisFunctionType , typename ResultType , typename ScalarType >
boost::enable_if< typename boost::mpl::has_key< boost::mpl::set< float, double, std::complex< float >, std::complex< double > >, ScalarType >, GridFunction< BasisFunctionType, ResultType > >::type operator* ( const ScalarType &  scalar,
const GridFunction< BasisFunctionType, ResultType > &  g 
)
related

Return the grid function representing the function g multiplied by scalar.

Note
An exception is thrown if g is uninitialized.
template<typename BasisFunctionType , typename ResultType >
GridFunction< BasisFunctionType, ResultType > operator+ ( const GridFunction< BasisFunctionType, ResultType > &  g1,
const GridFunction< BasisFunctionType, ResultType > &  g2 
)
related
template<typename BasisFunctionType , typename ResultType >
GridFunction< BasisFunctionType, ResultType > operator- ( const GridFunction< BasisFunctionType, ResultType > &  g)
related

Return the grid function representing the function g multipled by -1.

Note
An exception is thrown if g is uninitialized.
template<typename BasisFunctionType , typename ResultType >
GridFunction< BasisFunctionType, ResultType > operator- ( const GridFunction< BasisFunctionType, ResultType > &  g1,
const GridFunction< BasisFunctionType, ResultType > &  g2 
)
related
template<typename BasisFunctionType , typename ResultType , typename ScalarType >
GridFunction< BasisFunctionType, ResultType > operator/ ( const GridFunction< BasisFunctionType, ResultType > &  g1,
const ScalarType &  scalar 
)
related

Return the grid function representing the function g divided by scalar.

Note
An exception is thrown if g is uninitialized.

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