48 turbulentTemperatureRadCoupledMixedFvPatchScalarField::getOrCreateField
53 const fvMesh&
mesh =
patch().boundaryMesh().mesh();
64 mesh.time().timeName(),
72 mesh.objectRegistry::store(ptr);
79 void turbulentTemperatureRadCoupledMixedFvPatchScalarField::storeHTCFields
89 htc.boundaryFieldRef()[
patch().index()] = shtc;
93 htcPatch.boundaryFieldRef()[
patch().index()] = shtcPatch;
97 void turbulentTemperatureRadCoupledMixedFvPatchScalarField::writeFileHeader
130 mixedFvPatchScalarField(
p, iF),
137 functionObjects::writeFile
140 "turbulentTemperatureRadCoupledMixed",
144 TnbrName_(
"undefined-Tnbr"),
145 qrNbrName_(
"undefined-qrNbr"),
146 qrName_(
"undefined-qr"),
149 thermalInertia_(false),
153 this->refValue() =
Zero;
154 this->refGrad() =
Zero;
155 this->valueFraction() = 1.0;
156 this->source() = 0.0;
169 mixedFvPatchScalarField(psf,
p, iF, mapper),
177 functionObjects::writeFile(psf),
178 TnbrName_(psf.TnbrName_),
179 qrNbrName_(psf.qrNbrName_),
180 qrName_(psf.qrName_),
181 thicknessLayers_(psf.thicknessLayers_),
182 thicknessLayer_(psf.thicknessLayer_.clone(
p.
patch())),
183 kappaLayers_(psf.kappaLayers_),
184 kappaLayer_(psf.kappaLayer_.clone(
p.
patch())),
185 logInterval_(psf.logInterval_),
186 executionIndex_(psf.executionIndex_),
187 thermalInertia_(psf.thermalInertia_),
188 verbose_(psf.verbose_),
201 mixedFvPatchScalarField(
p, iF),
209 functionObjects::writeFile
212 "turbulentTemperatureRadCoupledMixed",
216 TnbrName_(
dict.getOrDefault<
word>(
"Tnbr",
"T")),
217 qrNbrName_(
dict.getOrDefault<
word>(
"qrNbr",
"none")),
218 qrName_(
dict.getOrDefault<
word>(
"qr",
"none")),
219 logInterval_(
dict.getOrDefault<scalar>(
"logInterval", -1)),
221 thermalInertia_(
dict.getOrDefault<
Switch>(
"thermalInertia", false)),
222 verbose_(
dict.getOrDefault<bool>(
"verbose", false)),
223 prefix_(
dict.getOrDefault<
word>(
"prefix",
"multiWorld"))
225 if (!isA<mappedPatchBase>(this->
patch().
patch()))
228 <<
"' not type '" << mappedPatchBase::typeName <<
"'" 229 <<
"\n for patch " <<
p.name()
230 <<
" of field " << internalField().name()
231 <<
" in file " << internalField().objectPath()
277 if (
dict.readIfPresent(
"thicknessLayers", thicknessLayers_))
279 dict.readEntry(
"kappaLayers", kappaLayers_);
290 kappaLayer_ = PatchFunction1<scalar>::New
300 if (this->readMixedEntries(
dict))
309 valueFraction() = 1.0;
313 if (
dict.readIfPresent(
"useImplicit", boolVal))
315 this->useImplicit(boolVal);
317 if (
dict.found(
"source"))
337 mixedFvPatchScalarField(psf, iF),
345 functionObjects::writeFile(psf),
346 TnbrName_(psf.TnbrName_),
347 qrNbrName_(psf.qrNbrName_),
348 qrName_(psf.qrName_),
349 thicknessLayers_(psf.thicknessLayers_),
350 thicknessLayer_(psf.thicknessLayer_.clone(
patch().
patch())),
351 kappaLayers_(psf.kappaLayers_),
352 kappaLayer_(psf.kappaLayer_.clone(
patch().
patch())),
353 logInterval_(psf.logInterval_),
354 executionIndex_(psf.executionIndex_),
355 thermalInertia_(psf.thermalInertia_),
356 verbose_(psf.verbose_),
367 mixedFvPatchScalarField(psf),
375 functionObjects::writeFile(psf),
376 TnbrName_(psf.TnbrName_),
377 qrNbrName_(psf.qrNbrName_),
378 qrName_(psf.qrName_),
379 thicknessLayers_(psf.thicknessLayers_),
380 thicknessLayer_(psf.thicknessLayer_.clone(
patch().
patch())),
381 kappaLayers_(psf.kappaLayers_),
382 kappaLayer_(psf.kappaLayer_.clone(
patch().
patch())),
383 logInterval_(psf.logInterval_),
384 executionIndex_(psf.executionIndex_),
385 thermalInertia_(psf.thermalInertia_),
386 verbose_(psf.verbose_),
398 mixedFvPatchScalarField::autoMap(
mapper);
404 kappaLayer_().autoMap(
mapper);
415 mixedFvPatchScalarField::rmap(ptf, addr);
427 thicknessLayer_().rmap(tiptf.thicknessLayer_(), addr);
428 kappaLayer_().rmap(tiptf.kappaLayer_(), addr);
460 const label patchi =
patch().index();
465 this->internalField()
484 refCast<const fvMesh>(nbrMesh).
boundary()[samplePatchi];
493 TcNbr = nbrField.patchInternalField();
495 KDeltaNbr = nbrField.kappa(nbrField)*nbrPatch.deltaCoeffs();
501 TcNbr = patchInternalField();
510 if (thicknessLayer_ || thicknessLayers_.
size())
518 const scalar t = db().time().timeOutputValue();
520 thicknessLayer_().value(t)
521 /kappaLayer_().value(t);
524 if (thicknessLayers_.
size())
526 forAll(thicknessLayers_, iLayer)
528 KDeltaC += thicknessLayers_[iLayer]/kappaLayers_[iLayer];
531 KDeltaC = 1.0/(KDeltaC + SMALL);
538 if (qrName_ !=
"none")
544 if (qrNbrName_ !=
"none")
550 const fvPatch& nbrPatch =
551 refCast<const fvMesh>(nbrMesh).
boundary()[samplePatchi];
565 <<
"thermalInertia not supported in combination with multi-world" 570 const scalar dt =
mesh.time().deltaTValue();
576 const basicThermo*
thermo =
582 const fvPatch& nbrPatch =
583 refCast<const fvMesh>(nbrMesh).
boundary()[samplePatchi];
585 thermo->p().boundaryField()[samplePatchi];
587 thermo->T().boundaryField()[samplePatchi];
591 thermo->Cp(ppn, Tpn, samplePatchi)
592 *
thermo->rho(samplePatchi)
593 / nbrPatch.deltaCoeffs()/dt
608 const basicThermo*
thermo =
619 /
patch().deltaCoeffs()/dt
632 this->internalField().name()
635 const fvPatchField<scalar>& TpOld =
T.oldTime().boundaryField()[patchi];
640 scalarField c(KDeltaNbr*TcNbr + (mCpDt + mCpDtNbr)*TpOld);
642 refGrad() = (qr + qrNbr)/kappaTp;
647 valueFraction() = KDeltaNbr/(KDeltaNbr +
alpha);
649 refGrad() = (qr + qrNbr)/kappaTp;
655 if (this->useImplicit())
660 valueFraction()*deltaH()
661 + (qr + qrNbr)/beta()
665 mixedFvPatchScalarField::updateCoeffs();
672 const scalar magSf =
gSum(
patch().magSf());
673 const scalar q = Q/
max(magSf, SMALL);
687 if (
mag(deltaT[i]) > SMALL)
689 htc[i] = qField[i]/deltaT[i];
692 const scalar aveHtc =
gSum(htc*
patch().magSf())/
max(magSf, SMALL);
701 if (
mag(deltaTPatch[i]) > SMALL)
703 htcPatch[i] = qField[i]/deltaTPatch[i];
706 const scalar aveHtcPatch =
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 " 792 tmp<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. " 806 return tmp<Field<scalar>>(
new Field<scalar>());
811 turbulentTemperatureRadCoupledMixedFvPatchScalarField::alphaSfDelta()
const 817 tmp<scalarField> turbulentTemperatureRadCoupledMixedFvPatchScalarField::
820 const mappedPatchBase& mpp =
821 refCast<const mappedPatchBase>(
patch().patch());
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 =
834 refCast<const fvMesh>(nbrMesh).
boundary()[samplePatchi];
845 mpp.distribute(TcNbr);
849 nbrField.alpha(TcNbr)*nbrPatch.deltaCoeffs()
851 mpp.distribute(alphaDeltaNbr);
858 return (alphaDeltaNbr + alphaDelta);
862 tmp<scalarField> turbulentTemperatureRadCoupledMixedFvPatchScalarField::
865 const mappedPatchBase& mpp =
866 refCast<const mappedPatchBase>(
patch().patch());
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 =
893 refCast<const mappedPatchBase>(
patch().patch());
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" 923 bool 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())
1002 turbulentTemperatureRadCoupledMixedFvPatchScalarField
word dictName() const
The local dictionary name (final part of scoped name)
virtual void rmap(const fvPatchField< scalar > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual OFstream & file()
Return access to the file (if only 1)
void size(const label n)
Older name for setAddressableSize.
virtual bool canWriteToFile() const
Flag to allow writing to the file.
MinMax< scalar > scalarMinMax
A scalar min/max range.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static int incrMsgType(int val=1) noexcept
Increment the message tag for standard messages.
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...
static const mappedPatchBase & mapper(const fvPatch &p, const DimensionedField< scalar, volMesh > &iF)
Check that patch is of correct type.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
const polyMesh & sampleMesh() const
Get the region mesh.
virtual void write(Ostream &os) const
Write.
virtual void resetFile(const word &name)
Reset internal file pointer to new file with new name.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr char nl
The newline '\n' character (0x0a)
Type & refCast(U &obj)
A dynamic_cast (for references). Generates a FatalError on failed casts and uses the virtual type() m...
virtual tmp< scalarField > kappa(const scalarField &Tp) const
Given patch temperature calculate corresponding K field.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
virtual tmp< scalarField > alpha(const scalarField &Tp) const
Given patch temperature calculate corresponding alphaEff field.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, any/none. Also accepts 0/1 as a string and shortcuts t/f, y/n.
Mixed boundary condition for temperature and radiation heat transfer, suitable for multiregion cases...
virtual void rmap(const fvPatchField< scalar > &, const labelList &)=0
Reverse map the given fvPatchField onto this fvPatchField.
static int & msgType() noexcept
Message tag of standard messages.
const GeometricField::Patch & lookupPatchField(const word &name, const GeometricField *=nullptr, const AnyType *=nullptr) const
Lookup the named field from the local registry and return the patch field corresponding to this patch...
virtual void autoMap(const fvPatchFieldMapper &)=0
Map (and resize as needed) from self given a mapping object.
void write(Ostream &os) const
Write.
bool writtenHeader_
Flag to identify whether the header has been written.
const dimensionSet dimless
Dimensionless.
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
makePatchTypeField(fvPatchScalarField, alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
psiReactionThermo & thermo
virtual bool canResetFile() const
Flag to allow resetting the file.
virtual void writeCommented(Ostream &os, const string &str) const
Write a commented string to stream.
static word scopedName(const std::string &scope, const word &name)
Create scope:name or scope_name string.
bool sameWorld() const
Is sample world the local world?
Type gSum(const FieldField< Field, Type > &f)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
virtual bool canWriteHeader() const
Flag to allow writing the header.
fvPatchField< scalar > fvPatchScalarField
virtual void manipulateMatrix(fvMatrix< scalar > &m, const label iMatrix, const direction cmpt)
Manipulate matrix.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
A FieldMapper for finite-volume patch fields.
turbulentTemperatureRadCoupledMixedFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Determines a mapping between patch face centres and mesh cell or face centres and processors they're ...
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
errorManip< error > abort(error &err)
label writePrecision_
Write precision.
virtual tmp< scalarField > kappa(const scalarField &Tp) const
Given patch temperature calculate corresponding K field. Override temperatureCoupledBase::kappa to in...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
virtual void write(Ostream &os) const
Write.
OBJstream os(runTime.globalPath()/outputName)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Functionality for sampling fields using mappedPatchBase. Every call to mappedField() returns a sample...
void distribute(List< Type > &lst) const
Wrapper around map/interpolate data distribution.
bool writeToFile_
Flag to enable/disable writing to file.
Common functions used in temperature coupled boundaries.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Type gAverage(const FieldField< Field, Type > &f)
const dimensionedScalar c
Speed of light in a vacuum.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Automatically write from objectRegistry::writeObject()
bool useUserTime_
Flag to use the specified user time, e.g. CA deg instead of seconds. Default = true.
const std::string patch
OpenFOAM patch number as a std::string.
static autoPtr< PatchFunction1< Type > > NewIfPresent(const polyPatch &pp, const word &entryName, const dictionary &dict, const bool faceValues=true)
An optional selector.
bool updateHeader_
Flag to update the header, e.g. on mesh changes. Default is true.
messageStream Info
Information stream (stdout output on master, null elsewhere)
const word & samplePatch() const
Patch (only if NEARESTPATCHFACE)
void writeEntry(Ostream &os) const
Write the UList with its compound type.
virtual void write(Ostream &) const
Write.
Mesh consisting of general polyhedral cells.
label index() const noexcept
The index of this patch in the boundaryMesh.
A class for managing temporary objects.
const word & sampleRegion() const
Region to sample.
const polyPatch & samplePolyPatch() const
Get the patch on the region.
void distribute(const word &fieldName, Field< T > &newValues) const
Wrapper for mapDistribute::distribute that knows about dabase mapping.
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > snGrad(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
static constexpr const zero Zero
Global zero (0)
virtual void writeTabbed(Ostream &os, const string &str) const
Write a tabbed string to stream.