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