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
00027
00028
00029 #include "fvSurfaceMapper.H"
00030 #include <finiteVolume/fvMesh.H>
00031 #include <OpenFOAM/mapPolyMesh.H>
00032 #include <OpenFOAM/faceMapper.H>
00033
00034
00035
00036 void Foam::fvSurfaceMapper::calcAddressing() const
00037 {
00038 if
00039 (
00040 directAddrPtr_
00041 || interpolationAddrPtr_
00042 || weightsPtr_
00043 || insertedObjectLabelsPtr_
00044 )
00045 {
00046 FatalErrorIn("void fvSurfaceMapper::calcAddressing() const)")
00047 << "Addressing already calculated"
00048 << abort(FatalError);
00049 }
00050
00051
00052
00053 const label oldNInternal = faceMap_.nOldInternalFaces();
00054
00055
00056 if (direct())
00057 {
00058
00059 directAddrPtr_ =
00060 new labelList
00061 (
00062 labelList::subList(faceMap_.directAddressing(), size())
00063 );
00064 labelList& addr = *directAddrPtr_;
00065
00066
00067 forAll (addr, faceI)
00068 {
00069 if (addr[faceI] > oldNInternal)
00070 {
00071 addr[faceI] = 0;
00072 }
00073 }
00074 }
00075 else
00076 {
00077
00078 interpolationAddrPtr_ =
00079 new labelListList
00080 (
00081 labelListList::subList(faceMap_.addressing(), size())
00082 );
00083 labelListList& addr = *interpolationAddrPtr_;
00084
00085 weightsPtr_ =
00086 new scalarListList
00087 (
00088 scalarListList::subList(faceMap_.weights(), size())
00089 );
00090 scalarListList& w = *weightsPtr_;
00091
00092
00093 forAll (addr, faceI)
00094 {
00095 if (max(addr[faceI]) >= oldNInternal)
00096 {
00097 addr[faceI] = labelList(1, 0);
00098 w[faceI] = scalarList(1, 1.0);
00099 }
00100 }
00101 }
00102
00103
00104
00105
00106 if (insertedObjects())
00107 {
00108 const labelList& insFaces = faceMap_.insertedObjectLabels();
00109
00110 insertedObjectLabelsPtr_ = new labelList(insFaces.size());
00111 labelList& ins = *insertedObjectLabelsPtr_;
00112
00113 label nIns = 0;
00114
00115 forAll (insFaces, faceI)
00116 {
00117
00118 if (insFaces[faceI] < size())
00119 {
00120 ins[nIns] = insFaces[faceI];
00121 nIns++;
00122 }
00123 }
00124
00125 ins.setSize(nIns);
00126 }
00127 else
00128 {
00129
00130 insertedObjectLabelsPtr_ = new labelList(0);
00131 }
00132 }
00133
00134
00135 void Foam::fvSurfaceMapper::clearOut()
00136 {
00137 deleteDemandDrivenData(directAddrPtr_);
00138 deleteDemandDrivenData(interpolationAddrPtr_);
00139 deleteDemandDrivenData(weightsPtr_);
00140
00141 deleteDemandDrivenData(insertedObjectLabelsPtr_);
00142 }
00143
00144
00145
00146
00147
00148 Foam::fvSurfaceMapper::fvSurfaceMapper
00149 (
00150 const fvMesh& mesh,
00151 const faceMapper& fMapper
00152 )
00153 :
00154 mesh_(mesh),
00155 faceMap_(fMapper),
00156 directAddrPtr_(NULL),
00157 interpolationAddrPtr_(NULL),
00158 weightsPtr_(NULL),
00159 insertedObjectLabelsPtr_(NULL)
00160 {}
00161
00162
00163
00164
00165 Foam::fvSurfaceMapper::~fvSurfaceMapper()
00166 {
00167 clearOut();
00168 }
00169
00170
00171
00172
00173 const Foam::unallocLabelList& Foam::fvSurfaceMapper::directAddressing() const
00174 {
00175 if (!direct())
00176 {
00177 FatalErrorIn
00178 (
00179 "const unallocLabelList& fvSurfaceMapper::"
00180 "directAddressing() const"
00181 ) << "Requested direct addressing for an interpolative mapper."
00182 << abort(FatalError);
00183 }
00184
00185 if (!directAddrPtr_)
00186 {
00187 calcAddressing();
00188 }
00189
00190 return *directAddrPtr_;
00191 }
00192
00193
00194 const Foam::labelListList& Foam::fvSurfaceMapper::addressing() const
00195 {
00196 if (direct())
00197 {
00198 FatalErrorIn
00199 (
00200 "const labelListList& fvSurfaceMapper::addressing() const"
00201 ) << "Requested interpolative addressing for a direct mapper."
00202 << abort(FatalError);
00203 }
00204
00205 if (!interpolationAddrPtr_)
00206 {
00207 calcAddressing();
00208 }
00209
00210 return *interpolationAddrPtr_;
00211 }
00212
00213
00214 const Foam::scalarListList& Foam::fvSurfaceMapper::weights() const
00215 {
00216 if (direct())
00217 {
00218 FatalErrorIn
00219 (
00220 "const scalarListList& fvSurfaceMapper::weights() const"
00221 ) << "Requested interpolative weights for a direct mapper."
00222 << abort(FatalError);
00223 }
00224
00225 if (!weightsPtr_)
00226 {
00227 calcAddressing();
00228 }
00229
00230 return *weightsPtr_;
00231 }
00232
00233
00234 const Foam::labelList& Foam::fvSurfaceMapper::insertedObjectLabels() const
00235 {
00236 if (!insertedObjectLabelsPtr_)
00237 {
00238 calcAddressing();
00239 }
00240
00241 return *insertedObjectLabelsPtr_;
00242 }
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254