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 label faceI = fZone[i];
88 label facePatchId = -1;
98 if (isA<coupledPolyPatch>(pp))
100 if (refCast<const coupledPolyPatch>(pp).owner())
102 faceId = pp.whichFace(faceI);
109 else if (!isA<emptyPolyPatch>(pp))
111 faceId = faceI - pp.start();
122 facePatchId_[
count] = facePatchId;
132 void Foam::fv::directionalPressureGradientExplicitSource::writeProps
138 if (mesh_.time().writeTime())
144 name_ +
"Properties",
145 mesh_.time().timeName(),
163 const word& sourceName,
164 const word& modelType,
170 model_(pressureDropModelNames_.get(
"model", coeffs_)),
171 gradP0_(cells_.size(),
Zero),
172 dGradP_(cells_.size(),
Zero),
173 gradPporous_(cells_.size(),
Zero),
174 flowDir_(coeffs_.get<
vector>(
"flowDir")),
181 faceZoneName_(coeffs_.get<
word>(
"faceZone")),
182 zoneID_(mesh_.faceZones().findZoneID(faceZoneName_)),
185 relaxationFactor_(coeffs_.getOrDefault<scalar>(
"relaxationFactor", 0.3)),
186 cellFaceMap_(cells_.size(), -1)
188 coeffs_.readEntry(
"fields", fieldNames_);
190 flowDir_.normalise();
192 if (fieldNames_.size() != 1)
195 <<
"Source can only be applied to a single field. Current "
202 <<
type() <<
" " << this->
name() <<
": "
203 <<
" Unknown face zone name: " << faceZoneName_
204 <<
". Valid face zones are: " << mesh_.faceZones().names()
208 if (model_ == pVolumetricFlowRateTable)
212 else if (model_ == pConstant)
214 coeffs_.readEntry(
"pressureDrop", pressureDrop_);
216 else if (model_ == pDarcyForchheimer)
218 coeffs_.readEntry(
"D", D_);
219 coeffs_.readEntry(
"I", I_);
220 coeffs_.readEntry(
"length", length_);
225 <<
"Did not find mode " << model_ <<
nl
226 <<
"Please set 'model' to one of "
227 << pressureDropModelNames_
231 applied_.setSize(fieldNames_.size(),
false);
236 mesh_.time().timePath()/
"uniform"/(name_ +
"Properties")
239 if (propsFile.
good())
241 Info<<
" Reading pressure gradient from file" <<
endl;
243 propsDict.readEntry(
"gradient", gradP0_);
246 Info<<
" Initial pressure gradient = " << gradP0_ <<
nl <<
endl;
267 case pDarcyForchheimer:
271 const auto& turbModel =
279 gradPporous_ = -flowDir_*(D_*
nu + I_*0.5*magUn)*magUn*length_;
283 const auto& turbModel =
294 - flowDir_*(D_*
mu + I_*0.5*
rho*magUn)*magUn*length_;
300 gradPporous_ = -flowDir_*pressureDrop_;
304 case pVolumetricFlowRateTable:
306 scalar volFlowRate = 0;
311 label faceI = faceId_[i];
312 if (facePatchId_[i] != -1)
314 label patchI = facePatchId_[i];
315 totalphi +=
phi.boundaryField()[patchI][faceI];
319 totalphi +=
phi[faceI];
326 volFlowRate =
mag(totalphi);
330 const auto& turbModel =
338 volFlowRate =
mag(totalphi)/rhoAve;
341 gradPporous_ = -flowDir_*flowRate_(volFlowRate);
346 const faceZone& fZone = mesh_.faceZones()[zoneID_];
348 labelList meshToLocal(mesh_.nCells(), -1);
351 meshToLocal[cells_[i]] = i;
354 labelList faceToCellIndex(fZone.size(), -1);
360 label masterCellI = mc[i];
362 if (meshToLocal[masterCellI] != -1 && masterCellI != -1)
364 faceToCellIndex[i] = meshToLocal[masterCellI];
366 else if (meshToLocal[masterCellI] == -1)
369 <<
"Did not find cell " << masterCellI
370 <<
"in cellZone :" << cellSetName()
383 forAll(
U.boundaryField(), patchI)
391 else if (!isA<emptyFvPatchScalarField>(pf))
399 label faceI = fZone[i];
400 label
cellId = faceToCellIndex[i];
404 label sourceCellId = sc[i];
405 if (mesh_.isInternalFace(faceI))
407 scalar w = mesh_.magSf()[faceI];
408 UfCells[
cellId] +=
U[sourceCellId]*w;
409 UfCellWeights[
cellId] += w;
413 label patchI = pbm.patchID()[faceI-mesh_.nInternalFaces()];
414 label localFaceI = pbm[patchI].whichFace(faceI);
416 scalar w = mesh_.magSf().boundaryField()[patchI][localFaceI];
418 if (upwindValues.set(patchI))
420 UfCells[
cellId] += upwindValues[patchI][localFaceI]*w;
421 UfCellWeights[
cellId] += w;
427 UfCells /= UfCellWeights;
431 label cellI = cells_[i];
433 const vector Ufnorm(UfCells[i]/(
mag(UfCells[i]) + SMALL));
440 (
D & UfCells[i]) -
U[cellI]
446 Info<<
"Difference mag(U) = "
447 <<
mag(UfCells[i]) -
mag(
U[cellI])
449 Info<<
"Pressure drop in flowDir direction : "
450 << gradPporous_[i] <<
endl;
451 Info<<
"UfCell:= " << UfCells[i] <<
"U : " <<
U[cellI] <<
endl;
454 writeProps(gradP0_ + dGradP_);
468 name_ + fieldNames_[fieldI] +
"Sup",
469 mesh_.time().timeName(),
491 this->addSup(eqn, fieldI);
510 mesh_.time().timeName(),
521 invAPtr_() = 1.0/eqn.
A();
548 coeffs.readEntry(
"flowDir", flowDir_);
549 flowDir_.normalise();
551 if (model_ == pConstant)
553 coeffs.readEntry(
"pressureDrop", pressureDrop_);
555 else if (model_ == pDarcyForchheimer)
557 coeffs.readEntry(
"D", D_);
558 coeffs.readEntry(
"I", I_);
559 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.
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.
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.
Field< vector > vectorField
Specialisation of Field<T> for vector.
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
const faceZoneMesh & faceZones() const
Return face zone mesh.
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
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 (uses stdout - output is on the master only)
word name(const complex &c)
Return string representation of complex.
const labelList & slaveCells() const
Return labels of slave cells.
IOdictionary propsDict(IOobject("particleTrackProperties", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED))
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,...
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
#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...
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
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....
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.
bool good() const
Return true if next operation might succeed.
virtual void correct(volVectorField &U)
Correct the pressure gradient.
const dimensionSet dimVolume(pow3(dimLength))
void setSize(const label newSize)
Alias for resize(const label)
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
const boolList & flipMap() const
Return face flip map.
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...