conductivity.hh 3.04 KB
Newer Older
1 2 3
#ifndef DUNE_DORIE_CONDUCTIVITY_ADAPTER_HH
#define DUNE_DORIE_CONDUCTIVITY_ADAPTER_HH

4 5
#include <dune/pdelab/common/function.hh>

6 7 8 9 10 11
namespace Dune{
  namespace Dorie{

    /*---------------------------------------------------------------------*//**
     * @brief      Converts a parametrization P that contains conductivity
     *             information into a grid function (in PDELab sense)
12 13
     * @ingroup    RichardsParam
     * 
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
     * @tparam     T     BasicTraits with information about the function domain
     * @tparam     P     Parametrization class with saturated conductivity
     *                   information
     */
    template<typename T, typename P>
    class ConductivityAdapter
      : public Dune::PDELab::GridFunctionBase<
                      Dune::PDELab::GridFunctionTraits<
                        typename T::GridView, 
                        typename T::RangeField,
                        1, 
                        typename T::Scalar 
                      >
                      ,ConductivityAdapter<T,P> 
                    >
    {
    public:
      using Traits = Dune::PDELab::GridFunctionTraits<
                          typename T::GridView,
                          typename T::RangeField,
                          1, 
                          typename T::Scalar
                        >;

    private:
      using RF     = typename T::RangeField;
      using Domain = typename T::Domain;

    public:
      /*-------------------------------------------------------------------*//**
       * @brief      Constructor for the ConductivityAdapter
       *
       * @param      gv    GridView
       * @param      p     Parametrization class
       * @see        RichardsEquationParameter
       */
50
      ConductivityAdapter(const typename Traits::GridViewType& gv,
51
                          std::shared_ptr<const P> p)
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
        : _gv(gv)
        , _p(p)
      {}

      /*-------------------------------------------------------------------*//**
       * @brief      Evaluation of the conductivity for a given entity e in an
       *             entity position x
       *
       * @param[in]  e     Entity of a grid
       * @param[in]  x     Position in local coordinates with respect the entity
       * @param      y     Saturated conductivity at position x
       */
      void evaluate ( const typename Traits::ElementType& e,
                      const typename Traits::DomainType& x,
                            typename Traits::RangeType& y) const
      {
68 69 70 71
        // bind to entity
        _p->bind(e);
        // evaluate saturated conductivity
        y = _p->conductivity_f()(1.0);
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
      }

      /*-------------------------------------------------------------------*//**
       * @brief      Function that returns a grid view valid for this grid
       *             function
       *
       * @return     Grid view
       */
      const typename Traits::GridViewType& getGridView() const
      {
        return _gv;
      }
      
    private:
      const typename Traits::GridViewType _gv;
87
      const std::shared_ptr<const P> _p;
88 89 90 91 92 93
    };

  }
}

#endif