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 "patchWave.H"
00027 #include <OpenFOAM/polyMesh.H>
00028 #include <meshTools/wallPoint.H>
00029 #include <OpenFOAM/MeshWave.H>
00030 #include <OpenFOAM/globalMeshData.H>
00031
00032
00033
00034 void Foam::patchWave::setChangedFaces
00035 (
00036 const labelHashSet& patchIDs,
00037 labelList& changedFaces,
00038 List<wallPoint>& faceDist
00039 ) const
00040 {
00041 const polyMesh& mesh = cellDistFuncs::mesh();
00042
00043 label nChangedFaces = 0;
00044
00045 forAll(mesh.boundaryMesh(), patchI)
00046 {
00047 if (patchIDs.found(patchI))
00048 {
00049 const polyPatch& patch = mesh.boundaryMesh()[patchI];
00050
00051 forAll(patch.faceCentres(), patchFaceI)
00052 {
00053 label meshFaceI = patch.start() + patchFaceI;
00054
00055 changedFaces[nChangedFaces] = meshFaceI;
00056
00057 faceDist[nChangedFaces] =
00058 wallPoint
00059 (
00060 patch.faceCentres()[patchFaceI],
00061 0.0
00062 );
00063
00064 nChangedFaces++;
00065 }
00066 }
00067 }
00068 }
00069
00070
00071 Foam::label Foam::patchWave::getValues(const MeshWave<wallPoint>& waveInfo)
00072 {
00073 const List<wallPoint>& cellInfo = waveInfo.allCellInfo();
00074 const List<wallPoint>& faceInfo = waveInfo.allFaceInfo();
00075
00076 label nIllegal = 0;
00077
00078
00079 distance_.setSize(cellInfo.size());
00080
00081 forAll(cellInfo, cellI)
00082 {
00083 scalar dist = cellInfo[cellI].distSqr();
00084
00085 if (cellInfo[cellI].valid())
00086 {
00087 distance_[cellI] = Foam::sqrt(dist);
00088 }
00089 else
00090 {
00091 distance_[cellI] = dist;
00092
00093 nIllegal++;
00094 }
00095 }
00096
00097
00098 forAll(patchDistance_, patchI)
00099 {
00100 const polyPatch& patch = mesh().boundaryMesh()[patchI];
00101
00102
00103 scalarField* patchDistPtr = new scalarField(patch.size());
00104
00105 patchDistance_.set(patchI, patchDistPtr);
00106
00107 scalarField& patchField = *patchDistPtr;
00108
00109 forAll(patchField, patchFaceI)
00110 {
00111 label meshFaceI = patch.start() + patchFaceI;
00112
00113 scalar dist = faceInfo[meshFaceI].distSqr();
00114
00115 if (faceInfo[meshFaceI].valid())
00116 {
00117
00118
00119 patchField[patchFaceI] = Foam::sqrt(dist) + SMALL;
00120 }
00121 else
00122 {
00123 patchField[patchFaceI] = dist;
00124
00125 nIllegal++;
00126 }
00127 }
00128 }
00129 return nIllegal;
00130 }
00131
00132
00133
00134
00135
00136 Foam::patchWave::patchWave
00137 (
00138 const polyMesh& mesh,
00139 const labelHashSet& patchIDs,
00140 const bool correctWalls
00141 )
00142 :
00143 cellDistFuncs(mesh),
00144 patchIDs_(patchIDs),
00145 correctWalls_(correctWalls),
00146 nUnset_(0),
00147 distance_(mesh.nCells()),
00148 patchDistance_(mesh.boundaryMesh().size())
00149 {
00150 patchWave::correct();
00151 }
00152
00153
00154
00155
00156 Foam::patchWave::~patchWave()
00157 {}
00158
00159
00160
00161
00162
00163
00164 void Foam::patchWave::correct()
00165 {
00166
00167
00168
00169
00170
00171 label nWalls = sumPatchSize(patchIDs_);
00172
00173 List<wallPoint> faceDist(nWalls);
00174 labelList changedFaces(nWalls);
00175
00176
00177 setChangedFaces(patchIDs_, changedFaces, faceDist);
00178
00179
00180
00181
00182
00183
00184 MeshWave<wallPoint> waveInfo
00185 (
00186 mesh(),
00187 changedFaces,
00188 faceDist,
00189 mesh().globalData().nTotalCells()
00190 );
00191
00192
00193
00194
00195
00196
00197 nUnset_ = getValues(waveInfo);
00198
00199
00200
00201
00202
00203 if (correctWalls_)
00204 {
00205 Map<label> nearestFace(2 * nWalls);
00206
00207 correctBoundaryFaceCells
00208 (
00209 patchIDs_,
00210 distance_,
00211 nearestFace
00212 );
00213
00214 correctBoundaryPointCells
00215 (
00216 patchIDs_,
00217 distance_,
00218 nearestFace
00219 );
00220 }
00221 }
00222
00223
00224