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