42 namespace functionObjects
57 Log <<
" functionObjects::" <<
type() <<
" " <<
name()
58 <<
" calculating stream-function" <<
endl;
86 label nVisitedOld = 0;
112 const auto& patchPhi =
phi.boundaryField()[patchi];
118 || isType<emptyPolyPatch>(
pp)
119 || isType<symmetryPlanePolyPatch>(
pp)
120 || isType<symmetryPolyPatch>(
pp)
121 || isType<wedgePolyPatch>(
pp)
129 const auto&
f =
pp[facei];
131 if (
magSqr(patchPhi[facei]) < SMALL)
136 for (
const label pointi :
f)
138 if (visitedPoint.test(pointi))
147 Log <<
" Zero face: patch: " << patchi
148 <<
" face: " << facei <<
endl;
150 for (
const label pointi :
f)
152 visitedPoint.set(pointi);
168 Log <<
" Zero flux boundary face not found. " 169 <<
"Using cell as a reference." <<
endl;
177 for (
const label pointi : zeroPoints)
179 if (visitedPoint.test(pointi))
188 for (
const label pointi : zeroPoints)
190 visitedPoint.set(pointi);
201 <<
"Cannot find initialisation face or a cell." 216 scalar currentStreamValue(0);
223 const auto& patchPhi =
phi.boundaryField()[patchi];
229 || isType<emptyPolyPatch>(
pp)
230 || isType<symmetryPlanePolyPatch>(
pp)
231 || isType<symmetryPolyPatch>(
pp)
232 || isType<wedgePolyPatch>(
pp)
240 const auto&
f =
pp[facei];
243 bool pointFound =
false;
245 for (
const label pointi :
f)
247 if (visitedPoint.test(pointi))
251 currentStreamPoint =
points[pointi];
266 for (
const label pointi :
f)
269 if (!visitedPoint.test(pointi))
273 points[pointi] - currentStreamPoint
278 const vector& nHat = unitAreas[facei];
280 if (edgeHat.y() > VSMALL)
282 visitedPoint.set(pointi);
288 + patchPhi[facei]*
sign(nHat.x())
291 else if (edgeHat.y() < -VSMALL)
293 visitedPoint.set(pointi);
299 - patchPhi[facei]*
sign(nHat.x())
304 if (edgeHat.x() > VSMALL)
306 visitedPoint.set(pointi);
312 + patchPhi[facei]*
sign(nHat.y())
315 else if (edgeHat.x() < -VSMALL)
317 visitedPoint.set(pointi);
323 - patchPhi[facei]*
sign(nHat.y())
333 for (label facei = 0; facei < nInternalFaces; ++facei)
335 const auto&
f = faces[facei];
337 bool pointFound =
false;
339 for (
const label pointi :
f)
342 if (visitedPoint.test(pointi))
345 currentStreamPoint =
points[pointi];
355 for (
const label pointi :
f)
358 if (!visitedPoint.test(pointi))
362 points[pointi] - currentStreamPoint
368 const vector& nHat = unitAreas[facei];
370 if (edgeHat.y() > VSMALL)
372 visitedPoint.set(pointi);
381 else if (edgeHat.y() < -VSMALL)
383 visitedPoint.set(pointi);
401 if (nVisited == nVisitedOld)
405 Log <<
" Exhausted a seed, looking for new seed " 406 <<
"(this is correct for multiply connected domains).";
412 nVisitedOld = nVisited;
424 return tstreamFunction;
428 bool Foam::functionObjects::streamFunction::calc()
430 const auto* phiPtr = findObject<surfaceScalarField>(fieldName_);
436 return store(resultName_, calc(
phi));
461 <<
"Case is not 2D, stream-function cannot be computed"
dimensionedScalar sign(const dimensionedScalar &ds)
defineTypeNameAndDebug(ObukhovLength, 0)
streamFunction(const word &name, const Time &runTime, const dictionary &dict)
Construct for given objectRegistry and dictionary.
errorManipArg< error, int > exit(error &err, const int errNo=1)
label nPoints() const noexcept
Number of mesh points.
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.
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create MeshObject registered with typeName.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const cellList & cells() const
void replace(const direction, const Cmpt &)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
label nGeometricD() const
Return the number of valid geometric dimensions in the mesh.
Macros for easy insertion into run-time selection tables.
const word & name() const noexcept
Return the name of this functionObject.
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
void setResultName(const word &typeName, const word &defaultArg)
Set the name of result field.
PtrList< polyPatch > polyPatchList
Store lists of polyPatch as a PtrList.
vectorField pointField
pointField is a vectorField.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
UList< face > faceUList
UList of faces.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
virtual const word & type() const =0
Runtime type information.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
label nInternalFaces() const noexcept
Number of internal faces.
virtual const faceList & faces() const
Return raw faces.
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
addToRunTimeSelectionTable(functionObject, ObukhovLength, dictionary)
vector point
Point is a vector.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Intermediate class for handling field expression function objects (e.g. blendingFactor etc...
const vectorField & faceAreas() const
const dimensionedScalar c
Speed of light in a vacuum.
const polyBoundaryMesh & patches
vector span() const
The bounding box span (from minimum to maximum)
static const Vector< label > one
const boundBox & bounds() const noexcept
Return mesh bounding box.
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< label > labelList
A List of labels.
A class for managing temporary objects.
void normalise()
Inplace normalise this field. Generally a no-op except for vector fields.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
const fvMesh & mesh_
Reference to the fvMesh.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
static constexpr const zero Zero
Global zero (0)
const Time & time_
Reference to the time database.