29 #include "surfaceInterpolate.H" 42 effectivenessHeatExchangerSource,
51 void Foam::fv::effectivenessHeatExchangerSource::readCoeffs()
53 secondaryMassFlowRate_ = coeffs().lookup<scalar>(
"secondaryMassFlowRate");
54 secondaryInletT_ = coeffs().lookup<scalar>(
"secondaryInletT");
55 primaryInletT_ = coeffs().lookup<scalar>(
"primaryInletT");
59 UName_ = coeffs().lookupOrDefault<word>(
"U",
"U");
60 TName_ = coeffs().lookupOrDefault<word>(
"T",
"T");
61 phiName_ = coeffs().lookupOrDefault<word>(
"phi",
"phi");
63 faceZoneName_ = coeffs().lookup<word>(
"faceZone");
67 void Foam::fv::effectivenessHeatExchangerSource::setZone()
69 zoneID_ =
mesh().faceZones().findZoneID(faceZoneName_);
73 <<
type() <<
" " << this->
name() <<
": " 74 <<
" Unknown face zone name: " << faceZoneName_
75 <<
". Valid face zones are: " <<
mesh().faceZones().names()
79 const faceZone& fZone =
mesh().faceZones()[zoneID_];
81 faceId_.setSize(fZone.size());
82 facePatchId_.setSize(fZone.size());
83 faceSign_.setSize(fZone.size());
88 const label facei = fZone[i];
90 label facePatchId = -1;
91 if (
mesh().isInternalFace(facei))
98 facePatchId =
mesh().boundaryMesh().whichPatch(facei);
99 const polyPatch& pp =
mesh().boundaryMesh()[facePatchId];
100 if (isA<coupledPolyPatch>(pp))
102 if (refCast<const coupledPolyPatch>(pp).owner())
104 faceId = pp.whichFace(facei);
111 else if (!isA<emptyPolyPatch>(pp))
113 faceId = facei - pp.start();
124 if (fZone.flipMap()[i])
126 faceSign_[
count] = -1;
130 faceSign_[
count] = 1;
133 facePatchId_[
count] = facePatchId;
137 faceId_.setSize(count);
138 facePatchId_.setSize(count);
139 faceSign_.setSize(count);
141 calculateTotalArea(faceZoneArea_);
145 void Foam::fv::effectivenessHeatExchangerSource::calculateTotalArea
153 const label facei = faceId_[i];
154 if (facePatchId_[i] != -1)
156 label patchi = facePatchId_[i];
157 area +=
mesh().magSf().boundaryField()[
patchi][facei];
161 area +=
mesh().magSf()[facei];
164 reduce(area, sumOp<scalar>());
173 const word& modelType,
178 fvModel(name, modelType, dict, mesh),
179 set_(coeffs(), mesh),
180 secondaryMassFlowRate_(NaN),
181 secondaryInletT_(NaN),
214 const word& fieldName
229 label facei = faceId_[i];
230 if (facePatchId_[i] != -1)
232 label patchi = facePatchId_[i];
236 Cpf.boundaryField()[
patchi][facei]
237 *
mesh().magSf().boundaryField()[
patchi][facei];
241 totalphi += phi[facei]*faceSign_[i];
242 CpfMean += Cpf[facei]*
mesh().magSf()[facei];
249 eTable_->value(
mag(totalphi), secondaryMassFlowRate_)
250 *(secondaryInletT_ - primaryInletT_)
251 *(CpfMean/faceZoneArea_)*
mag(totalphi);
274 deltaTCells[i] =
max(Tref - TCells[i], 0.0);
278 deltaTCells[i] =
max(TCells[i] - Tref, 0.0);
284 scalar sumWeight = 0;
288 sumWeight += V[cells[i]]*
mag(U[cells[i]])*deltaTCells[i];
292 if (set_.V() > vSmall &&
mag(Qt) > vSmall)
298 heSource[cells[i]] -=
299 Qt*V[cells[i]]*
mag(U[cells[i]])*deltaTCells[i]/sumWeight;
305 Info<<
indent <<
"Net mass flux [Kg/s] = " << totalphi <<
nl;
306 Info<<
indent <<
"Total energy exchange [W] = " << Qt <<
nl;
309 << eTable_->value(
mag(totalphi), secondaryMassFlowRate_) <<
endl;
319 set_.updateMesh(mpm);
effectivenessHeatExchangerSource(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
defineTypeNameAndDebug(fixedTemperatureConstraint, 0)
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const word & name() const
Return name.
fluidReactionThermo & thermo
Base-class for fluid and solid thermodynamic properties.
Ostream & indent(Ostream &os)
Indent stream.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
virtual bool read(const dictionary &dict)
Read dictionary.
static autoPtr< Function2< scalar > > New(const word &name, const dictionary &dict)
Selector.
void size(const label)
Override size to be inconsistent with allocated storage.
virtual bool read(const dictionary &dict)
Read source dictionary.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool master(const label communicator=0)
Am I the master process.
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
Finite volume model abstract base class.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Macros for easy insertion into run-time selection tables.
virtual volScalarField & he()=0
Enthalpy/Internal energy [J/kg].
A class for handling words, derived from string.
static const word null
An empty word.
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.
static const word dictName
Name of the thermophysical properties dictionary.
virtual wordList addSupFields() const
Return the list of fields for which the fvModel adds source term.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
virtual tmp< volScalarField > Cp() const =0
Heat capacity at constant pressure [J/kg/K].
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
word name(const complex &)
Return a string representation of a complex.
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
addToRunTimeSelectionTable(fvConstraint, fixedTemperatureConstraint, dictionary)
List< word > wordList
A List of words.
Mesh data needed to do the Finite Volume discretisation.
virtual void updateMesh(const mapPolyMesh &)
Update for mesh changes.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
dimensioned< scalar > mag(const dimensioned< Type > &)
virtual void addSup(const volScalarField &rho, fvMatrix< scalar > &eqn, const word &fieldName) const
Explicit and implicit source for compressible equation.