Chombo + EB + MF  3.2
ScalarFunction.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 #ifndef _SCALARFUNCTION_H_
12 #define _SCALARFUNCTION_H_
13 
14 #include "REAL.H"
15 #include "RealVect.H"
16 #include "IntVect.H"
17 #include "NamespaceHeader.H"
18 
19 //! \class ScalarFunction
20 //! This base class represents a scalar function \f$F: \mathbf{R}^D \rightarrow \mathbf{R}\f$.
22 {
23  public:
24 
25  //! Base class constructor. Must be called by subclasses.
26  //! \param a_homogeneous This flag indicates whether the scalar function
27  //! is constant in space.
28  //! \param a_constant This flag indicates whether the scalar function
29  //! is constant in time.
30  ScalarFunction(bool a_homogeneous,
31  bool a_constant);
32 
33  //! Destructor.
34  virtual ~ScalarFunction();
35 
36  //! Override this method to evaluate this function at the given
37  //! point in space and time.
38  //! \param a_x A point in \f$D\f$-dimensional space.
39  //! \param a_t The time at which the function is to be evaluated.
40  virtual Real operator()(const RealVect& a_x,
41  Real a_t) const = 0;
42 
43  //! Override this method to evaluate the given partial derivative of the
44  //! function at the given point in space and time.
45  //! \param a_order A multi-index identifying the order(s) of the
46  //! partial derivative of the function to be evaluated.
47  //! \param a_x A point in \f$D\f$-dimensional space.
48  //! \param a_t The time at which the derivative is to be evaluated.
49  virtual Real derivative(const IntVect& a_order,
50  const RealVect& a_x,
51  Real a_t) const;
52 
53  //! Override this method to return true if the derivative of the
54  //! requested order exists and is available, false if it is not.
55  //! This must be implemented in a way that is consistent with the
56  //! derivative method.
57  //! \param a_order A multi-index identifying the order(s) of the
58  //! desired partial derivative of the function.
59  virtual bool hasDerivative(const IntVect& a_order) const;
60 
61  //! This evaluates the function at time 0.
62  //! \param a_x A point in \f$D\f$-dimensional space.
63  Real operator()(const RealVect& a_x) const
64  {
65  return operator()(a_x, 0.0);
66  }
67 
68  //! This evaluates the given partial derivative of the function at time 0.
69  //! \param a_order A multi-index identifying the order(s) of the
70  //! partial derivative of the function to be evaluated.
71  //! \param a_x A point in \f$D\f$-dimensional space.
72  Real derivative(const IntVect& a_order,
73  const RealVect& a_x) const
74  {
75  return derivative(a_order, a_x, 0.0);
76  }
77 
78  //! Returns true if this function is homogeneous, false otherwise.
79  bool isHomogeneous() const
80  {
81  return m_isHomogeneous;
82  }
83 
84  //! Returns true if this function is constant, false otherwise.
85  bool isConstant() const
86  {
87  return m_isConstant;
88  }
89 
90  protected:
91 
93 
94  private:
95 
96  // Disallowed!
100 };
101 
102 #include "NamespaceFooter.H"
103 #endif
Real operator()(const RealVect &a_x) const
Definition: ScalarFunction.H:63
Definition: ScalarFunction.H:21
ScalarFunction & operator=(const ScalarFunction &)
Real derivative(const IntVect &a_order, const RealVect &a_x) const
Definition: ScalarFunction.H:72
bool isConstant() const
Returns true if this function is constant, false otherwise.
Definition: ScalarFunction.H:85
bool m_isHomogeneous
Definition: ScalarFunction.H:92
virtual Real derivative(const IntVect &a_order, const RealVect &a_x, Real a_t) const
bool isHomogeneous() const
Returns true if this function is homogeneous, false otherwise.
Definition: ScalarFunction.H:79
virtual bool hasDerivative(const IntVect &a_order) const
double Real
Definition: REAL.H:33
bool m_isConstant
Definition: ScalarFunction.H:92
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
virtual Real operator()(const RealVect &a_x, Real a_t) const =0
virtual ~ScalarFunction()
Destructor.