DUNE-ACFEM (2.5.1)

gridfunctionexpressionbase.hh
1 #ifndef __DUNE_ACFEM_GRIDFUNCTIONEXPRESSIONBASE_HH__
2 #define __DUNE_ACFEM_GRIDFUNCTIONEXPRESSIONBASE_HH__
3 
4 #include <dune/fem/version.hh>
5 #include <dune/fem/function/common/discretefunction.hh>
6 
7 #include "../expressions/expressionoperations.hh"
8 
9 namespace Dune
10 {
11 
12  namespace ACFem
13  {
14 
20  template<class UnOp, class Function>
21  class UnaryGridFunctionExpression;
22 
23  template<class BinOp, class LeftFunction, class RightFunction>
24  class BinaryGridFunctionExpression;
25 
29  template<class FunctionSpaceImp, class ExpressionImp,
30  template<class> class ExpressionTag = ExpressionTemplate>
32  : public Fem::Function<FunctionSpaceImp, ExpressionImp>,
33  public ExpressionTag<ExpressionImp>,
34  public Fem::HasLocalFunction
35  {
36  public:
37  typedef FunctionSpaceImp FunctionSpaceType;
38  typedef typename FunctionSpaceType::ScalarFunctionSpaceType ScalarFunctionSpaceType;
39  typedef typename FunctionSpaceType::RangeType RangeType;
40  typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
41 
46  void setName(const std::string& newName)
47  {
48  name_ = newName;
49  }
50 
56  const std::string& name() const
57  {
58  if (name_ == "") {
59  return this->expression().expressionName();
60  } else {
61  return name_;
62  }
63  }
64 
68  const std::string& expressionName() const
69  {
70  return expressionName_;
71  }
72 
73  protected:
74  // Stolen from the Fem::GridFunctionAdapter
75  template<class LocalFunction, class QuadratureType, class VectorType>
76  static void evaluateQuadratureImp(const LocalFunction& lf,
77  const QuadratureType& quadrature,
78  VectorType& values,
79  const RangeType&)
80  {
81  const unsigned int nop = quadrature.nop();
82  for (unsigned int qp = 0; qp < nop; ++qp) {
83  lf.evaluate(quadrature[qp], values[qp]);
84  }
85  }
86 
87  // Stolen from the Fem::GridFunctionAdapter
88  template<class LocalFunction, class QuadratureType, class VectorType>
89  static void evaluateQuadratureImp(const LocalFunction& lf,
90  const QuadratureType& quadrature,
91  VectorType& values,
92  const JacobianRangeType&)
93  {
94  const unsigned int nop = quadrature.nop();
95  for (unsigned int qp = 0; qp < nop; ++qp) {
96  lf.jacobian(quadrature[qp], values[qp]);
97  }
98  }
99 
100  mutable std::string expressionName_;
101  std::string name_;
102  };
103 
107  template<class FunctionSpaceImp, class ExpressionImp>
109  : public GridFunctionExpression<FunctionSpaceImp, ExpressionImp, ZeroExpression>
110  {};
111 
114  {};
115 
119  {};
120 
122 
124 
125  } // namespace ACFem
126 
127 } // namespace Dune
128 
129 #endif // __DUNE_ACFEM_GRIDFUNCTIONEXPRESSIONBASE_HH__
130 
131 
A class providing some basic functionality common to all expressions.
Definition: gridfunctionexpressionbase.hh:35
const std::string & name() const
Return a descriptive name for the function.
Definition: gridfunctionexpressionbase.hh:56
void setName(const std::string &newName)
Supply a descriptive name for the function.
Definition: gridfunctionexpressionbase.hh:46
const std::string & expressionName() const
Return a lengthy descriptive name for the underlying algebraic expression.
Definition: gridfunctionexpressionbase.hh:68
A base class for zero function expression.
Definition: gridfunctionexpressionbase.hh:110
const ExpressionType & expression() const
Return a const reference to the underlying expression.
Definition: expressionoperations.hh:42
Negation of IsPieceWiseConstant, in order to have something to branch to with std::conditional.
Definition: gridfunctionexpressionbase.hh:119
Tag type, consequences are zero Jacobian and Hessian.
Definition: gridfunctionexpressionbase.hh:114
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 1, 22:29, 2024)