00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <winstd.H>
00024
00025 #include <FabArray.H>
00026
00027 FabArrayBase::FabArrayBase ()
00028 {}
00029
00030 FabArrayBase::FabArrayBase (const BoxArray& bxs, int nvar, int ngrow)
00031 :
00032 boxarray(bxs),
00033 distributionMap(boxarray, ParallelDescriptor::NProcsCFD()),
00034 n_grow(ngrow),
00035 n_comp(nvar)
00036 {}
00037
00038 FabArrayBase::FabArrayBase (const BoxArray& bxs,
00039 int nvar,
00040 int ngrow,
00041 const DistributionMapping& map)
00042 :
00043 boxarray(bxs),
00044 distributionMap(map),
00045 n_grow(ngrow),
00046 n_comp(nvar)
00047 {}
00048
00049 FabArrayBase::~FabArrayBase ()
00050 {}
00051
00052 Box
00053 FabArrayBase::fabbox (int K) const
00054 {
00055
00056
00057
00058 return BoxLib::grow(boxarray[K], n_grow);
00059 }
00060
00061 bool MFIter::g_debugging = false;
00062
00063 MFIter::MFIter (const FabArrayBase& fabarray)
00064 :
00065 fabArray(fabarray),
00066 currentIndex(0),
00067 m_debugging(g_debugging)
00068 {
00069
00070
00071
00072
00073 const int MyProc = ParallelDescriptor::MyProc();
00074
00075 while (fabArray.DistributionMap()[currentIndex] != MyProc)
00076 {
00077 ++currentIndex;
00078 }
00079 }
00080
00081 void
00082 MFIter::operator++ ()
00083 {
00084 const int MyProc = ParallelDescriptor::MyProc();
00085
00086
00087
00088 do
00089 {
00090 ++currentIndex;
00091 }
00092 while (fabArray.DistributionMap()[currentIndex] != MyProc);
00093 }
00094
00095 void
00096 MFIter::setDebugging (bool debugging)
00097 {
00098 g_debugging = debugging;
00099 }
00100
00101 bool
00102 MFIter::isValid ()
00103 {
00104 BL_ASSERT(currentIndex >= 0);
00105
00106 bool rc = currentIndex < fabArray.size();
00107
00108 if (m_debugging)
00109 {
00110 if (rc) return true;
00111 ParallelDescriptor::Barrier();
00112 return false;
00113 }
00114
00115 return rc;
00116 }
00117
00118 const Box&
00119 MFIter::validbox () const
00120 {
00121 return fabArray.box(currentIndex);
00122 }
00123
00124 Box
00125 MFIter::fabbox () const
00126 {
00127 return fabArray.fabbox(currentIndex);
00128 }
00129
00130 FillBoxId::FillBoxId ()
00131 :
00132 m_fillBoxId(-1),
00133 m_fabIndex(-1)
00134 {}
00135
00136 FillBoxId::FillBoxId (int newid,
00137 const Box& fillbox)
00138 :
00139 m_fillBox(fillbox),
00140 m_fillBoxId(newid),
00141 m_fabIndex(-1)
00142 {}
00143
00144
00145
00146
00147
00148 CommDataCache::CommDataCache ()
00149 :
00150 m_valid(false)
00151 {}
00152
00153 void
00154 CommDataCache::operator= (const Array<CommData>& rhs)
00155 {
00156 m_commdata = rhs;
00157 m_valid = true;
00158 }
00159
00160 bool
00161 CommDataCache::isValid () const
00162 {
00163 return m_valid;
00164 }
00165
00166 const Array<CommData>&
00167 CommDataCache::theCommData () const
00168 {
00169 return m_commdata;
00170 }
00171
00172 FabArrayId::FabArrayId (int newid)
00173 :
00174 fabArrayId(newid)
00175 {}
00176
00177 bool
00178 FabArrayId::operator== (const FabArrayId& rhs) const
00179 {
00180 return fabArrayId == rhs.fabArrayId;
00181 }