Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "cyclicGAMGInterface.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028
00029
00030
00031 namespace Foam
00032 {
00033 defineTypeNameAndDebug(cyclicGAMGInterface, 0);
00034 addToRunTimeSelectionTable
00035 (
00036 GAMGInterface,
00037 cyclicGAMGInterface,
00038 lduInterface
00039 );
00040 }
00041
00042
00043
00044
00045 Foam::cyclicGAMGInterface::cyclicGAMGInterface
00046 (
00047 const lduInterface& fineInterface,
00048 const labelField& localRestrictAddressing,
00049 const labelField& neighbourRestrictAddressing
00050 )
00051 :
00052 GAMGInterface
00053 (
00054 fineInterface,
00055 localRestrictAddressing,
00056 neighbourRestrictAddressing
00057 ),
00058 fineCyclicInterface_(refCast<const cyclicLduInterface>(fineInterface))
00059 {
00060
00061 HashTable<SLList<label>, label, Hash<label> > neighboursTable
00062 (
00063 localRestrictAddressing.size()
00064 );
00065
00066
00067 HashTable<SLList<SLList<label> >, label, Hash<label> > faceFaceTable
00068 (
00069 localRestrictAddressing.size()
00070 );
00071
00072 label nCoarseFaces = 0;
00073
00074 label sizeBy2 = localRestrictAddressing.size()/2;
00075
00076 for (label ffi=0; ffi<sizeBy2; ffi++)
00077 {
00078 label curMaster = localRestrictAddressing[ffi];
00079 label curSlave = localRestrictAddressing[ffi + sizeBy2];
00080
00081
00082
00083
00084 if (neighboursTable.found(curMaster))
00085 {
00086
00087
00088
00089 SLList<label>& curNbrs = neighboursTable.find(curMaster)();
00090
00091 SLList<SLList<label> >& curFaceFaces =
00092 faceFaceTable.find(curMaster)();
00093
00094 bool nbrFound = false;
00095
00096 SLList<label>::iterator nbrsIter = curNbrs.begin();
00097
00098 SLList<SLList<label> >::iterator faceFacesIter =
00099 curFaceFaces.begin();
00100
00101 for
00102 (
00103 ;
00104 nbrsIter != curNbrs.end(), faceFacesIter != curFaceFaces.end();
00105 ++nbrsIter, ++faceFacesIter
00106 )
00107 {
00108 if (nbrsIter() == curSlave)
00109 {
00110 nbrFound = true;
00111 faceFacesIter().append(ffi);
00112 break;
00113 }
00114 }
00115
00116 if (!nbrFound)
00117 {
00118 curNbrs.append(curSlave);
00119 curFaceFaces.append(ffi);
00120
00121
00122 nCoarseFaces++;
00123 }
00124 }
00125 else
00126 {
00127
00128
00129 neighboursTable.insert(curMaster, SLList<label>(curSlave));
00130 faceFaceTable.insert(curMaster, SLList<SLList<label> >(ffi));
00131
00132
00133 nCoarseFaces++;
00134 }
00135 }
00136
00137
00138 faceCells_.setSize(2*nCoarseFaces, -1);
00139 faceRestrictAddressing_.setSize(localRestrictAddressing.size(), -1);
00140
00141 labelList contents = neighboursTable.toc();
00142
00143
00144 nCoarseFaces = 0;
00145
00146
00147 forAll (contents, masterI)
00148 {
00149 SLList<label>& curNbrs = neighboursTable.find(contents[masterI])();
00150
00151 SLList<SLList<label> >& curFaceFaces =
00152 faceFaceTable.find(contents[masterI])();
00153
00154 SLList<label>::iterator nbrsIter = curNbrs.begin();
00155 SLList<SLList<label> >::iterator faceFacesIter = curFaceFaces.begin();
00156
00157 for
00158 (
00159 ;
00160 nbrsIter != curNbrs.end(), faceFacesIter != curFaceFaces.end();
00161 ++nbrsIter, ++faceFacesIter
00162 )
00163 {
00164 faceCells_[nCoarseFaces] = contents[masterI];
00165
00166 for
00167 (
00168 SLList<label>::iterator facesIter = faceFacesIter().begin();
00169 facesIter != faceFacesIter().end();
00170 ++facesIter
00171 )
00172 {
00173 faceRestrictAddressing_[facesIter()] = nCoarseFaces;
00174 }
00175
00176 nCoarseFaces++;
00177 }
00178 }
00179
00180
00181 forAll (contents, masterI)
00182 {
00183 SLList<label>& curNbrs = neighboursTable.find(contents[masterI])();
00184
00185 SLList<SLList<label> >& curFaceFaces =
00186 faceFaceTable.find(contents[masterI])();
00187
00188 SLList<label>::iterator nbrsIter = curNbrs.begin();
00189 SLList<SLList<label> >::iterator faceFacesIter = curFaceFaces.begin();
00190
00191 for
00192 (
00193 ;
00194 nbrsIter != curNbrs.end(), faceFacesIter != curFaceFaces.end();
00195 ++nbrsIter, ++faceFacesIter
00196 )
00197 {
00198 faceCells_[nCoarseFaces] = nbrsIter();
00199
00200 for
00201 (
00202 SLList<label>::iterator facesIter = faceFacesIter().begin();
00203 facesIter != faceFacesIter().end();
00204 ++facesIter
00205 )
00206 {
00207 faceRestrictAddressing_[facesIter() + sizeBy2] = nCoarseFaces;
00208 }
00209
00210 nCoarseFaces++;
00211 }
00212 }
00213 }
00214
00215
00216
00217
00218 Foam::cyclicGAMGInterface::~cyclicGAMGInterface()
00219 {}
00220
00221
00222
00223
00224 Foam::tmp<Foam::labelField> Foam::cyclicGAMGInterface::transfer
00225 (
00226 const Pstream::commsTypes,
00227 const unallocLabelList& interfaceData
00228 ) const
00229 {
00230 tmp<labelField> tpnf(new labelField(size()));
00231 labelField& pnf = tpnf();
00232
00233 label sizeby2 = size()/2;
00234
00235 for (label facei=0; facei<sizeby2; facei++)
00236 {
00237 pnf[facei] = interfaceData[facei + sizeby2];
00238 pnf[facei + sizeby2] = interfaceData[facei];
00239 }
00240
00241 return tpnf;
00242 }
00243
00244
00245 Foam::tmp<Foam::labelField> Foam::cyclicGAMGInterface::internalFieldTransfer
00246 (
00247 const Pstream::commsTypes,
00248 const unallocLabelList& iF
00249 ) const
00250 {
00251 tmp<labelField> tpnf(new labelField(size()));
00252 labelField& pnf = tpnf();
00253
00254 label sizeby2 = size()/2;
00255
00256 for (label facei=0; facei<sizeby2; facei++)
00257 {
00258 pnf[facei] = iF[faceCells_[facei + sizeby2]];
00259 pnf[facei + sizeby2] = iF[faceCells_[facei]];
00260 }
00261
00262 return tpnf;
00263 }
00264
00265
00266