/usr/include/dune/pdelab/function/const.hh is in libdune-pdelab-dev 2.4.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=8 sw=2 sts=2:
#ifndef DUNE_PDELAB_FUNCTION_CONST_HH
#define DUNE_PDELAB_FUNCTION_CONST_HH
#include <dune/pdelab/common/function.hh>
namespace Dune {
namespace PDELab {
//! GridFunction returning a constant value everywhere
/**
* \tparam GV The type of the GridView
* \tparam RF The type of the range field
* \tparam dimRange The dimension of the Range
*/
template<typename GV, typename RF, unsigned dimR = 1>
class ConstGridFunction
: public AnalyticGridFunctionBase<
AnalyticGridFunctionTraits<GV,RF,dimR>,
ConstGridFunction<GV,RF,dimR>
>,
public InstationaryFunctionDefaults
{
public:
typedef AnalyticGridFunctionTraits<GV,RF,dimR> Traits;
typedef AnalyticGridFunctionBase<
Traits,
ConstGridFunction<GV,RF, dimR> > BaseT;
//! Contruct a Const GridFunction
/**
* \param gv The GridView to use. It is passed as a reference to
* AnalyticGridFunctionBase (look there for the requirements
* of this argument).
* \param val_ The value tu return on evaluation. This class stores a
* copy of that value.
*/
ConstGridFunction(const GV& gv,
const typename Traits::RangeType& val_ = 1)
: BaseT(gv)
, val(val_)
{}
//! evaluate the function globally
/**
* \param x Position in global coordinates where to evaluate.
* \param y The resulting value.
*/
inline void
evaluateGlobal(const typename Traits::DomainType& x,
typename Traits::RangeType& y) const
{
y = val;
}
private:
typename Traits::RangeType val;
};
//! BoundaryGridFunction returning a constant value everywhere
/**
* \tparam GV The type of the GridView
* \tparam RF The type of the range field
* \tparam dimRange The dimension of the Range
*/
template<typename GV, typename RF, unsigned dimR = 1>
class ConstBoundaryGridFunction
: public BoundaryGridFunctionBase<
BoundaryGridFunctionTraits<
GV,
RF,dimR,FieldVector<RF,dimR> >,
ConstBoundaryGridFunction<GV, RF, dimR> >
{
public:
//! export Traits class
typedef BoundaryGridFunctionTraits<
GV,
RF,dimR,FieldVector<RF,dimR> > Traits;
private:
typedef BoundaryGridFunctionBase<
Traits,
ConstBoundaryGridFunction<GV,RF,dimR> > BaseT;
public:
//! Contruct a ConstBoundaryGridFunction
/**
* \param gv_ The GridView to use. This class stores a copy of it.
* \param val_ The value tu return on evaluation. This class stores a
* copy of that value.
*/
ConstBoundaryGridFunction(const GV& gv_,
const typename Traits::RangeType& val_ = 1)
: gv(gv_)
, val(val_)
{}
//! evaluate the function
/**
* \tparam I Type of intersection
*
* \param ig IntersectionGeometry of this boundary intersection.
* \param x Position in local coordinates where to evaluate.
* \param y The resulting value.
*/
template<typename I>
inline void
evaluate(const IntersectionGeometry<I>& ig,
const typename Traits::DomainType& x,
typename Traits::RangeType& y) const
{
y = val;
}
//! get a reference to the GridView
inline const GV& getGridView () const
{
return gv;
}
private:
const GV gv;
const typename Traits::RangeType val;
};
} // namspace PDELab
} // namspace Dune
#endif // DUNE_PDELAB_FUNCTION_CONST_HH
|