45 Foam::directions::directionTypeNames_
47 { directionType::TAN1,
"tan1" },
48 { directionType::TAN2,
"tan2" },
49 { directionType::NORMAL,
"normal" },
55 void Foam::directions::writeOBJ(Ostream&
os,
const point& pt)
57 os <<
"v " << pt.x() <<
' ' << pt.y() <<
' ' << pt.z() <<
endl;
61 void Foam::directions::writeOBJ
72 os <<
"l " << vertI + 1 <<
' ' << vertI + 2 <<
endl;
78 void Foam::directions::writeOBJ
80 const fileName& fName,
81 const primitiveMesh&
mesh,
85 Pout<<
"Writing cell info to " << fName <<
" as vectors at the cellCentres" 88 OFstream xDirStream(fName);
97 scalar minDist = GREAT;
106 scalar scale = 0.5*minDist;
108 writeOBJ(xDirStream, ctr, ctr + scale*dirs[celli], vertI);
113 void Foam::directions::check2D
115 const twoDPointCorrector* correct2DPtr,
121 if (
mag(correct2DPtr->planeNormal() & vec) > 1
e-6)
124 <<
"is not normal to plane defined in dynamicMeshDict." 126 <<
"Either make case 3D or adjust vector." 135 const polyMesh&
mesh,
144 List<directionInfo> changedFacesInfo(
pp.size());
150 label meshFacei =
pp.start() + patchFacei;
157 <<
"useHexTopology specified but cell " << celli
158 <<
" on face " << patchFacei <<
" of patch " <<
pp.name()
162 const vector& cutDir = ppField[patchFacei];
178 changedFaces[patchFacei] = meshFacei;
179 changedFacesInfo[patchFacei] =
191 changedFaces[patchFacei] =
pp.start() + patchFacei;
192 changedFacesInfo[patchFacei] =
201 MeshWave<directionInfo> directionCalc
209 const List<directionInfo>& cellInfo = directionCalc.allCellInfo();
219 label index = cellInfo[celli].index();
225 <<
"Cell " << celli <<
" never visited to determine " 226 <<
"local coordinate system" <<
endl 227 <<
"Using direction " << defaultDir <<
" instead" <<
endl;
229 dirField[celli] = defaultDir;
233 else if (index == -2)
236 dirField[celli] = cellInfo[celli].n();
240 else if (index == -1)
243 <<
"Illegal index " << index <<
endl 255 reduce(nGeom, sumOp<label>());
256 reduce(nTopo, sumOp<label>());
257 reduce(nUnset, sumOp<label>());
259 Info<<
"Calculated local coords for " << defaultDir
261 <<
" Geometric cut cells : " << nGeom <<
endl 262 <<
" Topological cut cells : " << nTopo <<
endl 263 <<
" Unset cells : " << nUnset <<
endl 272 Foam::directions::directions
282 const word coordSystem(
dict.get<
word>(
"coordinateSystem"));
286 bool wantNormal =
false;
287 bool wantTan1 =
false;
288 bool wantTan2 =
false;
291 if (coordSystem !=
"fieldBased")
293 for (
const word& wantedName : wantedDirs)
301 else if (wantedDir ==
TAN1)
305 else if (wantedDir ==
TAN2)
313 if (coordSystem ==
"global")
318 check2D(correct2DPtr, tan1);
321 check2D(correct2DPtr, tan2);
325 Info<<
"Global Coordinate system:" <<
endl 326 <<
" normal : " << normal <<
endl 327 <<
" tan1 : " << tan1 <<
endl 328 <<
" tan2 : " << tan2
344 else if (coordSystem ==
"patchLocal")
348 const word patchName(patchDict.get<word>(
"patch"));
350 const label patchi =
mesh.boundaryMesh().findPatchID(patchName);
355 <<
"Cannot find patch " 361 const polyPatch&
pp =
mesh.boundaryMesh()[patchi];
365 const vector& n0 =
pp.faceNormals()[0];
372 <<
"Discarding user specified tan1 since 2D case." <<
endl 373 <<
"Recalculated tan1 from face normal and planeNormal as " 377 const bool useTopo(
dict.get<
bool>(
"useHexTopology"));
382 if (wantNormal || wantTan2)
400 if (wantTan1 || wantTan2)
420 tmp<vectorField> tan2Dirs = normalDirs ^ tan1Dirs;
425 else if (coordSystem ==
"fieldBased")
434 mesh.instance()/wantedDirs[i],
445 <<
"Unknown coordinate system " 446 << coordSystem <<
endl 447 <<
"Known types are global, patchLocal and fieldBased"
void size(const label n)
Older name for setAddressableSize.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void resize(const label len)
Adjust allocated size of list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool test(const UList< face > &faces)
Test if given list of faces satisfies criteria for HEX. (6 quad)
Ignore writing from objectRegistry::writeObject()
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
#define forAll(list, i)
Loop across all elements in list.
T & operator[](const label i)
Return element of UList.
const dimensionedScalar e
Elementary charge.
Class applies a two-dimensional correction to mesh motion point field.
A class for handling words, derived from Foam::string.
static label edgeToFaceIndex(const primitiveMesh &mesh, const label celli, const label facei, const label edgeI)
Given edge on hex cell find corresponding edge on face. Is either.
virtual const labelList & faceOwner() const
Return face owner.
const globalMeshData & globalData() const
Return parallel info (demand-driven)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
const vectorField & cellCentres() const
errorManip< error > abort(error &err)
OBJstream os(runTime.globalPath()/outputName)
const vector & planeNormal() const
Return plane normal.
label nTotalCells() const noexcept
Total global number of mesh cells.
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
directionType
Enumeration listing the possible coordinate directions.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Field< vector > vectorField
Specialisation of Field<T> for vector.
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
IOField< vector > vectorIOField
IO for a Field of vector.
const labelListList & cellCells() const
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())