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_);
158 scalePtr_ = Function1<scalar>::New(
"scale",
dict, &mesh_);
162 case modeType::FUNCTION:
164 velocityPtr_ = Function1<vector>::New(
"velocity",
dict, &mesh_);
167 case modeType::ROTATION:
169 omegaPtr_ = Function1<scalar>::New(
"omega",
dict, &mesh_);
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);
248 Uc.replace(vector::X, -omega*z);
250 Uc.replace(vector::Z, omega*
x);
262 Uf.replace(vector::X, -omega*zp);
264 Uf.replace(vector::Z, omega*xp);
269 U.correctBoundaryConditions();
274 case modeType::VORTEX2D:
294 U.correctBoundaryConditions();
298 const vectorField Cf(mesh_.Cf().primitiveField() - origin_);
308 const vectorField& Sfc = mesh_.Sf().primitiveField();
313 mesh_.Sf().boundaryField();
315 mesh_.Cf().boundaryField();
334 case modeType::VORTEX3D:
354 U.correctBoundaryConditions();
358 const vectorField Cf(mesh_.Cf().primitiveField() - origin_);
368 const vectorField& Sfc = mesh_.Sf().primitiveField();
373 mesh_.Sf().boundaryField();
375 mesh_.Cf().boundaryField();
396 if (t > reverseTime_)
398 Log <<
" flow direction: reverse" <<
nl;
404 const scalar
s = scalePtr_->value(t);
408 U.correctBoundaryConditions();
411 Log <<
" Continuity error: max(mag(sum(phi))) = "
setFlow(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Surface integrate surfaceField creating a volField. Surface sum a surfaceField creating a volField...
defineTypeNameAndDebug(ObukhovLength, 0)
void surfaceIntegrate(Field< Type > &ivf, const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
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.
tmp< surfaceScalarField > flux(const volVectorField &vvf)
Return the face-flux field obtained from the given volVectorField.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
constexpr char nl
The newline '\n' character (0x0a)
wordList names() const
The unsorted names of all objects.
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
Vector< Cmpt > & normalise(const scalar tol=ROOTVSMALL)
Inplace normalise the vector by its magnitude.
GeometricBoundaryField< vector, fvPatchField, volMesh > Boundary
Type of boundary fields.
void replace(const direction, const UList< cmptType > &)
Replace a component field of the field.
GeometricField< vector, fvPatchField, volMesh > volVectorField
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Macros for easy insertion into run-time selection tables.
bool read(const char *buf, int32_t &val)
Same as readInt32.
#define forAll(list, i)
Loop across all elements in list.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
static const Identity< scalar > I
A class for handling words, derived from Foam::string.
Type * getObjectPtr(const word &name, const bool recursive=false) const
Return non-const pointer to the object of the given Type, using a const-cast to have it behave like a...
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Calculate the face-flux of the given field.
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
constexpr scalar pi(M_PI)
virtual bool execute()
Do nothing.
autoPtr< surfaceVectorField > Uf
virtual bool write()
Calculate the setFlow and write.
dimensionedScalar sin(const dimensionedScalar &ds)
const volScalarField & Cp
Type gMax(const FieldField< Field, Type > &f)
addToRunTimeSelectionTable(functionObject, ObukhovLength, dictionary)
surfaceScalarField phic(mixture.cAlpha() *mag(alphaPhic/mesh.magSf()))
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
PtrList< volScalarField > & Y
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual bool read(const dictionary &dict)
Read optional controls.
Field< vector > vectorField
Specialisation of Field<T> for vector.
virtual bool read(const dictionary &dict)
Read the setFlow data.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
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))
Tensor of scalars, i.e. Tensor<scalar>.
const fvMesh & mesh_
Reference to the fvMesh.
static constexpr const zero Zero
Global zero (0)
const dimensionSet dimVelocity