Go to the documentation of this file.
39 namespace functionObjects
49 Foam::functionObjects::setFlow::modeType
51 Foam::functionObjects::setFlow::modeTypeNames
53 { functionObjects::setFlow::modeType::FUNCTION,
"function" },
54 { functionObjects::setFlow::modeType::ROTATION,
"rotation" },
55 { functionObjects::setFlow::modeType::VORTEX2D,
"vortex2D" },
56 { functionObjects::setFlow::modeType::VORTEX3D,
"vortex3D" },
72 if (rhoName_ !=
"none")
85 <<
"Unable to find rho field'" << rhoName_
86 <<
"' in the mesh database. Available fields are:"
108 mode_(modeType::FUNCTION),
112 reverseTime_(VGREAT),
117 velocityPtr_(
nullptr)
131 modeTypeNames.readEntry(
"mode",
dict, mode_);
133 Info<<
" operating mode: " << modeTypeNames[mode_] <<
endl;
135 if (
dict.readIfPresent(
"U", UName_))
137 Info<<
" U field name: " << UName_ <<
endl;
140 if (
dict.readIfPresent(
"rho", rhoName_))
142 Info<<
" rho field name: " << rhoName_ <<
endl;
145 if (
dict.readIfPresent(
"phi", phiName_))
147 Info<<
" phi field name: " << phiName_ <<
endl;
150 if (
dict.readIfPresent(
"reverseTime", reverseTime_))
152 Info<<
" reverse flow direction at time: " << reverseTime_
154 reverseTime_ = mesh_.time().userTimeToTime(reverseTime_);
162 case modeType::FUNCTION:
167 case modeType::ROTATION:
171 dict.readEntry(
"origin", origin_);
175 R_ =
tensor(refDir, axis, refDir^axis);
178 case modeType::VORTEX2D:
179 case modeType::VORTEX3D:
181 dict.readEntry(
"origin", origin_);
185 R_ =
tensor(refDir, axis, refDir^axis);
209 if (!Uptr || !phiptr)
211 Info<<
" Either field " << UName_ <<
" or " << phiName_
212 <<
" not found in the mesh database" <<
nl;
217 const scalar t = mesh_.time().timeOutputValue();
219 Log <<
" setting " << UName_ <<
" and " << phiName_ <<
nl;
226 case modeType::FUNCTION:
228 const vector Uc = velocityPtr_->value(t);
230 U.correctBoundaryConditions();
235 case modeType::ROTATION:
246 const scalar omega = omegaPtr_->value(t);
252 volVectorField::Boundary& Ubf =
U.boundaryFieldRef();
269 U.correctBoundaryConditions();
274 case modeType::VORTEX2D:
297 const scalarField xp(mesh_.points().component(0) - origin_[0]);
298 const scalarField yp(mesh_.points().component(1) - origin_[1]);
299 const scalarField zp(mesh_.points().component(2) - origin_[2]);
306 const face&
f = mesh_.faces()[fi];
311 const label p1 =
f[fpi];
312 const label p2 =
f[(fpi + 1) %
nPoints];
313 phic[fi] += 0.5*(
psi[p1] +
psi[p2])*(yp[p2] - yp[p1]);
317 surfaceScalarField::Boundary& phibf =
phi.boundaryFieldRef();
321 const label start = mesh_.boundaryMesh()[patchi].start();
326 const face&
f = mesh_.faces()[start + fi];
331 const label p1 =
f[fpi];
332 const label p2 =
f[(fpi + 1) %
nPoints];
333 phif[fi] += 0.5*(
psi[p1] +
psi[p2])*(yp[p2] - yp[p1]);
340 case modeType::VORTEX3D:
360 U.correctBoundaryConditions();
364 const vectorField Cf(mesh_.Cf().primitiveField() - origin_);
374 const vectorField& Sfc = mesh_.Sf().primitiveField();
377 surfaceScalarField::Boundary& phibf =
phi.boundaryFieldRef();
378 const surfaceVectorField::Boundary& Sfbf =
379 mesh_.Sf().boundaryField();
380 const surfaceVectorField::Boundary& Cfbf =
381 mesh_.Cf().boundaryField();
402 if (t > reverseTime_)
404 Log <<
" flow direction: reverse" <<
nl;
410 const scalar
s = scalePtr_->value(t);
414 U.correctBoundaryConditions();
417 Log <<
" Continuity error: max(mag(sum(phi))) = "
virtual bool read(const dictionary &dict)
Read the setFlow data.
Type * getObjectPtr(const word &name, const bool recursive=false) const
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
tmp< surfaceScalarField > flux(const volVectorField &vvf)
Return the face-flux field obtained from the given volVectorField.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for handling words, derived from Foam::string.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
static constexpr const zero Zero
Global zero (0)
const dimensionSet dimVelocity
dimensionedScalar sin(const dimensionedScalar &ds)
bool read(const char *buf, int32_t &val)
Same as readInt32.
setFlow(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
autoPtr< surfaceVectorField > Uf
Ostream & endl(Ostream &os)
Add newline and flush stream.
Vector< Cmpt > & normalise()
Normalise the vector by its magnitude.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
#define forAll(list, i)
Loop across all elements in list.
surfaceScalarField phic(mixture.cAlpha() *mag(alphaPhic/mesh.magSf()))
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
virtual bool execute()
Do nothing.
virtual bool write()
Calculate the setFlow and write.
messageStream Info
Information stream (uses stdout - output is on the master only)
word name(const complex &c)
Return string representation of complex.
void replace(const direction, const UList< cmptType > &)
Replace a component field of the field.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Surface integrate surfaceField creating a volField. Surface sum a surfaceField creating a volField.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
virtual bool read(const dictionary &dict)
Read optional controls.
Macros for easy insertion into run-time selection tables.
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
errorManipArg< error, int > exit(error &err, const int errNo=1)
GeometricField< vector, fvPatchField, volMesh > volVectorField
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
constexpr scalar pi(M_PI)
wordList names() const
The names of all objects.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
addToRunTimeSelectionTable(functionObject, ObukhovLength, dictionary)
void surfaceIntegrate(Field< Type > &ivf, const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Calculate the face-flux of the given field.
const fvMesh & mesh_
Reference to the fvMesh.
const volScalarField & Cp
defineTypeNameAndDebug(ObukhovLength, 0)
A face is a list of labels corresponding to mesh vertices.
Graphite solid properties.
const volScalarField & psi
Tensor< scalar > tensor
Tensor of scalars, i.e. Tensor<scalar>.
Type gMax(const FieldField< Field, Type > &f)