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