Go to the documentation of this file.
34 #include "surfaceInterpolate.H"
53 directionalPressureGradientExplicitSource,
66 Foam::fv::directionalPressureGradientExplicitSource::pressureDropModelNames_
68 { pressureDropModel::pVolumetricFlowRateTable,
"volumetricFlowRateTable" },
69 { pressureDropModel::pConstant,
"constant" },
70 { pressureDropModel::pDarcyForchheimer,
"DarcyForchheimer" },
76 void Foam::fv::directionalPressureGradientExplicitSource::initialise()
81 facePatchId_.
setSize(fZone.size());
86 label faceI = fZone[i];
89 label facePatchId = -1;
99 if (isA<coupledPolyPatch>(pp))
101 if (refCast<const coupledPolyPatch>(pp).owner())
103 faceId = pp.whichFace(faceI);
110 else if (!isA<emptyPolyPatch>(pp))
112 faceId = faceI - pp.start();
123 facePatchId_[
count] = facePatchId;
133 void Foam::fv::directionalPressureGradientExplicitSource::writeProps
139 if (mesh_.time().writeTime())
145 name_ +
"Properties",
146 mesh_.time().timeName(),
161 Foam::fv::directionalPressureGradientExplicitSource::
162 directionalPressureGradientExplicitSource
164 const word& sourceName,
165 const word& modelType,
171 model_(pressureDropModelNames_.get(
"model", coeffs_)),
172 gradP0_(cells_.size(),
Zero),
173 dGradP_(cells_.size(),
Zero),
174 gradPporous_(cells_.size(),
Zero),
175 flowDir_(coeffs_.get<
vector>(
"flowDir")),
182 faceZoneName_(coeffs_.get<
word>(
"faceZone")),
183 zoneID_(mesh_.faceZones().findZoneID(faceZoneName_)),
186 relaxationFactor_(coeffs_.lookupOrDefault<scalar>(
"relaxationFactor",0.3)),
187 cellFaceMap_(cells_.size(), -1)
189 coeffs_.readEntry(
"fields", fieldNames_);
191 flowDir_.normalise();
193 if (fieldNames_.size() != 1)
196 <<
"Source can only be applied to a single field. Current "
203 <<
type() <<
" " << this->
name() <<
": "
204 <<
" Unknown face zone name: " << faceZoneName_
205 <<
". Valid face zones are: " << mesh_.faceZones().names()
209 if (model_ == pVolumetricFlowRateTable)
213 else if (model_ == pConstant)
215 coeffs_.readEntry(
"pressureDrop", pressureDrop_);
217 else if (model_ == pDarcyForchheimer)
219 coeffs_.readEntry(
"D", D_);
220 coeffs_.readEntry(
"I", I_);
221 coeffs_.readEntry(
"length", length_);
226 <<
"Did not find mode " << model_
228 <<
"Please set 'model' to one of "
229 << pressureDropModelNames_
233 applied_.setSize(fieldNames_.size(),
false);
238 mesh_.time().timePath()/
"uniform"/(name_ +
"Properties")
241 if (propsFile.
good())
243 Info<<
" Reading pressure gradient from file" <<
endl;
245 propsDict.readEntry(
"gradient", gradP0_);
248 Info<<
" Initial pressure gradient = " << gradP0_ <<
nl <<
endl;
270 case pDarcyForchheimer:
282 gradPporous_ = -flowDir_*(D_*
nu + I_*0.5*magUn)*magUn*length_;
297 - flowDir_*(D_*
mu + I_*0.5*
rho*magUn)*magUn*length_;
303 gradPporous_ = -flowDir_*pressureDrop_;
307 case pVolumetricFlowRateTable:
309 scalar volFlowRate = 0;
314 label faceI = faceId_[i];
315 if (facePatchId_[i] != -1)
317 label patchI = facePatchId_[i];
318 totalphi +=
phi.boundaryField()[patchI][faceI];
322 totalphi +=
phi[faceI];
329 volFlowRate =
mag(totalphi);
341 volFlowRate =
mag(totalphi)/rhoAve;
344 gradPporous_ = -flowDir_*flowRate_(volFlowRate);
349 const faceZone& fZone = mesh_.faceZones()[zoneID_];
351 labelList meshToLocal(mesh_.nCells(), -1);
354 meshToLocal[cells_[i]] = i;
357 labelList faceToCellIndex(fZone.size(), -1);
363 label masterCellI = mc[i];
365 if (meshToLocal[masterCellI] != -1 && masterCellI != -1)
367 faceToCellIndex[i] = meshToLocal[masterCellI];
369 else if (meshToLocal[masterCellI] == -1)
372 <<
"Did not find cell " << masterCellI
373 <<
"in cellZone :" << cellSetName()
386 forAll(
U.boundaryField(), patchI)
394 else if (!isA<emptyFvPatchScalarField>(pf))
402 label faceI = fZone[i];
407 label sourceCellId = sc[i];
408 if (mesh_.isInternalFace(faceI))
410 scalar w = mesh_.magSf()[faceI];
411 UfCells[
cellId] +=
U[sourceCellId]*w;
412 UfCellWeights[
cellId] += w;
416 label patchI = pbm.patchID()[faceI-mesh_.nInternalFaces()];
417 label localFaceI = pbm[patchI].whichFace(faceI);
419 scalar w = mesh_.magSf().boundaryField()[patchI][localFaceI];
421 if (upwindValues.set(patchI))
423 UfCells[
cellId] += upwindValues[patchI][localFaceI]*w;
424 UfCellWeights[
cellId] += w;
430 UfCells /= UfCellWeights;
434 label cellI = cells_[i];
436 const vector Ufnorm = UfCells[i]/(
mag(UfCells[i]) + SMALL);
443 (
D & UfCells[i]) -
U[cellI]
449 Info<<
"Difference mag(U) = "
450 <<
mag(UfCells[i]) -
mag(
U[cellI])
452 Info<<
"Pressure drop in flowDir direction : "
453 << gradPporous_[i] <<
endl;
454 Info<<
"UfCell:= " << UfCells[i] <<
"U : " <<
U[cellI] <<
endl;
457 writeProps(gradP0_ + dGradP_);
471 name_ + fieldNames_[fieldI] +
"Sup",
472 mesh_.time().timeName(),
494 this->addSup(eqn, fieldI);
504 if (invAPtr_.empty())
513 mesh_.time().timeName(),
524 invAPtr_() = 1.0/eqn.
A();
551 coeffs.readEntry(
"flowDir", flowDir_);
552 flowDir_.normalise();
554 if (model_ == pConstant)
556 coeffs.readEntry(
"pressureDrop", pressureDrop_);
558 else if (model_ == pDarcyForchheimer)
560 coeffs.readEntry(
"D", D_);
561 coeffs.readEntry(
"I", I_);
562 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...
A class for handling words, derived from Foam::string.
Cell-set options abtract base class. Provides a base set of controls, e.g.:
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.
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)
T lookupOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
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))
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
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.
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.
defineTypeNameAndDebug(option, 0)
const labelList & masterCells() const
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
addToRunTimeSelectionTable(option, fixedTemperatureConstraint, dictionary)
virtual tmp< volScalarField > nu() const
Return the laminar viscosity.
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....
tmp< volScalarField > rAU
A List with indirect addressing.
Templated abstract base class for single-phase incompressible turbulence models.
virtual void writeData(Ostream &os) const
Write the source properties.
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)
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...