00001 #ifdef CH_LANG_CC 00002 /* 00003 * _______ __ 00004 * / ___/ / ___ __ _ / / ___ 00005 * / /__/ _ \/ _ \/ V \/ _ \/ _ \ 00006 * \___/_//_/\___/_/_/_/_.__/\___/ 00007 * Please refer to Copyright.txt, in Chombo's root directory. 00008 */ 00009 #endif 00010 00011 #ifndef _SCALARFUNCTION_H_ 00012 #define _SCALARFUNCTION_H_ 00013 00014 #include "REAL.H" 00015 #include "RealVect.H" 00016 #include "IntVect.H" 00017 #include "NamespaceHeader.H" 00018 00019 //! \class ScalarFunction 00020 //! This base class represents a scalar function \f$F: \mathbf{R}^D \rightarrow \mathbf{R}\f$. 00021 class ScalarFunction 00022 { 00023 public: 00024 00025 //! Base class constructor. Must be called by subclasses. 00026 //! \param a_homogeneous This flag indicates whether the scalar function 00027 //! is constant in space. 00028 //! \param a_constant This flag indicates whether the scalar function 00029 //! is constant in time. 00030 ScalarFunction(bool a_homogeneous, 00031 bool a_constant); 00032 00033 //! Destructor. 00034 virtual ~ScalarFunction(); 00035 00036 //! Override this method to evaluate this function at the given 00037 //! point in space and time. 00038 //! \param a_x A point in \f$D\f$-dimensional space. 00039 //! \param a_t The time at which the function is to be evaluated. 00040 virtual Real operator()(const RealVect& a_x, 00041 Real a_t) const = 0; 00042 00043 //! Override this method to evaluate the given partial derivative of the 00044 //! function at the given point in space and time. 00045 //! \param a_order A multi-index identifying the order(s) of the 00046 //! partial derivative of the function to be evaluated. 00047 //! \param a_x A point in \f$D\f$-dimensional space. 00048 //! \param a_t The time at which the derivative is to be evaluated. 00049 virtual Real derivative(const IntVect& a_order, 00050 const RealVect& a_x, 00051 Real a_t) const; 00052 00053 //! Override this method to return true if the derivative of the 00054 //! requested order exists and is available, false if it is not. 00055 //! This must be implemented in a way that is consistent with the 00056 //! derivative method. 00057 //! \param a_order A multi-index identifying the order(s) of the 00058 //! desired partial derivative of the function. 00059 virtual bool hasDerivative(const IntVect& a_order) const; 00060 00061 //! This evaluates the function at time 0. 00062 //! \param a_x A point in \f$D\f$-dimensional space. 00063 Real operator()(const RealVect& a_x) const 00064 { 00065 return operator()(a_x, 0.0); 00066 } 00067 00068 //! This evaluates the given partial derivative of the function at time 0. 00069 //! \param a_order A multi-index identifying the order(s) of the 00070 //! partial derivative of the function to be evaluated. 00071 //! \param a_x A point in \f$D\f$-dimensional space. 00072 Real derivative(const IntVect& a_order, 00073 const RealVect& a_x) const 00074 { 00075 return derivative(a_order, a_x, 0.0); 00076 } 00077 00078 //! Returns true if this function is homogeneous, false otherwise. 00079 bool isHomogeneous() const 00080 { 00081 return m_isHomogeneous; 00082 } 00083 00084 //! Returns true if this function is constant, false otherwise. 00085 bool isConstant() const 00086 { 00087 return m_isConstant; 00088 } 00089 00090 protected: 00091 00092 bool m_isHomogeneous, m_isConstant; 00093 00094 private: 00095 00096 // Disallowed! 00097 ScalarFunction(); 00098 ScalarFunction(const ScalarFunction&); 00099 ScalarFunction& operator=(const ScalarFunction&); 00100 }; 00101 00102 #include "NamespaceFooter.H" 00103 #endif