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 _DERIVSTENCIL_H_ 00012 #define _DERIVSTENCIL_H_ 00013 00014 #include <iostream> 00015 #include <math.h> 00016 #include "SPACE.H" 00017 #include <stdlib.h> 00018 #include "REAL.H" 00019 #include "IntVect.H" 00020 #include "Vector.H" 00021 #include "NamespaceHeader.H" 00022 00023 ///class to encapsulate the operations to create derivs on irreg stencils 00024 /** 00025 DerivStencil is meant to be used to encapsulate the information 00026 necessary to take finite difference derivatives at a point in 00027 space. Every point in the stencil has a weight. You add them 00028 (the boxarrayindex and the weight) at the same time and you can manipulate 00029 the weights enmasse by real number operations. Stencils may not 00030 interact with each other with the same sort of arithmetic because 00031 that would bring up issues as to what to do when there is 00032 incomplete intersection between the stencils. 00033 00034 */ 00035 class DerivStencil 00036 { 00037 public: 00038 /// 00039 void define(); 00040 00041 /// 00042 /** return true if any define function been called. 00043 */ 00044 bool isDefined() const 00045 { 00046 return isdefined; 00047 } 00048 00049 /// 00050 /** 00051 default constructor; creates empty vectors 00052 */ 00053 DerivStencil(); 00054 00055 /// 00056 /** 00057 copy constructor; sets *this = a_dsin 00058 */ 00059 DerivStencil(const DerivStencil& a_dsin); 00060 00061 /// 00062 ~DerivStencil(); 00063 00064 /// 00065 /** 00066 make derivstencil empty 00067 */ 00068 void clear(); 00069 00070 /// 00071 /** 00072 return length of vectors 00073 */ 00074 int size() const; 00075 00076 /// 00077 /** 00078 get iv at ivec 00079 */ 00080 const IntVect& getIndex(int a_ivec) const; 00081 00082 /// 00083 /** 00084 get weight at ivec 00085 */ 00086 const Real& getWeight(int a_ivec) const; 00087 00088 /// 00089 /** 00090 add another set if the IntVect is not in the 00091 stencil already. \\ 00092 **Add the weight to the existing weight otherwise** 00093 */ 00094 void accumulate(const IntVect& a_iv, Real a_weight); 00095 00096 /// 00097 /** 00098 assignment operator 00099 */ 00100 const DerivStencil& operator=(const DerivStencil& a_dsin); 00101 00102 /// 00103 /** 00104 Multiply each weight by a_facin 00105 does nothing if vectors are of zero length 00106 */ 00107 const DerivStencil& operator*=(Real a_facin); 00108 00109 /// 00110 /** 00111 divide each weight by a_denom 00112 does nothing if vectors are of zero length. 00113 Be advised --- 00114 This function does no checking to see if a_denom 00115 is close to zero. 00116 */ 00117 const DerivStencil& operator/=(Real a_denom); 00118 00119 /// 00120 /** 00121 add a_facin to each weight 00122 does nothing if vectors are of zero length 00123 */ 00124 const DerivStencil& operator+=(Real a_facin); 00125 00126 /// 00127 /** 00128 subtract a_facin from each weight 00129 does nothing if vectors are of zero length 00130 */ 00131 const DerivStencil& operator-=(Real a_facin); 00132 00133 protected: 00134 /// 00135 Vector<IntVect> m_vectIV; 00136 /// 00137 Vector<Real> m_vectWgt; 00138 /// 00139 bool isdefined; 00140 }; 00141 00142 #include "NamespaceFooter.H" 00143 #endif