57 Log <<
" functionObjects::" <<
type() <<
" " <<
name()
58 <<
" calculating stream-function" <<
endl;
86 label nVisitedOld = 0;
94 unitAreas.normalise();
112 const auto& patchPhi =
phi.boundaryField()[patchi];
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;
171 for (
const cell& c :
mesh_.cells())
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];
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
275 edgeHat.replace(slabDir, 0);
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
365 edgeHat.replace(slabDir, 0);
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;
419 const scalar thickness =
vector(slabNormal) &
mesh_.bounds().span();
424 return tstreamFunction;
430 const auto* phiPtr = findObject<surfaceScalarField>(fieldName_);
436 return store(resultName_, calc(
phi));
461 <<
"Case is not 2D, stream-function cannot be computed"
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Defines the attributes of an object for which implicit objectRegistry management is supported,...
static FOAM_NO_DANGLING_REFERENCE const pointMesh & New(const polyMesh &mesh, Args &&... args)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
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.
static const Vector< Cmpt > one
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Abstract base-class for Time/database function objects.
virtual const word & type() const =0
Runtime type information.
Intermediate class for handling field expression function objects (e.g. blendingFactor etc....
fieldExpression(const word &name, const Time &runTime, const dictionary &dict, const word &fieldName=word::null, const word &resultName=word::null)
Construct from name, Time and dictionary.
virtual bool calc()=0
Calculate the components of the field and return true if successful.
void setResultName(const word &typeName, const word &defaultArg)
Set the name of result field.
const fvMesh & mesh_
Reference to the fvMesh.
Computes the stream function (i.e. https://w.wiki/Ncm).
streamFunction(const word &name, const Time &runTime, const dictionary &dict)
Construct for given objectRegistry and dictionary.
const Time & time_
Reference to the time database.
Mesh representing a set of points created from polyMesh.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
label nGeometricD() const
Return the number of valid geometric dimensions in the mesh.
virtual const faceList & faces() const
Return raw faces.
virtual const pointField & points() const
Return raw points.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
label nInternalFaces() const noexcept
Number of internal faces.
label nPoints() const noexcept
Number of mesh points.
const vectorField & faceAreas() const
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const dimensionedScalar c
Speed of light in a vacuum.
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
PtrList< polyPatch > polyPatchList
Store lists of polyPatch as a PtrList.
dimensionedScalar sign(const dimensionedScalar &ds)
List< label > labelList
A List of labels.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
static constexpr const zero Zero
Global zero (0).
bool isType(const U &obj)
Check if typeid of the object and Type are identical.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
vectorField pointField
pointField is a vectorField.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
UList< face > faceUList
UList of faces.
#define forAll(list, i)
Loop across all elements in list.