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 "wallLayerCells.H"
00027 #include <OpenFOAM/DynamicList.H>
00028 #include <OpenFOAM/MeshWave.H>
00029 #include <dynamicMesh/wallNormalInfo.H>
00030 #include <OpenFOAM/OFstream.H>
00031
00032
00033
00034
00035 namespace Foam
00036 {
00037
00038 defineTypeNameAndDebug(wallLayerCells, 0);
00039
00040 }
00041
00042
00043
00044
00045 bool Foam::wallLayerCells::usesCoupledPatch(const label cellI) const
00046 {
00047 const polyBoundaryMesh& patches = mesh().boundaryMesh();
00048
00049 const cell& cFaces = mesh().cells()[cellI];
00050
00051 forAll(cFaces, cFaceI)
00052 {
00053 label faceI = cFaces[cFaceI];
00054
00055 label patchID = patches.whichPatch(faceI);
00056
00057 if ((patchID >= 0) && (patches[patchID].coupled()))
00058 {
00059 return true;
00060 }
00061 }
00062 return false;
00063 }
00064
00065
00066
00067
00068 Foam::wallLayerCells::wallLayerCells
00069 (
00070 const polyMesh& mesh,
00071 const List<word>& patchNames,
00072 const label nLayers
00073 )
00074 :
00075 edgeVertex(mesh),
00076 List<refineCell>()
00077 {
00078
00079
00080 const polyPatchList& patches = mesh.boundaryMesh();
00081
00082
00083 HashTable<label> patchNameToIndex(patches.size());
00084
00085 forAll(patches, patchI)
00086 {
00087 patchNameToIndex.insert(patches[patchI].name(), patchI);
00088 }
00089
00090
00091
00092 label nWalls = 0;
00093
00094 forAll(patchNames, patchNameI)
00095 {
00096 const word& name = patchNames[patchNameI];
00097
00098 if (patchNameToIndex.found(name))
00099 {
00100 label patchI = patchNameToIndex[name];
00101
00102 nWalls += patches[patchI].size();
00103 }
00104 }
00105
00106
00107 List<wallNormalInfo> changedFacesInfo(nWalls);
00108 labelList changedFaces(nWalls);
00109
00110
00111 label nChangedFaces = 0;
00112
00113 forAll(patchNames, patchNameI)
00114 {
00115 const word& name = patchNames[patchNameI];
00116
00117 if (patchNameToIndex.found(name))
00118 {
00119 label patchI = patchNameToIndex[name];
00120
00121 const polyPatch& pp = patches[patchI];
00122
00123 forAll(pp, patchFaceI)
00124 {
00125 label meshFaceI = pp.start() + patchFaceI;
00126
00127 changedFaces[nChangedFaces] = meshFaceI;
00128
00129
00130 const vector& norm = pp.faceNormals()[patchFaceI];
00131
00132 changedFacesInfo[nChangedFaces] = wallNormalInfo(norm);
00133
00134 nChangedFaces++;
00135 }
00136 }
00137 }
00138
00139
00140
00141
00142
00143
00144 MeshWave<wallNormalInfo> regionCalc
00145 (
00146 mesh,
00147 changedFaces,
00148 changedFacesInfo,
00149 0
00150 );
00151
00152 regionCalc.iterate(nLayers);
00153
00154
00155
00156
00157
00158
00159 const List<wallNormalInfo>& faceInfo = regionCalc.allFaceInfo();
00160
00161 if (debug)
00162 {
00163 Info<< "wallLayerCells::getRefinement : dumping selected faces to "
00164 << "selectedFaces.obj" << endl;
00165
00166 OFstream fcStream("selectedFaces.obj");
00167
00168 label vertI = 0;
00169
00170 forAll(faceInfo, faceI)
00171 {
00172 const wallNormalInfo& info = faceInfo[faceI];
00173
00174 if (info.valid())
00175 {
00176 const face& f = mesh.faces()[faceI];
00177
00178 point mid(0.0, 0.0, 0.0);
00179
00180 forAll(f, fp)
00181 {
00182 mid += mesh.points()[f[fp]];
00183 }
00184 mid /= f.size();
00185
00186 fcStream
00187 << "v " << mid.x() << ' ' << mid.y() << ' ' << mid.z()
00188 << endl;
00189 vertI++;
00190
00191 point end(mid + info.normal());
00192
00193 fcStream
00194 << "v " << end.x() << ' ' << end.y() << ' ' << end.z()
00195 << endl;
00196 vertI++;
00197
00198 fcStream << "l " << vertI << ' ' <<vertI-1 << endl;
00199 }
00200 }
00201 }
00202
00203
00204
00205
00206
00207
00208
00209
00210 DynamicList<refineCell> refineCells(3*nWalls);
00211
00212 const List<wallNormalInfo>& cellInfo = regionCalc.allCellInfo();
00213
00214 forAll(cellInfo, cellI)
00215 {
00216 const wallNormalInfo& info = cellInfo[cellI];
00217
00218 if (info.valid() && !usesCoupledPatch(cellI))
00219 {
00220 refineCells.append(refineCell(cellI, info.normal()));
00221 }
00222 }
00223
00224
00225 transfer(refineCells);
00226 }
00227
00228
00229