Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

BaseEBFaceFABI.H

Go to the documentation of this file.
00001 /* _______              __
00002   / ___/ /  ___  __ _  / /  ___
00003  / /__/ _ \/ _ \/  ' \/ _ \/ _ \
00004  \___/_//_/\___/_/_/_/_.__/\___/ 
00005 */
00006 //
00007 // This software is copyright (C) by the Lawrence Berkeley
00008 // National Laboratory.  Permission is granted to reproduce
00009 // this software for non-commercial purposes provided that
00010 // this notice is left intact.
00011 // 
00012 // It is acknowledged that the U.S. Government has rights to
00013 // this software under Contract DE-AC03-765F00098 between
00014 // the U.S.  Department of Energy and the University of
00015 // California.
00016 //
00017 // This software is provided as a professional and academic
00018 // contribution for joint exchange. Thus it is experimental,
00019 // is provided ``as is'', with no warranties of any kind
00020 // whatsoever, no support, no promise of updates, or printed
00021 // documentation. By using this software, you acknowledge
00022 // that the Lawrence Berkeley National Laboratory and
00023 // Regents of the University of California shall have no
00024 // liability with respect to the infringement of other
00025 // copyrights by any part of this software.
00026 //
00027 //  ANAG, LBNL
00028 
00029 #ifndef _BaseEBFaceFABI_H_
00030 #define _BaseEBFaceFABI_H_
00031 
00032 /*************/
00033 /*************/
00034 template <class T> inline
00035 const EBISBox& 
00036 BaseEBFaceFAB<T>::getEBISBox() const
00037 {
00038   return m_ebisBox;
00039 }
00040 /*************/
00041 /*************/
00042 template <class T>
00043 inline void 
00044 BaseEBFaceFAB<T>::copy(const Box& a_regionFrom, 
00045                        const Interval& a_dstInt, 
00046                        const Box& a_regionTo,
00047                        const BaseEBFaceFAB<T>& a_src, 
00048                        const Interval& a_srcInt)
00049 {
00050   assert(a_regionFrom == a_regionTo);
00051   assert(isDefined());
00052   assert(a_dstInt.size()==a_srcInt.size());
00053   assert(a_regionTo.cellCentered());
00054   assert(a_src.m_iDir ==m_iDir);
00055   assert(a_dstInt.begin()>=0);
00056   assert(a_srcInt.begin()>=0);
00057   assert(a_srcInt.end()< a_src.m_nComp);
00058   assert(a_dstInt.end()< m_nComp);
00059   assert(a_src.m_region.contains(a_regionTo));
00060   assert(m_region.contains(a_regionTo));
00061   Box rcell = a_regionFrom;
00062   Box RFace = surroundingNodes(rcell, m_iDir);
00063 
00064   assert(m_regionFace.contains(RFace));
00065   //this one has to be rface because basefab does not know
00066   //from cell vs edge centered
00067   m_regFAB.copy(RFace, a_dstInt, RFace, a_src.m_regFAB, a_srcInt);
00068   //this has to be cell centered because that is how
00069   //it is defined.
00070   m_irrFAB.copy(rcell, a_dstInt, rcell, a_src.m_irrFAB, a_srcInt);
00071 }
00072 /**********************/
00073 /**********************/
00074 template <class T> inline
00075 BaseEBFaceFAB<T>::BaseEBFaceFAB()
00076 {
00077   setDefaultValues();
00078 }
00079 
00080 /**********************/
00081 /**********************/
00082 template <class T> inline
00083 BaseEBFaceFAB<T>::BaseEBFaceFAB(const EBISBox& a_ebisBox, 
00084                                 const Box& a_region, 
00085                                 int a_iDir, int a_nComp)
00086 {
00087   setDefaultValues();
00088   define(a_ebisBox, a_region, a_iDir, a_nComp);
00089 }
00090 
00091 /**********************/
00092 /**********************/
00093 template <class T> inline
00094 void 
00095 BaseEBFaceFAB<T>::define(const EBISBox&  a_ebisBox, 
00096                          const Box& a_region, 
00097                          int a_iDir, int a_nComp)
00098 {
00099   clear();
00100   m_isDefined = true;
00101   assert(a_region.cellCentered());
00102   assert(!a_region.isEmpty());
00103   assert(a_nComp > 0);
00104   assert((a_iDir >= 0) && (a_iDir < SpaceDim));
00105 
00106   m_ebisBox = a_ebisBox;
00107   m_region = a_ebisBox.getRegion() & a_region;
00108   assert(!m_region.isEmpty());
00109   m_nComp = a_nComp;
00110   m_iDir = a_iDir;
00111   m_regionFace= surroundingNodes(m_region, a_iDir);
00112 
00113   m_regFAB.resize(m_regionFace, m_nComp);
00114   IntVectSet multiCells = m_ebisBox.getMultiCells(m_region);
00115   m_irrFAB.define(multiCells, m_ebisBox.getEBGraph(), m_iDir, m_nComp);
00116 }
00117 
00118 /**********************/
00119 /**********************/
00120 template <class T> inline
00121 const IntVectSet&
00122 BaseEBFaceFAB<T>::getMultiCells() const
00123 {
00124   assert(isDefined());
00125   return(m_irrFAB.getIVS());
00126 }
00127 /**********************/
00128 /**********************/
00129 template <class T> inline
00130 BaseEBFaceFAB<T>::~BaseEBFaceFAB()
00131 {
00132   clear();
00133 }
00134 
00135 /**********************/
00136 /**********************/
00137 template <class T> inline
00138 void
00139 BaseEBFaceFAB<T>::clear()
00140 {
00141   m_irrFAB.clear();
00142   m_regFAB.clear();
00143   m_isDefined = false;
00144 }
00145 
00146 /**********************/
00147 /**********************/
00148 template <class T> inline
00149 void 
00150 BaseEBFaceFAB<T>::setVal(T value)
00151 {
00152   m_irrFAB.setVal(value);
00153   m_regFAB.setVal(value);
00154 }
00155 
00156 
00157 /**********************/
00158 /**********************/
00159 template <class T> inline
00160 bool 
00161 BaseEBFaceFAB<T>::isDefined() const
00162 {
00163   return (m_isDefined);
00164 }
00165 
00166 /**********************/
00167 /**********************/
00168 template <class T> inline
00169 int
00170 BaseEBFaceFAB<T>::nComp() const 
00171 {
00172   assert(isDefined());
00173   return m_nComp;
00174 }
00175 
00176 /**********************/
00177 /**********************/
00178 template <class T> inline
00179 const BaseIFFAB<T>& 
00180 BaseEBFaceFAB<T>::getMultiValuedFAB() const
00181 {
00182   assert(isDefined());
00183   return m_irrFAB;
00184 }
00185 
00186 /**********************/
00187 /**********************/
00188 template <class T> inline
00189 BaseIFFAB<T>& 
00190 BaseEBFaceFAB<T>::getMultiValuedFAB() 
00191 {
00192   assert(isDefined());
00193   return m_irrFAB;
00194 }
00195 
00196 /**********************/
00197 /**********************/
00198 template <class T> inline
00199 const BaseFab<T>& 
00200 BaseEBFaceFAB<T>::getSingleValuedFAB() const
00201 {
00202   assert(isDefined());
00203   return m_regFAB;
00204 }
00205 
00206 /**********************/
00207 /**********************/
00208 template <class T> inline
00209 BaseFab<T>& 
00210 BaseEBFaceFAB<T>::getSingleValuedFAB() 
00211 {
00212   assert(isDefined());
00213   return m_regFAB;
00214 }
00215 
00216 /**********************/
00217 /**********************/
00218 template <class T> inline
00219 int 
00220 BaseEBFaceFAB<T>::direction() const
00221 {
00222   assert(isDefined());
00223   return m_iDir;
00224 }
00225 
00226 /**********************/
00227 /**********************/
00228 template <class T> inline
00229 const Box& 
00230 BaseEBFaceFAB<T>::getRegion() const 
00231 {
00232   assert(isDefined());
00233   return m_regionFace;
00234 }
00235 /**********************/
00236 /**********************/
00237 template <class T> inline
00238 const Box& 
00239 BaseEBFaceFAB<T>::getCellRegion() const 
00240 {
00241   assert(isDefined());
00242   return m_region;
00243 }
00244 
00245 /**********************/
00246 /**********************/
00247 template <class T> inline
00248 T&
00249 BaseEBFaceFAB<T>::operator()(const FaceIndex& a_facein, int  a_nCompLoc)
00250 {
00251   assert(isDefined());
00252   assert((a_nCompLoc >= 0)&&(a_nCompLoc < m_nComp));
00253   const IntVect& ivlo = a_facein.gridIndex(Side::Lo);
00254   const IntVect& ivhi = a_facein.gridIndex(Side::Hi);
00255   assert(m_regionFace.contains(ivhi));
00256 
00257   const IntVectSet& multiVals = getMultiCells();
00258   T* returnval;
00259   if(multiVals.contains(ivlo) || multiVals.contains(ivhi))
00260     {
00261       returnval = &m_irrFAB(a_facein, a_nCompLoc);
00262     }
00263   else
00264     {
00265       returnval = &m_regFAB(ivhi, a_nCompLoc);
00266     }
00267   return *returnval;
00268 }
00269 
00270 /**********************/
00271 /**********************/
00272 template <class T> inline
00273 const T&
00274 BaseEBFaceFAB<T>::operator() (const FaceIndex& a_facein, int  a_nCompLoc) const
00275 {
00276   assert(isDefined());
00277   assert((a_nCompLoc >= 0)&&(a_nCompLoc < m_nComp));
00278   const IntVect& ivlo = a_facein.gridIndex(Side::Lo);
00279   const IntVect& ivhi = a_facein.gridIndex(Side::Hi);
00280   assert(m_regionFace.contains(ivhi));
00281 
00282   const IntVectSet& multiVals = getMultiCells();
00283   const T* returnval;
00284   if(multiVals.contains(ivlo) || multiVals.contains(ivhi))
00285     {
00286       returnval = &m_irrFAB(a_facein, a_nCompLoc);
00287     }
00288   else
00289     {
00290       returnval = &m_regFAB(ivhi, a_nCompLoc);
00291     }
00292   return *returnval;
00293 }
00294 
00295 /**********************/
00296 /**********************/
00297 template <class T> inline
00298 void
00299 BaseEBFaceFAB<T>::setDefaultValues()
00300 {
00301   m_isDefined = false;
00302   m_nComp = -1;
00303   m_iDir = -1;
00304 }
00305 
00306 
00307 #endif
00308 

Generated on Wed Apr 16 14:31:03 2003 for EBChombo by doxygen1.2.16