pointPatchMapper.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 #include "pointPatchMapper.H"
00028 #include "pointPatch.H"
00029 #include "mapPolyMesh.H"
00030 #include "faceMapper.H"
00031 #include "demandDrivenData.H"
00032
00033
00034
00035 void Foam::pointPatchMapper::calcAddressing() const
00036 {
00037 if
00038 (
00039 directAddrPtr_
00040 || interpolationAddrPtr_
00041 || weightsPtr_
00042 )
00043 {
00044 FatalErrorIn
00045 (
00046 "void pointPatchMapper::calcAddressing() const"
00047 ) << "Addressing already calculated"
00048 << abort(FatalError);
00049 }
00050
00051 if (direct())
00052 {
00053
00054 directAddrPtr_ = new labelList(mpm_.patchPointMap()[patch_.index()]);
00055 labelList& addr = *directAddrPtr_;
00056
00057 forAll(addr, i)
00058 {
00059 if (addr[i] < 0)
00060 {
00061 addr[i] = 0;
00062 }
00063 }
00064 }
00065 else
00066 {
00067
00068
00069
00070
00071
00072
00073
00074 interpolationAddrPtr_ = new labelListList(size());
00075 labelListList& addr = *interpolationAddrPtr_;
00076
00077 weightsPtr_ = new scalarListList(addr.size());
00078 scalarListList& w = *weightsPtr_;
00079
00080 const labelList& ppm = mpm_.patchPointMap()[patch_.index()];
00081
00082 forAll(ppm, i)
00083 {
00084 if (ppm[i] >= 0)
00085 {
00086 addr[i] = labelList(1, ppm[i]);
00087 w[i] = scalarList(1, 1.0);
00088 }
00089 else
00090 {
00091
00092 addr[i] = labelList(1, 0);
00093 w[i] = scalarList(1, 1.0);
00094 }
00095 }
00096 }
00097 }
00098
00099
00100 void Foam::pointPatchMapper::clearOut()
00101 {
00102 deleteDemandDrivenData(directAddrPtr_);
00103 deleteDemandDrivenData(interpolationAddrPtr_);
00104 deleteDemandDrivenData(weightsPtr_);
00105 }
00106
00107
00108
00109
00110
00111 Foam::pointPatchMapper::pointPatchMapper
00112 (
00113 const pointPatch& patch,
00114 const pointMapper& pointMap,
00115 const mapPolyMesh& mpm
00116 )
00117 :
00118 pointPatchFieldMapper(),
00119 patch_(patch),
00120 pointMapper_(pointMap),
00121 mpm_(mpm),
00122 sizeBeforeMapping_
00123 (
00124 patch_.index() < mpm_.oldPatchNMeshPoints().size()
00125 ? mpm_.oldPatchNMeshPoints()[patch_.index()]
00126 : 0
00127 ),
00128 directAddrPtr_(NULL),
00129 interpolationAddrPtr_(NULL),
00130 weightsPtr_(NULL)
00131 {}
00132
00133
00134
00135
00136 Foam::pointPatchMapper::~pointPatchMapper()
00137 {
00138 clearOut();
00139 }
00140
00141
00142
00143
00144 const Foam::unallocLabelList& Foam::pointPatchMapper::directAddressing() const
00145 {
00146 if (!direct())
00147 {
00148 FatalErrorIn
00149 (
00150 "const unallocLabelList& pointPatchMapper::directAddressing() const"
00151 ) << "Requested direct addressing for an interpolative mapper."
00152 << abort(FatalError);
00153 }
00154
00155 if (!directAddrPtr_)
00156 {
00157 calcAddressing();
00158 }
00159
00160 return *directAddrPtr_;
00161 }
00162
00163
00164 const Foam::labelListList& Foam::pointPatchMapper::addressing() const
00165 {
00166 if (direct())
00167 {
00168 FatalErrorIn
00169 (
00170 "const labelListList& pointPatchMapper::addressing() const"
00171 ) << "Requested interpolative addressing for a direct mapper."
00172 << abort(FatalError);
00173 }
00174
00175 if (!interpolationAddrPtr_)
00176 {
00177 calcAddressing();
00178 }
00179
00180 return *interpolationAddrPtr_;
00181 }
00182
00183
00184 const Foam::scalarListList& Foam::pointPatchMapper::weights() const
00185 {
00186 if (direct())
00187 {
00188 FatalErrorIn
00189 (
00190 "const scalarListList& pointPatchMapper::weights() const"
00191 ) << "Requested interpolative weights for a direct mapper."
00192 << abort(FatalError);
00193 }
00194
00195 if (!weightsPtr_)
00196 {
00197 calcAddressing();
00198 }
00199
00200 return *weightsPtr_;
00201 }
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
Copyright © 2000-2009 OpenCFD Ltd