48 turbulentTemperatureRadCoupledMixedFvPatchScalarField::getOrCreateField
53 const fvMesh&
mesh =
patch().boundaryMesh().mesh();
64 mesh.time().timeName(),
80 void turbulentTemperatureRadCoupledMixedFvPatchScalarField::storeHTCFields
90 htc.boundaryFieldRef()[
patch().index()] = shtc;
94 htcPatch.boundaryFieldRef()[
patch().index()] = shtcPatch;
98 void turbulentTemperatureRadCoupledMixedFvPatchScalarField::writeFileHeader
131 mixedFvPatchScalarField(
p, iF),
138 functionObjects::writeFile
141 "turbulentTemperatureRadCoupledMixed",
145 TnbrName_(
"undefined-Tnbr"),
146 qrNbrName_(
"undefined-qrNbr"),
147 qrName_(
"undefined-qr"),
150 thermalInertia_(false),
154 this->refValue() =
Zero;
155 this->refGrad() =
Zero;
156 this->valueFraction() = 1.0;
157 this->source() = 0.0;
170 mixedFvPatchScalarField(psf,
p, iF, mapper),
178 functionObjects::writeFile(psf),
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),
210 functionObjects::writeFile
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"))
226 if (!isA<mappedPatchBase>(this->
patch().
patch()))
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"))
338 mixedFvPatchScalarField(psf, iF),
346 functionObjects::writeFile(psf),
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),
376 functionObjects::writeFile(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);
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()
485 refCast<const fvMesh>(nbrMesh).
boundary()[samplePatchi];
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 =
552 refCast<const fvMesh>(nbrMesh).
boundary()[samplePatchi];
566 <<
"thermalInertia not supported in combination with multi-world" 571 const scalar dt =
mesh.time().deltaTValue();
577 const basicThermo*
thermo =
583 const fvPatch& nbrPatch =
584 refCast<const fvMesh>(nbrMesh).
boundary()[samplePatchi];
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()
636 const fvPatchField<scalar>& TpOld =
T.oldTime().boundaryField()[patchi];
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];
693 const scalar aveHtc =
gSum(htc*
patch().magSf())/
max(magSf, SMALL);
702 if (
mag(deltaTPatch[i]) > SMALL)
704 htcPatch[i] = qField[i]/deltaTPatch[i];
707 const scalar aveHtcPatch =
714 const scalar TpNbrAvg =
gAverage(TpNbr);
718 <<
patch().boundaryMesh().mesh().name() <<
':' 719 <<
patch().name() <<
':' 720 << this->internalField().name() <<
" <- " 723 << this->internalField().name() <<
" :" <<
nl 724 <<
" Heat transfer rate [W]:" << Q <<
nl 725 <<
" Area [m^2]:" << magSf <<
nl 726 <<
" Heat flux [W/m^2]:" << q <<
nl 727 <<
" Area-averaged heat-transfer coefficient [W/m^2/K]:" 729 <<
" Area-averaged patch heat-transfer coefficient [W/m^2/K]:" 731 <<
" Wall temperature [K]" 732 <<
" min:" << TpMinMax.min()
733 <<
" max:" << TpMinMax.max()
734 <<
" avg:" << TpAvg <<
nl 735 <<
" Neighbour wall temperature [K]" 736 <<
" min:" << TpNbrMinMax.min()
737 <<
" max:" << TpNbrMinMax.max()
738 <<
" avg:" << TpNbrAvg
750 writeFileHeader(
file());
756 << db().time().timeOutputValue() <<
token::TAB 772 storeHTCFields(prefix_, htc, htcPatch);
787 <<
"This T BC does not support energy coupling " 788 <<
"It is implemented on he field " 793 tmp<Field<scalar>> turbulentTemperatureRadCoupledMixedFvPatchScalarField::coeffs
795 fvMatrix<scalar>& matrix,
796 const Field<scalar>& coeffs,
801 <<
"This BC does not support energy coupling " 802 <<
"Use compressible::turbulentTemperatureRadCoupledMixed " 803 <<
"which has more functionalities and it can handle " 804 <<
"the assemble coupled option for energy. " 812 turbulentTemperatureRadCoupledMixedFvPatchScalarField::alphaSfDelta()
const 818 tmp<scalarField> turbulentTemperatureRadCoupledMixedFvPatchScalarField::
821 const mappedPatchBase& mpp =
822 refCast<const mappedPatchBase>(
patch().patch());
824 if (!mpp.sameWorld())
827 <<
"coupled energy not supported in combination with multi-world" 831 const label samplePatchi = mpp.samplePolyPatch().index();
832 const polyMesh& nbrMesh = mpp.sampleMesh();
834 const fvPatch& nbrPatch =
835 refCast<const fvMesh>(nbrMesh).
boundary()[samplePatchi];
846 mpp.distribute(TcNbr);
850 nbrField.alpha(TcNbr)*nbrPatch.deltaCoeffs()
852 mpp.distribute(alphaDeltaNbr);
859 return (alphaDeltaNbr + alphaDelta);
863 tmp<scalarField> turbulentTemperatureRadCoupledMixedFvPatchScalarField::
866 const mappedPatchBase& mpp =
867 refCast<const mappedPatchBase>(
patch().patch());
869 if (!mpp.sameWorld())
872 <<
"coupled energy not supported in combination with multi-world" 876 const polyMesh& nbrMesh = mpp.sampleMesh();
878 const basicThermo* nbrThermo =
881 const polyMesh&
mesh =
patch().boundaryMesh().mesh();
883 const basicThermo* localThermo =
887 if (nbrThermo && localThermo)
889 const label patchi =
patch().index();
890 const scalarField&
pp = localThermo->p().boundaryField()[patchi];
893 const mappedPatchBase& mpp =
894 refCast<const mappedPatchBase>(
patch().patch());
896 const label patchiNrb = mpp.samplePolyPatch().index();
898 const scalarField& ppNbr = nbrThermo->p().boundaryField()[patchiNrb];
908 - localThermo->he(
pp, Tp, patchi)
909 + nbrThermo->he(ppNbr, Tp, patchiNrb)
915 <<
"Can't find thermos on mapped patch " 916 <<
" method, but thermo package not available" 924 bool turbulentTemperatureRadCoupledMixedFvPatchScalarField::writeFile()
926 if (!verbose_ || (logInterval_ <= 0))
931 const auto& time =
patch().boundaryMesh().mesh().time();
933 const scalar t = time.timeOutputValue();
934 const scalar ts = time.startTime().value();
935 const scalar deltaT = time.deltaTValue();
937 const label executionIndex = label
947 if (executionIndex > executionIndex_)
949 executionIndex_ = executionIndex;
964 os.writeEntryIfDifferent<
word>(
"Tnbr",
"T", TnbrName_);
965 os.writeEntryIfDifferent<
word>(
"qrNbr",
"none", qrNbrName_);
966 os.writeEntryIfDifferent<
word>(
"qr",
"none", qrName_);
967 os.writeEntry<scalar>(
"logInterval", logInterval_);
971 os.writeEntry(
"thermalInertia", thermalInertia_);
973 os.writeEntryIfDifferent<
bool>(
"verbose",
false, verbose_);
974 os.writeEntryIfDifferent<word>(
"prefix",
"multiWorld", prefix_);
978 thicknessLayer_().writeData(
os);
979 kappaLayer_().writeData(
os);
981 if (thicknessLayers_.
size())
1003 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) to Type reference.
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...
bool store()
Register object with its registry and transfer ownership to the registry.
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.
Request registration (bool: true)
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.