39 namespace functionObjects
60 Log <<
" functionObjects::" <<
type() <<
" " <<
name()
61 <<
" calculating steam-function" <<
endl;
70 scalar thickness =
vector(slabNormal) & mesh_.bounds().span();
74 tmp<pointScalarField> tstreamFunction
86 forAll(visitedPoint, pointi)
88 visitedPoint[pointi] = 0;
91 label nVisitedOld = 0;
96 label nInternalFaces = mesh_.nInternalFaces();
99 unitAreas /=
mag(unitAreas);
103 bool finished =
true;
117 if (!isType<emptyPolyPatch>(patches[patchi]))
126 const labelList& zeroPoints = bouFaces[facei];
131 forAll(zeroPoints, pointi)
133 if (visitedPoint[zeroPoints[pointi]] == 1)
142 Log <<
" Zero face: patch: " << patchi
143 <<
" face: " << facei <<
endl;
145 forAll(zeroPoints, pointi)
147 streamFunction[zeroPoints[pointi]] = 0;
148 visitedPoint[zeroPoints[pointi]] = 1;
163 Log <<
" Zero flux boundary face not found. " 164 <<
"Using cell as a reference." 171 labelList zeroPoints = c[cI].labels(mesh_.faces());
175 forAll(zeroPoints, pointi)
177 if (visitedPoint[zeroPoints[pointi]] == 1)
186 forAll(zeroPoints, pointi)
188 streamFunction[zeroPoints[pointi]] = 0.0;
189 visitedPoint[zeroPoints[pointi]] = 1;
198 <<
"Cannot find initialisation face or a cell." 213 for (
label facei = nInternalFaces; facei<faces.size(); facei++)
215 const labelList& curBPoints = faces[facei];
216 bool bPointFound =
false;
218 scalar currentBStream = 0.0;
219 vector currentBStreamPoint(0, 0, 0);
221 forAll(curBPoints, pointi)
224 if (visitedPoint[curBPoints[pointi]] == 1)
227 currentBStream = streamFunction[curBPoints[pointi]];
228 currentBStreamPoint = points[curBPoints[pointi]];
239 forAll(curBPoints, pointi)
242 if (visitedPoint[curBPoints[pointi]] == 0)
245 mesh_.boundaryMesh().whichPatch(facei);
249 !isType<emptyPolyPatch>(patches[patchNo])
250 && !isType<symmetryPlanePolyPatch>
252 && !isType<symmetryPolyPatch>(patches[patchNo])
253 && !isType<wedgePolyPatch>(patches[patchNo])
257 mesh_.boundaryMesh()[patchNo]
261 points[curBPoints[pointi]]
262 - currentBStreamPoint;
264 edgeHat /=
mag(edgeHat);
266 vector nHat = unitAreas[facei];
268 if (edgeHat.y() > vSmall)
270 visitedPoint[curBPoints[pointi]] = 1;
273 streamFunction[curBPoints[pointi]] =
275 + phi.boundaryField()[patchNo][faceNo]
278 else if (edgeHat.y() < -vSmall)
280 visitedPoint[curBPoints[pointi]] = 1;
283 streamFunction[curBPoints[pointi]] =
285 - phi.boundaryField()[patchNo][faceNo]
290 if (edgeHat.x() > vSmall)
292 visitedPoint[curBPoints[pointi]] = 1;
295 streamFunction[curBPoints[pointi]] =
297 + phi.boundaryField()[patchNo][faceNo]
300 else if (edgeHat.x() < -vSmall)
302 visitedPoint[curBPoints[pointi]] = 1;
305 streamFunction[curBPoints[pointi]] =
307 - phi.boundaryField()[patchNo][faceNo]
321 for (
label facei=0; facei<nInternalFaces; facei++)
324 const labelList& curPoints = faces[facei];
326 bool pointFound =
false;
328 scalar currentStream = 0.0;
329 point currentStreamPoint(0, 0, 0);
334 if (visitedPoint[curPoints[pointi]] == 1)
337 currentStream = streamFunction[curPoints[pointi]];
338 currentStreamPoint = points[curPoints[pointi]];
351 if (visitedPoint[curPoints[pointi]] == 0)
354 points[curPoints[pointi]] - currentStreamPoint;
357 edgeHat /=
mag(edgeHat);
359 vector nHat = unitAreas[facei];
361 if (edgeHat.y() > vSmall)
363 visitedPoint[curPoints[pointi]] = 1;
366 streamFunction[curPoints[pointi]] =
368 + phi[facei]*
sign(nHat.x());
370 else if (edgeHat.y() < -vSmall)
372 visitedPoint[curPoints[pointi]] = 1;
375 streamFunction[curPoints[pointi]] =
377 - phi[facei]*
sign(nHat.x());
388 if (nVisited == nVisitedOld)
392 Log <<
" Exhausted a seed, looking for new seed " 393 <<
"(this is correct for multiply connected domains).";
399 nVisitedOld = nVisited;
405 streamFunction /= thickness;
406 streamFunction.boundaryFieldRef() = 0.0;
408 return tstreamFunction;
412 bool Foam::functionObjects::streamFunction::calc()
414 if (foundObject<surfaceScalarField>(fieldName_))
419 return store(resultName_, calc(phi));
423 cannotFindObject<surfaceScalarField>(fieldName_);
441 label nD = mesh_.nGeometricD();
446 <<
"Case is not 2D, stream-function cannot be computed"
PtrList< polyPatch > polyPatchList
container classes for polyPatch
dimensionedScalar sign(const dimensionedScalar &ds)
#define forAll(list, i)
Loop across all elements in list.
streamFunction(const word &name, const Time &runTime, const dictionary &dict)
Construct for given objectRegistry and dictionary.
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual ~streamFunction()
Destructor.
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
addToRunTimeSelectionTable(functionObject, Qdot, dictionary)
static tmp< GeometricField< scalar, pointPatchField, pointMesh > > New(const word &name, const Internal &, const PtrList< pointPatchField< scalar >> &)
Return a temporary field constructed from name,.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Vector< scalar > vector
A scalar version of the templated Vector.
void replace(const direction, const Cmpt &)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Macros for easy insertion into run-time selection tables.
vectorField pointField
pointField is a vectorField.
A class for handling words, derived from string.
List< label > labelList
A List of labels.
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
dimensioned< scalar > magSqr(const dimensioned< Type > &)
static pointMesh & New(polyMesh &mesh)
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
Addressing for a faceList slice.
word name(const complex &)
Return a string representation of a complex.
defineTypeNameAndDebug(Qdot, 0)
Internal & ref()
Return a reference to the dimensioned internal field.
vector point
Point is a vector.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
#define Log
Report write to Foam::Info if the local log switch is true.
static const Vector< Cmpt > one
dimensioned< scalar > mag(const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
A class for managing temporary objects.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
List< cell > cellList
list of cells