22 #ifndef bempp_grid_function_hpp
23 #define bempp_grid_function_hpp
25 #include "../common/common.hpp"
27 #include "../common/armadillo_fwd.hpp"
28 #include "../common/deprecated.hpp"
29 #include "../common/shared_ptr.hpp"
31 #include "../grid/vtk_writer.hpp"
32 #include "../fiber/quadrature_strategy.hpp"
33 #include "../fiber/scalar_traits.hpp"
35 #include <boost/mpl/set.hpp>
36 #include <boost/mpl/has_key.hpp>
37 #include <boost/utility/enable_if.hpp>
44 template <
typename ValueType>
class Basis;
45 template <
typename ResultType>
class LocalAssemblerForGridFunctions;
46 template <
typename ValueType>
class Function;
55 class AssemblyOptions;
56 class GeometryFactory;
58 template <
int codim>
class Entity;
59 template <
typename BasisFunctionType>
class Space;
60 template <
typename BasisFunctionType,
typename ResultType>
class Context;
79 template <
typename BasisFunctionType,
typename ResultType>
86 enum DataType { COEFFICIENTS, PROJECTIONS };
87 enum ConstructionMode { APPROXIMATE, INTERPOLATE };
110 const shared_ptr<
const Space<BasisFunctionType> >&
space,
129 const shared_ptr<
const Space<BasisFunctionType> >&
space,
130 const shared_ptr<
const Space<BasisFunctionType> >&
dualSpace,
165 const shared_ptr<
const Space<BasisFunctionType> >&
space,
166 const shared_ptr<
const Space<BasisFunctionType> >&
dualSpace,
167 const Function<ResultType>&
function,
168 ConstructionMode mode = APPROXIMATE);
202 const shared_ptr<
const Space<BasisFunctionType> >&
space,
203 const shared_ptr<
const Space<BasisFunctionType> >&
dualSpace,
204 const arma::Col<ResultType>& data,
227 const shared_ptr<
const Space<BasisFunctionType> >&
space,
228 const shared_ptr<
const Space<BasisFunctionType> >&
dualSpace,
250 shared_ptr<const Grid>
grid()
const;
253 shared_ptr<const Space<BasisFunctionType> >
space()
const;
261 shared_ptr<const Space<BasisFunctionType> >
dualSpace()
const;
265 shared_ptr<const Context<BasisFunctionType, ResultType> >
context()
const;
289 const shared_ptr<
const Space<BasisFunctionType> >& dualSpace_)
const;
305 const shared_ptr<
const Space<BasisFunctionType> >& dualSpace_,
306 const arma::Col<ResultType>& projects);
314 MagnitudeType
L2Norm()
const;
337 std::vector<ResultType>& coeffs)
const;
347 arma::Mat<CoordinateType>& points, arma::Mat<ResultType>& values)
const;
361 const Entity<0>& element,
362 const arma::Mat<CoordinateType>& local,
363 arma::Mat<ResultType>& values)
const;
380 const Space<BasisFunctionType>& dualSpace_)
const;
407 const Space<BasisFunctionType>& dualSpace_,
408 const arma::Col<ResultType>& projects);
448 const char* dataLabel,
449 const char* fileNamesBase,
const char* filesPath = 0,
475 const char* dataLabel,
const char* fileName)
const;
478 void initializeFromCoefficients(
479 const shared_ptr<
const Context<BasisFunctionType, ResultType> >&
context,
480 const shared_ptr<
const Space<BasisFunctionType> >&
space,
482 void initializeFromProjections(
483 const shared_ptr<
const Context<BasisFunctionType, ResultType> >&
context,
484 const shared_ptr<
const Space<BasisFunctionType> >&
space,
485 const shared_ptr<
const Space<BasisFunctionType> >&
dualSpace,
487 void updateProjectionsFromCoefficients(
488 const shared_ptr<
const Space<BasisFunctionType> >& dualSpace_)
const;
489 void updateCoefficientsFromProjections()
const;
492 shared_ptr<const Context<BasisFunctionType, ResultType> > m_context;
493 shared_ptr<const Space<BasisFunctionType> > m_space;
494 mutable shared_ptr<const Space<BasisFunctionType> > m_dualSpace;
495 mutable shared_ptr<const arma::Col<ResultType> > m_coefficients;
496 mutable shared_ptr<const arma::Col<ResultType> > m_projections;
497 bool m_wasInitializedFromCoefficients;
504 template <
typename BasisFunctionType,
typename ResultType>
505 GridFunction<BasisFunctionType, ResultType> operator+(
506 const GridFunction<BasisFunctionType, ResultType>& g);
513 template <
typename BasisFunctionType,
typename ResultType>
514 GridFunction<BasisFunctionType, ResultType> operator-(
515 const GridFunction<BasisFunctionType, ResultType>& g);
522 template <
typename BasisFunctionType,
typename ResultType>
523 GridFunction<BasisFunctionType, ResultType> operator+(
524 const GridFunction<BasisFunctionType, ResultType>& g1,
525 const GridFunction<BasisFunctionType, ResultType>& g2);
532 template <
typename BasisFunctionType,
typename ResultType>
533 GridFunction<BasisFunctionType, ResultType> operator-(
534 const GridFunction<BasisFunctionType, ResultType>& g1,
535 const GridFunction<BasisFunctionType, ResultType>& g2);
542 template <
typename BasisFunctionType,
typename ResultType,
typename ScalarType>
543 GridFunction<BasisFunctionType, ResultType> operator*(
544 const GridFunction<BasisFunctionType, ResultType>& g,
const ScalarType& scalar);
553 template <
typename BasisFunctionType,
typename ResultType,
typename ScalarType>
554 typename boost::enable_if<
555 typename boost::mpl::has_key<
556 boost::mpl::set<float, double, std::complex<float>, std::complex<double> >,
558 GridFunction<BasisFunctionType, ResultType> >::type
560 const ScalarType& scalar,
const GridFunction<BasisFunctionType, ResultType>& g);
567 template <
typename BasisFunctionType,
typename ResultType,
typename ScalarType>
568 GridFunction<BasisFunctionType, ResultType> operator/(
569 const GridFunction<BasisFunctionType, ResultType>& g1,
const ScalarType& scalar);
596 template <
typename BasisFunctionType,
typename ResultType>
597 void exportToVtk(
const GridFunction<BasisFunctionType, ResultType>& gridFunction,
599 const char* dataLabel,
600 const char* fileNamesBase,
const char* filesPath = 0,
622 template <
typename BasisFunctionType,
typename ResultType>
623 void exportToGmsh(
const GridFunction<BasisFunctionType, ResultType>& gridFunction,
624 const char* dataLabel,
const char* fileName);
Traits of scalar types.
Definition: scalar_traits.hpp:40
BEMPP_DEPRECATED arma::Col< ResultType > projections() const
Vector of scalar products of this function with the basis functions of its dual space.
Definition: grid_function.cpp:548
const arma::Col< ResultType > & coefficients() const
Vector of expansion coefficients of this function in the basis of its expansion space.
Definition: grid_function.cpp:477
void evaluateAtSpecialPoints(VtkWriter::DataType dataType, arma::Mat< ResultType > &result_) const
Evaluate function at either vertices or barycentres.
Definition: grid_function.cpp:729
OutputType
How data should be stored in a VTK file.
Definition: vtk_writer.hpp:46
bool wasInitializedFromCoefficients() const
Returns true if the GridFunction was initialized with a list of coefficients and false if it was init...
Definition: grid_function.cpp:429
#define BEMPP_DEPRECATED
Macro used to mark deprecated functions or classes.
Definition: deprecated.hpp:41
shared_ptr< const Grid > grid() const
Grid on which this function is defined.
Definition: grid_function.cpp:435
shared_ptr< const Context< BasisFunctionType, ResultType > > context() const
Assembly context used to retrieve the strategy for evaluating any necessary integrals.
Definition: grid_function.cpp:460
shared_ptr< const Space< BasisFunctionType > > dualSpace() const
Space dual to the space in which this function is expanded.
Definition: grid_function.cpp:453
int componentCount() const
Number of components of this function.
Definition: grid_function.cpp:466
GridFunction()
Constructor.
Definition: grid_function.cpp:211
const Fiber::Shapeset< BasisFunctionType > & shapeset(const Entity< 0 > &element) const
Return the shapeset associated with the given element.
Definition: grid_function.cpp:688
MagnitudeType L2Norm() const
Return the -norm of the grid function.
Definition: grid_function.cpp:657
Collection of shape functions defined on a reference element.
Definition: default_local_assembler_for_operators_on_surfaces_utilities.hpp:34
void getLocalCoefficients(const Entity< 0 > &element, std::vector< ResultType > &coeffs) const
Retrieve the expansion coefficients of this function on a single element.
Definition: grid_function.cpp:697
Function to be used as a source term.
Definition: function.hpp:39
shared_ptr< const Space< BasisFunctionType > > space() const
Space in which this function is expanded.
Definition: grid_function.cpp:446
BEMPP_DEPRECATED void exportToGmsh(const char *dataLabel, const char *fileName) const
Export this function to a Gmsh (.msh) file.
Definition: grid_function.cpp:1010
Output to the file is in ascii.
Definition: vtk_writer.hpp:48
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.
Definition: grid_function.cpp:718
void setCoefficients(const arma::Col< ResultType > &coeffs)
Reset the expansion coefficients of this function in the basis of its primal space.
Definition: grid_function.cpp:488
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.
Definition: grid_function.cpp:963
const BEMPP_DEPRECATED Fiber::Basis< BasisFunctionType > & basis(const Entity< 0 > &element) const
Return the shapeset associated with the given element.
Definition: grid_function.cpp:1216
DataType
Dataset type.
Definition: vtk_writer.hpp:58
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...
Definition: grid_function.cpp:559
bool isInitialized() const
Return whether this function has been properly initialized.
Definition: grid_function.cpp:422