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 _VARCOEFSTENCIL_H_ 00012 #define _VARCOEFSTENCIL_H_ 00013 00014 #include "Vector.H" 00015 #include "VolIndex.H" 00016 #include "FaceIndex.H" 00017 #include "REAL.H" 00018 #include "NamespaceHeader.H" 00019 00020 /// VoF-centered stencil 00021 /** 00022 This stencil is a fundamental tool for building 00023 eb applications by making the ability to cache 00024 stencil information. This object consists of 00025 a vector of VoFs and a vector of weights. 00026 */ 00027 class VarCoefStencil 00028 { 00029 public: 00030 /// 00031 /** 00032 default constructor. makes empty vectors. 00033 */ 00034 VarCoefStencil(); 00035 00036 /// 00037 ~VarCoefStencil(); 00038 00039 /// 00040 void clear(); 00041 00042 /// 00043 /** 00044 add a VoF to the Stencil, with it's associated weight 00045 it is required that all VoFs are in the same EBIndexSpace 00046 If the vof is already in the 00047 stencil, add the weights. 00048 */ 00049 void 00050 add(const VolIndex& vof,const FaceIndex& coefloc, const Real& weight, int ivar); 00051 00052 /// 00053 /** 00054 number of VoFs in the Stencil 00055 */ 00056 int 00057 size() const; 00058 00059 /// 00060 /** 00061 access a VoF 00062 */ 00063 const VolIndex& 00064 vof(int i) const; 00065 00066 /// 00067 /** 00068 access a VoF 00069 */ 00070 const FaceIndex& 00071 coefLoc(int i) const; 00072 00073 00074 /// 00075 /** 00076 access a weight 00077 */ 00078 const Real& 00079 weight(int i) const; 00080 00081 /// 00082 /** 00083 access a weight 00084 */ 00085 Real& weight(int i); 00086 00087 00088 /// 00089 const int& variable(int i) const; 00090 00091 /// 00092 int& variable(int i); 00093 00094 /// 00095 /** 00096 add all faces and weights of inputs 00097 to this. If a vof is already in the 00098 stencil, add the weights. 00099 only addition is well-defined here 00100 as far as arithmatic operations are 00101 concerned. 00102 */ 00103 VarCoefStencil& 00104 operator+=(const VarCoefStencil& a_vofsten); 00105 00106 /// 00107 /** 00108 */ 00109 void operator*=(const Real& scaling); 00110 00111 /// 00112 VarCoefStencil& 00113 operator=(const VarCoefStencil& a_vofsten); 00114 00115 /// 00116 VarCoefStencil(const VarCoefStencil& a_vofstenin); 00117 00118 void setAllVariables(int a_var) 00119 { 00120 if (vofs.size() > 0) 00121 { 00122 variables = Vector<int>(vofs.size(), a_var); 00123 } 00124 } 00125 protected: 00126 00127 /// the VoFs 00128 Vector<VolIndex> vofs; 00129 00130 00131 /// the weights 00132 Vector<Real> weights; 00133 00134 Vector<int> variables; 00135 00136 /// Where the face-centered coefficients live 00137 Vector<FaceIndex> coefLocs; 00138 }; 00139 00140 00141 /** inlines */ 00142 00143 /**************/ 00144 inline int 00145 VarCoefStencil::size() const 00146 { 00147 return weights.size(); 00148 } 00149 /**************/ 00150 inline const FaceIndex& 00151 VarCoefStencil::coefLoc(int i) const 00152 { 00153 return coefLocs[i]; 00154 } 00155 /**************/ 00156 inline const VolIndex& 00157 VarCoefStencil::vof(int i) const 00158 { 00159 return vofs[i]; 00160 } 00161 /**************/ 00162 inline const Real& 00163 VarCoefStencil::weight(int i) const 00164 { 00165 return weights[i]; 00166 } 00167 00168 inline Real& 00169 VarCoefStencil::weight(int i) 00170 { 00171 return weights[i]; 00172 } 00173 00174 #ifdef CH_EXPLICIT_TEMPLATES 00175 // 00176 // Extra no-op stuff required for successful explicit template instantiation. 00177 // 00178 00179 00180 inline int linearSize( const VarCoefStencil& fs ) 00181 { 00182 CH_assert(0); 00183 return -1; 00184 } 00185 template<> inline 00186 void linearIn<VarCoefStencil>(VarCoefStencil& a_outputT, const void* const inBuf) 00187 { 00188 CH_assert(0); 00189 } 00190 template<> inline 00191 void linearOut<VarCoefStencil>(void* const a_outBuf, const VarCoefStencil& a_inputT) 00192 { 00193 CH_assert(0); 00194 } 00195 00196 00197 inline int linearSize( const bool& fs ) 00198 { 00199 CH_assert(0); 00200 return -1; 00201 } 00202 template<> inline 00203 void linearIn<bool>(bool& a_outputT, const void* const inBuf) 00204 { 00205 CH_assert(0); 00206 } 00207 template<> inline 00208 void linearOut<bool>(void* const a_outBuf, const bool& a_inputT) 00209 { 00210 CH_assert(0); 00211 } 00212 00213 00214 #endif // CH_EXPLICIT_TEMPLATES 00215 00216 00217 #include "NamespaceFooter.H" 00218 #endif