dune-vtk  0.2
legacyvtkfunction.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 
5 #include <dune/grid/io/file/vtk/function.hh>
6 
8 
9 namespace Dune
10 {
11  namespace Vtk
12  {
14  template <class GridView>
16  : public LocalFunctionInterface<GridView>
17  {
19  using Entity = typename Interface::Entity;
20  using LocalCoordinate = typename Interface::LocalCoordinate;
21 
22  public:
24  explicit VTKLocalFunctionWrapper (std::shared_ptr<VTKFunction<GridView> const> const& fct)
25  : fct_(fct)
26  {}
27 
29  virtual void bind (Entity const& entity) override
30  {
31  entity_ = &entity;
32  }
33 
35  virtual void unbind () override
36  {
37  entity_ = nullptr;
38  }
39 
41  virtual double evaluate (int comp, LocalCoordinate const& xi) const override
42  {
43  return fct_->evaluate(comp, *entity_, xi);
44  }
45 
46  private:
47  std::shared_ptr<VTKFunction<GridView> const> fct_;
48  Entity const* entity_;
49  };
50 
51  } //end namespace Vtk
52 } // end namespace Dune
Definition: writer.hh:13
Type erasure for Legacy VTKFunction.
Definition: legacyvtkfunction.hh:17
VTKLocalFunctionWrapper(std::shared_ptr< VTKFunction< GridView > const > const &fct)
Constructor. Stores a shared pointer to the passed Dune::VTKFunction.
Definition: legacyvtkfunction.hh:24
virtual double evaluate(int comp, LocalCoordinate const &xi) const override
Evaluate the Dune::VTKFunction in LocalCoordinates on the stored Entity.
Definition: legacyvtkfunction.hh:41
virtual void bind(Entity const &entity) override
Stores a pointer to the passed entity.
Definition: legacyvtkfunction.hh:29
virtual void unbind() override
Unsets the stored entity pointer.
Definition: legacyvtkfunction.hh:35
An abstract base class for LocalFunctions that can be bound to an element and evaluated in local coor...
Definition: localfunctioninterface.hh:11
typename Entity::Geometry::LocalCoordinate LocalCoordinate
Definition: localfunctioninterface.hh:14
typename GridView::template Codim< 0 >::Entity Entity
Definition: localfunctioninterface.hh:13