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 _SUMIF_H_ 00012 #define _SUMIF_H_ 00013 00014 #include "MayDay.H" 00015 #include "RealVect.H" 00016 #include "Vector.H" 00017 00018 #include "BaseIF.H" 00019 00020 #include "NamespaceHeader.H" 00021 00022 /// 00023 /** 00024 This implicit function is the sum of two (of more) implicit 00025 functions with which it is constructed. 00026 */ 00027 class SumIF: public BaseIF 00028 { 00029 public: 00030 /// 00031 /** 00032 Constructor specifying two implicit functions as inputs. 00033 */ 00034 SumIF(const BaseIF& a_impFunc1, 00035 const BaseIF& a_impFunc2, 00036 const bool& a_sign); 00037 00038 /// 00039 /** 00040 Constructor specifying any number of implicit functions as inputs. 00041 */ 00042 SumIF(const Vector<BaseIF*>& a_impFuncs); 00043 00044 /// Copy constructor 00045 SumIF(const SumIF& a_inputIF); 00046 00047 /// Destructor 00048 virtual ~SumIF(); 00049 00050 void setSign(bool a_sign); 00051 00052 /// 00053 /** 00054 Return the value of the function at a_point. 00055 */ 00056 virtual Real value(const RealVect& a_point) const; 00057 00058 virtual Real value(const IndexTM<Real,GLOBALDIM>& a_point) const; 00059 00060 virtual Real value(const IndexTM<int,GLOBALDIM> & a_partialDerivative, 00061 const IndexTM<Real,GLOBALDIM>& a_point) const; 00062 00063 virtual bool getSign() const; 00064 00065 virtual BaseIF* getImplicitFunction(int a_num); 00066 00067 virtual BaseIF* newImplicitFunction() const; 00068 00069 /// 00070 /** 00071 Pass this call onto the IFs contained in this IF class. 00072 */ 00073 virtual void boxLayoutChanged(const DisjointBoxLayout & a_newBoxLayout, 00074 const RealVect & a_dx) 00075 { 00076 for (int i = 0; i < m_numFuncs; i++) 00077 { 00078 m_impFuncs[i]->boxLayoutChanged(a_newBoxLayout,a_dx); 00079 } 00080 } 00081 00082 protected: 00083 int m_numFuncs; // number of implicit functions 00084 Vector<BaseIF*> m_impFuncs; // implicit functions 00085 bool m_sign; // if true -> sum of all IF //if false the first IF minus the second one (never happen when m_numFuncs > 2) 00086 00087 private: 00088 SumIF() 00089 { 00090 MayDay::Abort("SumIF uses strong construction"); 00091 } 00092 00093 void operator=(const SumIF& a_inputIF) 00094 { 00095 MayDay::Abort("SumIF doesn't allow assignment"); 00096 } 00097 }; 00098 00099 #include "NamespaceFooter.H" 00100 #endif