48 Foam::directions::directionTypeNames_;
55 void Foam::directions::writeOBJ(
Ostream& os,
const point& pt)
57 os <<
"v " << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
72 os <<
"l " << vertI + 1 <<
' ' << vertI + 2 <<
endl;
81 const fileName& fName,
82 const primitiveMesh&
mesh,
86 Pout<<
"Writing cell info to " << fName <<
" as vectors at the cellCentres"
89 OFstream xDirStream(fName);
95 const point& ctr = mesh.cellCentres()[cellI];
98 scalar minDist = GREAT;
100 const labelList& nbrs = mesh.cellCells()[cellI];
104 minDist =
min(minDist,
mag(mesh.cellCentres()[nbrs[nbrI]] - ctr));
107 scalar scale = 0.5*minDist;
109 writeOBJ(xDirStream, ctr, ctr + scale*dirs[cellI], vertI);
114 void Foam::directions::check2D
116 const twoDPointCorrector* correct2DPtr,
122 if (
mag(correct2DPtr->planeNormal() & vec) > 1
E-6)
125 <<
"is not normal to plane defined in dynamicMeshDict."
127 <<
"Either make case 3D or adjust vector."
137 const polyMesh& mesh,
146 List<directionInfo> changedFacesInfo(pp.size());
152 label meshFaceI = pp.start() + patchFaceI;
154 label cellI = mesh.faceOwner()[meshFaceI];
156 if (!hexMatcher().
isA(mesh, cellI))
159 <<
"useHexTopology specified but cell " << cellI
160 <<
" on face " << patchFaceI <<
" of patch " << pp.name()
164 const vector& cutDir = ppField[patchFaceI];
180 changedFaces[patchFaceI] = meshFaceI;
181 changedFacesInfo[patchFaceI] =
193 changedFaces[patchFaceI] = pp.start() + patchFaceI;
194 changedFacesInfo[patchFaceI] =
203 MeshWave<directionInfo> directionCalc
208 mesh.globalData().nTotalCells()+1
211 const List<directionInfo>& cellInfo = directionCalc.allCellInfo();
221 label index = cellInfo[cellI].index();
227 <<
"Cell " << cellI <<
" never visited to determine "
228 <<
"local coordinate system" << endl
229 <<
"Using direction " << defaultDir <<
" instead" <<
endl;
231 dirField[cellI] = defaultDir;
235 else if (index == -2)
238 dirField[cellI] = cellInfo[cellI].n();
242 else if (index == -1)
245 <<
"Illegal index " << index << endl
257 Pout<<
"Calculated local coords for " << defaultDir
259 <<
" Geometric cut cells : " << nGeom << endl
260 <<
" Topological cut cells : " << nTopo << endl
261 <<
" Unset cells : " << nUnset << endl
271 Foam::directions::directions
282 bool wantNormal =
false;
283 bool wantTan1 =
false;
284 bool wantTan2 =
false;
288 directionType wantedDir = directionTypeNames_[wantedDirs[i]];
290 if (wantedDir == NORMAL)
294 else if (wantedDir == TAN1)
298 else if (wantedDir == TAN2)
307 word coordSystem(dict.
lookup(
"coordinateSystem"));
309 if (coordSystem ==
"global")
314 check2D(correct2DPtr, tan1);
317 check2D(correct2DPtr, tan2);
320 normal /=
mag(normal);
322 Pout<<
"Global Coordinate system:" << endl
323 <<
" normal : " << normal << endl
324 <<
" tan1 : " << tan1 << endl
325 <<
" tan2 : " << tan2
341 else if (coordSystem ==
"patchLocal")
353 "directions::directions(const polyMesh&, const dictionary&,"
354 "const twoDPointCorrector*"
355 ) <<
"Cannot find patch "
372 "directions::directions(const polyMesh&, const dictionary&,"
373 "const twoDPointCorrector*"
374 ) <<
"Discarding user specified tan1 since 2D case." << endl
375 <<
"Recalculated tan1 from face normal and planeNormal as "
376 << tan1 << endl <<
endl;
384 if (wantNormal || wantTan2)
398 operator[](nDirs++) = normalDirs;
405 if (wantTan1 || wantTan2)
420 operator[](nDirs++) = tan1Dirs;
430 operator[](nDirs++) = tan2Dirs;
440 "directions::directions(const polyMesh&, const dictionary&,"
441 "const twoDPointCorrector*"
442 ) <<
"Unknown coordinate system "
443 << coordSystem << endl