48turbulentTemperatureRadCoupledMixedFvPatchScalarField::getOrCreateField
53 const fvMesh&
mesh =
patch().boundaryMesh().mesh();
64 mesh.time().timeName(),
80void turbulentTemperatureRadCoupledMixedFvPatchScalarField::storeHTCFields
90 htc.boundaryFieldRef()[
patch().index()] = shtc;
94 htcPatch.boundaryFieldRef()[
patch().index()] = shtcPatch;
98void turbulentTemperatureRadCoupledMixedFvPatchScalarField::writeFileHeader
131 mixedFvPatchScalarField(
p, iF),
141 "turbulentTemperatureRadCoupledMixed",
145 TnbrName_(
"undefined-Tnbr"),
146 qrNbrName_(
"undefined-qrNbr"),
147 qrName_(
"undefined-qr"),
150 thermalInertia_(false),
155 this->refGrad() =
Zero;
156 this->valueFraction() = 1.0;
157 this->source() = 0.0;
170 mixedFvPatchScalarField(psf,
p, iF, mapper),
179 TnbrName_(psf.TnbrName_),
180 qrNbrName_(psf.qrNbrName_),
181 qrName_(psf.qrName_),
182 thicknessLayers_(psf.thicknessLayers_),
183 thicknessLayer_(psf.thicknessLayer_.clone(
p.patch())),
184 kappaLayers_(psf.kappaLayers_),
185 kappaLayer_(psf.kappaLayer_.clone(
p.patch())),
186 logInterval_(psf.logInterval_),
187 executionIndex_(psf.executionIndex_),
188 thermalInertia_(psf.thermalInertia_),
189 verbose_(psf.verbose_),
202 mixedFvPatchScalarField(
p, iF),
213 "turbulentTemperatureRadCoupledMixed",
217 TnbrName_(
dict.getOrDefault<
word>(
"Tnbr",
"T")),
218 qrNbrName_(
dict.getOrDefault<
word>(
"qrNbr",
"none")),
219 qrName_(
dict.getOrDefault<
word>(
"qr",
"none")),
220 logInterval_(
dict.getOrDefault<scalar>(
"logInterval", -1)),
222 thermalInertia_(
dict.getOrDefault<
Switch>(
"thermalInertia", false)),
223 verbose_(
dict.getOrDefault<bool>(
"verbose", false)),
224 prefix_(
dict.getOrDefault<
word>(
"prefix",
"multiWorld"))
229 <<
"' not type '" << mappedPatchBase::typeName <<
"'"
230 <<
"\n for patch " <<
p.name()
231 <<
" of field " << internalField().name()
232 <<
" in file " << internalField().objectPath()
278 if (
dict.readIfPresent(
"thicknessLayers", thicknessLayers_))
280 dict.readEntry(
"kappaLayers", kappaLayers_);
291 kappaLayer_ = PatchFunction1<scalar>::New
301 if (this->readMixedEntries(
dict))
310 valueFraction() = 1.0;
314 if (
dict.readIfPresent(
"useImplicit", boolVal))
316 this->useImplicit(boolVal);
318 if (
dict.found(
"source"))
327 writeFile::read(
dict);
334 const turbulentTemperatureRadCoupledMixedFvPatchScalarField& psf,
338 mixedFvPatchScalarField(psf, iF),
347 TnbrName_(psf.TnbrName_),
348 qrNbrName_(psf.qrNbrName_),
349 qrName_(psf.qrName_),
350 thicknessLayers_(psf.thicknessLayers_),
351 thicknessLayer_(psf.thicknessLayer_.clone(patch().patch())),
352 kappaLayers_(psf.kappaLayers_),
353 kappaLayer_(psf.kappaLayer_.clone(patch().patch())),
354 logInterval_(psf.logInterval_),
355 executionIndex_(psf.executionIndex_),
356 thermalInertia_(psf.thermalInertia_),
357 verbose_(psf.verbose_),
368 mixedFvPatchScalarField(psf),
377 TnbrName_(psf.TnbrName_),
378 qrNbrName_(psf.qrNbrName_),
379 qrName_(psf.qrName_),
380 thicknessLayers_(psf.thicknessLayers_),
381 thicknessLayer_(psf.thicknessLayer_.clone(patch().patch())),
382 kappaLayers_(psf.kappaLayers_),
383 kappaLayer_(psf.kappaLayer_.clone(patch().patch())),
384 logInterval_(psf.logInterval_),
385 executionIndex_(psf.executionIndex_),
386 thermalInertia_(psf.thermalInertia_),
387 verbose_(psf.verbose_),
399 mixedFvPatchScalarField::autoMap(
mapper);
404 thicknessLayer_().autoMap(
mapper);
405 kappaLayer_().autoMap(
mapper);
416 mixedFvPatchScalarField::rmap(ptf, addr);
428 thicknessLayer_().rmap(tiptf.thicknessLayer_(), addr);
429 kappaLayer_().rmap(tiptf.kappaLayer_(), addr);
461 const label patchi = patch().index();
466 this->internalField()
473 const scalarField KDelta(kappaTp*patch().deltaCoeffs());
494 TcNbr = nbrField.patchInternalField();
496 KDeltaNbr = nbrField.kappa(nbrField)*nbrPatch.
deltaCoeffs();
502 TcNbr = patchInternalField();
511 if (thicknessLayer_ || thicknessLayers_.size())
519 const scalar t = db().time().timeOutputValue();
521 thicknessLayer_().value(t)
522 /kappaLayer_().value(t);
525 if (thicknessLayers_.size())
527 forAll(thicknessLayers_, iLayer)
529 KDeltaC += thicknessLayers_[iLayer]/kappaLayers_[iLayer];
532 KDeltaC = 1.0/(KDeltaC + SMALL);
539 if (qrName_ !=
"none")
545 if (qrNbrName_ !=
"none")
551 const fvPatch& nbrPatch =
566 <<
"thermalInertia not supported in combination with multi-world"
571 const scalar dt =
mesh.time().deltaTValue();
577 const basicThermo*
thermo =
583 const fvPatch& nbrPatch =
586 thermo->p().boundaryField()[samplePatchi];
588 thermo->
T().boundaryField()[samplePatchi];
592 thermo->Cp(ppn, Tpn, samplePatchi)
593 *
thermo->rho(samplePatchi)
594 / nbrPatch.deltaCoeffs()/dt
609 const basicThermo*
thermo =
620 /
patch().deltaCoeffs()/dt
633 this->internalField().name()
641 scalarField c(KDeltaNbr*TcNbr + (mCpDt + mCpDtNbr)*TpOld);
643 refGrad() = (qr + qrNbr)/kappaTp;
648 valueFraction() = KDeltaNbr/(KDeltaNbr +
alpha);
650 refGrad() = (qr + qrNbr)/kappaTp;
656 if (this->useImplicit())
661 valueFraction()*deltaH()
662 + (qr + qrNbr)/beta()
666 mixedFvPatchScalarField::updateCoeffs();
673 const scalar magSf =
gSum(
patch().magSf());
674 const scalar q = Q/
max(magSf, SMALL);
688 if (
mag(deltaT[i]) > SMALL)
690 htc[i] = qField[i]/deltaT[i];
702 if (
mag(deltaTPatch[i]) > SMALL)
704 htcPatch[i] = qField[i]/deltaTPatch[i];
713 const scalar TpNbrAvg =
gAverage(TpNbr);
717 <<
patch().boundaryMesh().mesh().name() <<
':'
718 <<
patch().name() <<
':'
719 << this->internalField().name() <<
" <- "
722 << this->internalField().name() <<
" :" <<
nl
723 <<
" Heat transfer rate [W]:" << Q <<
nl
724 <<
" Area [m^2]:" << magSf <<
nl
725 <<
" Heat flux [W/m^2]:" << q <<
nl
726 <<
" Area-averaged heat-transfer coefficient [W/m^2/K]:"
728 <<
" Area-averaged patch heat-transfer coefficient [W/m^2/K]:"
730 <<
" Wall temperature [K]"
731 <<
" min:" << TpMinMax.min()
732 <<
" max:" << TpMinMax.max()
733 <<
" avg:" << TpAvg <<
nl
734 <<
" Neighbour wall temperature [K]"
735 <<
" min:" << TpNbrMinMax.min()
736 <<
" max:" << TpNbrMinMax.max()
737 <<
" avg:" << TpNbrAvg
749 writeFileHeader(
file());
755 << db().time().timeOutputValue() <<
token::TAB
771 storeHTCFields(prefix_, htc, htcPatch);
786 <<
"This T BC does not support energy coupling "
787 <<
"It is implemented on he field "
792tmp<Field<scalar>> turbulentTemperatureRadCoupledMixedFvPatchScalarField::coeffs
794 fvMatrix<scalar>& matrix,
795 const Field<scalar>& coeffs,
800 <<
"This BC does not support energy coupling "
801 <<
"Use compressible::turbulentTemperatureRadCoupledMixed "
802 <<
"which has more functionalities and it can handle "
803 <<
"the assemble coupled option for energy. "
811turbulentTemperatureRadCoupledMixedFvPatchScalarField::alphaSfDelta()
const
817tmp<scalarField> turbulentTemperatureRadCoupledMixedFvPatchScalarField::
820 const mappedPatchBase& mpp =
823 if (!mpp.sameWorld())
826 <<
"coupled energy not supported in combination with multi-world"
830 const label samplePatchi = mpp.samplePolyPatch().index();
831 const polyMesh& nbrMesh = mpp.sampleMesh();
833 const fvPatch& nbrPatch =
845 mpp.distribute(TcNbr);
849 nbrField.alpha(TcNbr)*nbrPatch.deltaCoeffs()
851 mpp.distribute(alphaDeltaNbr);
858 return (alphaDeltaNbr + alphaDelta);
862tmp<scalarField> turbulentTemperatureRadCoupledMixedFvPatchScalarField::
865 const mappedPatchBase& mpp =
868 if (!mpp.sameWorld())
871 <<
"coupled energy not supported in combination with multi-world"
875 const polyMesh& nbrMesh = mpp.sampleMesh();
877 const basicThermo* nbrThermo =
880 const polyMesh&
mesh =
patch().boundaryMesh().mesh();
882 const basicThermo* localThermo =
886 if (nbrThermo && localThermo)
888 const label patchi =
patch().index();
889 const scalarField&
pp = localThermo->p().boundaryField()[patchi];
892 const mappedPatchBase& mpp =
895 const label patchiNrb = mpp.samplePolyPatch().index();
897 const scalarField& ppNbr = nbrThermo->p().boundaryField()[patchiNrb];
907 - localThermo->he(
pp, Tp, patchi)
908 + nbrThermo->he(ppNbr, Tp, patchiNrb)
914 <<
"Can't find thermos on mapped patch "
915 <<
" method, but thermo package not available"
923bool turbulentTemperatureRadCoupledMixedFvPatchScalarField::writeFile()
925 if (!verbose_ || (logInterval_ <= 0))
930 const auto& time =
patch().boundaryMesh().mesh().time();
932 const scalar t = time.timeOutputValue();
933 const scalar ts = time.startTime().value();
934 const scalar deltaT = time.deltaTValue();
936 const label executionIndex = label
946 if (executionIndex > executionIndex_)
948 executionIndex_ = executionIndex;
963 os.writeEntryIfDifferent<
word>(
"Tnbr",
"T", TnbrName_);
964 os.writeEntryIfDifferent<
word>(
"qrNbr",
"none", qrNbrName_);
965 os.writeEntryIfDifferent<
word>(
"qr",
"none", qrName_);
966 os.writeEntry<scalar>(
"logInterval", logInterval_);
970 os.writeEntry(
"thermalInertia", thermalInertia_);
972 os.writeEntryIfDifferent<
bool>(
"verbose",
false, verbose_);
973 os.writeEntryIfDifferent<word>(
"prefix",
"multiWorld",
prefix_);
977 thicknessLayer_().writeData(
os);
978 kappaLayer_().writeData(
os);
980 if (thicknessLayers_.size())
982 thicknessLayers_.writeEntry(
"thicknessLayers",
os);
983 kappaLayers_.writeEntry(
"kappaLayers",
os);
1002 turbulentTemperatureRadCoupledMixedFvPatchScalarField
Macros for easy insertion into run-time selection tables.
writer write("magLe", fld)
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
tmp< Field< Type > > T() const
Return the field transpose (only defined for second rank tensors).
const GeometricField< Type, PatchField, GeoMesh > & oldTime() const
Return old time field.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
@ REGISTER
Request registration (bool: true).
@ NO_READ
Nothing to be read.
@ MUST_READ
Reading required.
@ AUTO_WRITE
Automatically write from objectRegistry::writeObject().
static word scopedName(const std::string &scope, const word &name)
Create scope:name or scope_name string.
void setSize(label n)
Alias for resize().
const T & max() const noexcept
The max value.
const T & min() const noexcept
The min value.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static autoPtr< PatchFunction1< Type > > NewIfPresent(const polyPatch &pp, const word &entryName, const dictionary &dict, const bool faceValues=true)
An optional selector.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
void size(const label n)
Older name for setAddressableSize.
static int & msgType() noexcept
Message tag of standard messages.
static int incrMsgType(int val=1) noexcept
Increment the message tag for standard messages.
Abstract base-class for fluid and solid thermodynamic properties.
static const word dictName
The dictionary name ("thermophysicalProperties").
Mixed boundary condition for temperature and radiation heat transfer, suitable for multiregion cases....
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual tmp< fvPatchField< scalar > > clone() const
Return a clone.
virtual tmp< scalarField > kappa(const scalarField &Tp) const
Given patch temperature calculate corresponding K field. Override temperatureCoupledBase::kappa to in...
virtual void rmap(const fvPatchField< scalar > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual void write(Ostream &os) const
Write.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void manipulateMatrix(fvMatrix< scalar > &m, const label iMatrix, const direction cmpt)
Manipulate matrix.
turbulentTemperatureRadCoupledMixedFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool updateHeader_
Flag to update the header, e.g. on mesh changes. Default is true.
label writePrecision_
Write precision.
virtual void writeTabbed(Ostream &os, const string &str) const
Write a tabbed string to stream.
virtual bool canWriteToFile() const
Flag to allow writing to the file.
bool useUserTime_
Flag to use the specified user time, e.g. CA deg instead of seconds. Default = true.
const fileName prefix_
Prefix.
bool writeToFile_
Flag to enable/disable writing to file.
bool writtenHeader_
Flag to identify whether the header has been written.
virtual OFstream & file()
Return access to the file (if only 1).
virtual void writeCommented(Ostream &os, const string &str) const
Write a commented string to stream.
virtual void resetFile(const word &name)
Reset internal file pointer to new file with new name.
virtual bool canWriteHeader() const
Flag to allow writing the header.
virtual bool canResetFile() const
Flag to allow resetting the file.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
A FieldMapper for finite-volume patch fields.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
const scalarField & deltaCoeffs() const
Return the face - cell distance coefficient except for coupled patches for which the cell-centre to c...
const GeometricField::Patch & lookupPatchField(const word &name) const
Lookup the named field from the local registry and return the patch field corresponding to this patch...
Determines a mapping between patch face centres and mesh cell or face centres and processors they're ...
const polyMesh & sampleMesh() const
Get the region mesh.
const polyPatch & samplePolyPatch() const
Get the patch on the region.
void distribute(List< Type > &lst) const
Wrapper around map/interpolate data distribution.
const word & samplePatch() const
Patch (only if NEARESTPATCHFACE).
const word & sampleRegion() const
Region to sample.
bool sameWorld() const
Is sample world the local world?
Functionality for sampling fields using mappedPatchBase. Every call to mappedField() returns a sample...
virtual void write(Ostream &os) const
Write.
static const mappedPatchBase & mapper(const fvPatch &p, const DimensionedField< scalar, volMesh > &iF)
mappedPatchFieldBase(const mappedPatchBase &mapper, const fvPatchField< scalar > &patchField, const word &fieldName, const bool setAverage, const scalar average, const word &interpolationScheme)
void distribute(const word &fieldName, Field< T > &newValues) const
virtual void write(Ostream &) const
Write.
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
label index() const noexcept
The index of this patch in the boundaryMesh.
Mesh consisting of general polyhedral cells.
bool store()
Register object with its registry and transfer ownership to the registry.
Common functions used in temperature coupled boundaries.
virtual tmp< scalarField > alpha(const scalarField &Tp) const
Given patch temperature calculate corresponding alphaEff field.
virtual void autoMap(const fvPatchFieldMapper &)=0
Map (and resize as needed) from self given a mapping object.
void write(Ostream &os) const
Write.
virtual void rmap(const fvPatchField< scalar > &, const labelList &)=0
Reverse map the given fvPatchField onto this fvPatchField.
virtual tmp< scalarField > kappa(const scalarField &Tp) const
Given patch temperature calculate corresponding K field.
temperatureCoupledBase(const fvPatch &patch, const KMethodType method=KMethodType::mtFluidThermo)
Default construct from patch, using fluidThermo (default) or specified method.
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define makePatchTypeField(PatchTypeField, typePatchTypeField)
Define a concrete fvPatchField type and add to run-time tables Example, (fvPatchScalarField,...
const dimensionedScalar c
Speed of light in a vacuum.
const std::string patch
OpenFOAM patch number as a std::string.
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > snGrad(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Type gAverage(const FieldField< Field, Type > &f, const label comm)
The global arithmetic average of a FieldField.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Type gSum(const FieldField< Field, Type > &f)
const dimensionSet dimless
Dimensionless.
Type gWeightedAverage(const UList< scalar > &weights, const UList< Type > &fld, const label comm)
The global weighted average of a field, using the mag() of the weights.
List< label > labelList
A List of labels.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
messageStream Info
Information stream (stdout output on master, null elsewhere).
MinMax< scalar > scalarMinMax
A scalar min/max range.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
fvPatchField< scalar > fvPatchScalarField
constexpr char nl
The newline '\n' character (0x0a).
psiReactionThermo & thermo
#define forAll(list, i)
Loop across all elements in list.