Go to the documentation of this file.
34 #include "surfaceInterpolate.H"
52 directionalPressureGradientExplicitSource,
65 Foam::fv::directionalPressureGradientExplicitSource::pressureDropModelNames_
67 { pressureDropModel::pVolumetricFlowRateTable,
"volumetricFlowRateTable" },
68 { pressureDropModel::pConstant,
"constant" },
69 { pressureDropModel::pDarcyForchheimer,
"DarcyForchheimer" },
75 void Foam::fv::directionalPressureGradientExplicitSource::initialise()
80 facePatchId_.
setSize(fZone.size());
85 const label faceI = fZone[i];
88 label facePatchId = -1;
98 const auto* cpp = isA<coupledPolyPatch>(pp);
102 faceId = (cpp->owner() ? pp.whichFace(faceI) : -1);
104 else if (!isA<emptyPolyPatch>(pp))
106 faceId = pp.whichFace(faceI);
117 facePatchId_[
count] = facePatchId;
127 void Foam::fv::directionalPressureGradientExplicitSource::writeProps
133 if (mesh_.time().writeTime())
139 name_ +
"Properties",
140 mesh_.time().timeName(),
158 const word& sourceName,
159 const word& modelType,
165 model_(pressureDropModelNames_.get(
"model", coeffs_)),
166 gradP0_(cells_.size(),
Zero),
167 dGradP_(cells_.size(),
Zero),
168 gradPporous_(cells_.size(),
Zero),
169 flowDir_(coeffs_.get<
vector>(
"flowDir")),
176 faceZoneName_(coeffs_.get<
word>(
"faceZone")),
177 zoneID_(mesh_.faceZones().findZoneID(faceZoneName_)),
180 relaxationFactor_(coeffs_.getOrDefault<scalar>(
"relaxationFactor", 0.3)),
181 cellFaceMap_(cells_.size(), -1)
183 coeffs_.readEntry(
"fields", fieldNames_);
185 flowDir_.normalise();
187 if (fieldNames_.size() != 1)
190 <<
"Source can only be applied to a single field. Current "
197 <<
type() <<
" " << this->
name() <<
": "
198 <<
" Unknown face zone name: " << faceZoneName_
199 <<
". Valid face zones are: " << mesh_.faceZones().names()
203 if (model_ == pVolumetricFlowRateTable)
207 else if (model_ == pConstant)
209 coeffs_.readEntry(
"pressureDrop", pressureDrop_);
211 else if (model_ == pDarcyForchheimer)
213 coeffs_.readEntry(
"D", D_);
214 coeffs_.readEntry(
"I", I_);
215 coeffs_.readEntry(
"length", length_);
220 <<
"Did not find mode " << model_ <<
nl
221 <<
"Please set 'model' to one of "
222 << pressureDropModelNames_
231 mesh_.time().timePath()/
"uniform"/(name_ +
"Properties")
234 if (propsFile.
good())
236 Info<<
" Reading pressure gradient from file" <<
endl;
238 propsDict.readEntry(
"gradient", gradP0_);
241 Info<<
" Initial pressure gradient = " << gradP0_ <<
nl <<
endl;
262 case pDarcyForchheimer:
266 const auto& turbModel =
274 gradPporous_ = -flowDir_*(D_*
nu + I_*0.5*magUn)*magUn*length_;
278 const auto& turbModel =
289 - flowDir_*(D_*
mu + I_*0.5*
rho*magUn)*magUn*length_;
295 gradPporous_ = -flowDir_*pressureDrop_;
299 case pVolumetricFlowRateTable:
301 scalar volFlowRate = 0;
306 label faceI = faceId_[i];
307 if (facePatchId_[i] != -1)
309 label patchI = facePatchId_[i];
310 totalphi +=
phi.boundaryField()[patchI][faceI];
314 totalphi +=
phi[faceI];
321 volFlowRate =
mag(totalphi);
325 const auto& turbModel =
333 volFlowRate =
mag(totalphi)/rhoAve;
336 gradPporous_ = -flowDir_*flowRate_(volFlowRate);
341 const faceZone& fZone = mesh_.faceZones()[zoneID_];
343 labelList meshToLocal(mesh_.nCells(), -1);
346 meshToLocal[cells_[i]] = i;
349 labelList faceToCellIndex(fZone.size(), -1);
355 label masterCellI = mc[i];
357 if (meshToLocal[masterCellI] != -1 && masterCellI != -1)
359 faceToCellIndex[i] = meshToLocal[masterCellI];
361 else if (meshToLocal[masterCellI] == -1)
364 <<
"Did not find cell " << masterCellI
365 <<
"in cellZone :" << cellSetName()
378 forAll(
U.boundaryField(), patchI)
386 else if (!isA<emptyFvPatchScalarField>(pf))
394 label faceI = fZone[i];
395 label
cellId = faceToCellIndex[i];
399 label sourceCellId = sc[i];
400 if (mesh_.isInternalFace(faceI))
402 scalar w = mesh_.magSf()[faceI];
403 UfCells[
cellId] +=
U[sourceCellId]*w;
404 UfCellWeights[
cellId] += w;
408 label patchI = pbm.patchID()[faceI-mesh_.nInternalFaces()];
409 label localFaceI = pbm[patchI].whichFace(faceI);
411 scalar w = mesh_.magSf().boundaryField()[patchI][localFaceI];
413 if (upwindValues.set(patchI))
415 UfCells[
cellId] += upwindValues[patchI][localFaceI]*w;
416 UfCellWeights[
cellId] += w;
422 UfCells /= UfCellWeights;
426 label cellI = cells_[i];
428 const vector Ufnorm(UfCells[i]/(
mag(UfCells[i]) + SMALL));
435 (
D & UfCells[i]) -
U[cellI]
441 Info<<
"Difference mag(U) = "
442 <<
mag(UfCells[i]) -
mag(
U[cellI])
444 Info<<
"Pressure drop in flowDir direction : "
445 << gradPporous_[i] <<
endl;
446 Info<<
"UfCell:= " << UfCells[i] <<
"U : " <<
U[cellI] <<
endl;
449 writeProps(gradP0_ + dGradP_);
463 name_ + fieldNames_[fieldI] +
"Sup",
464 mesh_.time().timeName(),
486 this->addSup(eqn, fieldI);
505 mesh_.time().timeName(),
516 invAPtr_() = 1.0/eqn.
A();
543 coeffs.readEntry(
"flowDir", flowDir_);
544 flowDir_.normalise();
546 if (model_ == pConstant)
548 coeffs.readEntry(
"pressureDrop", pressureDrop_);
550 else if (model_ == pDarcyForchheimer)
552 coeffs.readEntry(
"D", D_);
553 coeffs.readEntry(
"I", I_);
554 coeffs.readEntry(
"length", length_);
int debug
Static debugging option.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
volVectorField gradP(fvc::grad(p))
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
tmp< volScalarField > rAU
A class for handling words, derived from Foam::string.
Intermediate abstract class for handling cell-set options for the derived fvOptions.
A field of fields is a PtrList of fields with reference counting.
const boolList & flipMap() const noexcept
Return face flip map.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
const dimensionedScalar mu
Atomic mass unit.
static constexpr const zero Zero
Global zero (0)
const dimensionSet dimVelocity
Input from file stream, using an ISstream.
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
const dimensionSet & dimensions() const
virtual void constrain(fvMatrix< vector > &eqn, const label fieldI)
Set 1/A coefficient.
static const word propertiesName
Default name of the turbulence properties dictionary.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Type gSum(const FieldField< Field, Type > &f)
const fvMesh & mesh_
Reference to the mesh database.
#define forAll(list, i)
Loop across all elements in list.
bool good() const noexcept
True if next operation might succeed.
Field< vector > vectorField
Specialisation of Field<T> for vector.
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
A special matrix type and solver, designed for finite volume solutions of scalar equations.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
virtual bool coupled() const
Return true if this patch field is coupled.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
const dimensionSet dimArea(sqr(dimLength))
A subset of mesh faces organised as a primitive patch.
messageStream Info
Information stream (stdout output on master, null elsewhere)
void setSize(const label n)
Alias for resize()
const labelList & slaveCells() const
Return labels of slave cells.
IOdictionary propsDict(IOobject("particleTrackProperties", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED))
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
directionalPressureGradientExplicitSource(const word &sourceName, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from explicit source name and mesh.
scalarProduct< Type, Type >::type gSumProd(const UList< Type > &f1, const UList< Type > &f2, const label comm)
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
OBJstream os(runTime.globalPath()/outputName)
Macros for easy insertion into run-time selection tables.
tmp< volScalarField > A() const
Return the central coefficient.
Mesh data needed to do the Finite Volume discretisation.
pressureDropModel
Modes of pressure drop.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual tmp< Field< Type > > patchNeighbourField() const
Return patchField on the opposite patch of a coupled patch.
const labelList & masterCells() const
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual void addSup(fvMatrix< vector > &eqn, const label fieldI)
Add explicit contribution to momentum equation.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Templated wrapper class to provide compressible turbulence models thermal diffusivity based thermal t...
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
const dimensionedScalar & D
A special matrix type and solver, designed for finite volume solutions of scalar equations....
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A List with indirect addressing.
Templated abstract base class for single-phase incompressible turbulence models.
defineTypeNameAndDebug(atmAmbientTurbSource, 0)
virtual void writeData(Ostream &os) const
Write the source properties.
addToRunTimeSelectionTable(option, atmAmbientTurbSource, dictionary)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from vector n1 to n2.
virtual void correct(volVectorField &U)
Correct the pressure gradient.
const dimensionSet dimVolume(pow3(dimLength))
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
virtual bool read(const dictionary &dict)
Read source dictionary.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...