[dune-fem] LocalFunctionAdapter
    Agnese, Marco 
    m.agnese13 at imperial.ac.uk
       
    Thu Jun  4 19:41:25 CEST 2015
    
    
  
Hi,
I am trying (without much success :)) to interpolate a c++ analytical function over a grid. 
So let's suppose that I have an identical function
RangeType f(const DomainType& x,const double& t,const EntityType& entity)
{
return x;
}
I have created the following class
template<typename DiscreteSpaceImp>
class LocalAnalyticalFunction
{
  public:
  typedef DiscreteSpaceImp DiscreteFunctionSpaceType;
  typedef typename DiscreteFunctionSpaceType::FunctionSpaceType FunctionSpaceType;
  typedef typename DiscreteFunctionSpaceType::GridPartType GridPartType;
  typedef typename DiscreteFunctionSpaceType::EntityType EntityType;
  typedef typename FunctionSpaceType::DomainType DomainType;
  typedef typename FunctionSpaceType::RangeType RangeType;
  typedef std::function<RangeType(const DomainType&,const double&,const EntityType&)> AnalyticalFunctionType;
  // constructor
  LocalAnalyticalFunction(const AnalyticalFunctionType& f,const double& t):
    f_(f),t_(t)
  {}
  // evaluate local function
  inline void evaluate(const DomainType& x,RangeType& val)
  {
    val=f_(entity().geometry().global(x),t_,entity());
  }
  // initialize to new entity
  inline void init(const EntityType& entity)
  { 
    entity_=&entity;
  }
  inline const EntityType& entity() const
  {
    return *entity_;
  }
  private:
  EntityType const * entity_;
  const AnalyticalFunctionType& f_;
  const double& t_;
};
Now I try to interpolate f() doing this
  typedef LocalAnalyticalFunction<DiscreteSpaceType> LocalAnalyticalFunctionType;
  LocalAnalyticalFunctionType localAnalyticalFunction(f,t);
  // create adapter
  typedef LocalFunctionAdapter<LocalAnalyticalFunctionType> AdaptedFunctionType;
  AdaptedFunctionType fAdapted("adapted function",localAnalyticalFunction,df.gridPart());
  interpolate(fAdapted,df);
where df is a discrete function defined over a LagrangeSpace.
The interpolate() function returns me the following error
no known conversion for argument 1 from ‘const Dune::Fem::QuadraturePointWrapper<Dune::Fem::CachingPointList<Dune::Fem::LeafGridPart<Dune::GeometryGrid<Dune::AlbertaGrid<2, 2>, Dune::Fem::VertexFunction<Dune::AlbertaGrid<2, 2> >, std::allocator<void> > >, 0, Dune::Fem::LagrangePointSetTraits<double, 2, 2u> > >’ to ‘const DomainType& {aka const Dune::FieldVector<double, 2>&}
therefore seems that it calls the evaluate() using a lagrange point as x which has a type different from DomainType. 
What I am doing wrong? I don't understand.  
Thank you very much for your help,
cheers,
Marco.
    
    
More information about the dune-fem
mailing list