Loading...
Searching...
No Matches
heatExchangerSource.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2013-2015 OpenFOAM Foundation
9 Copyright (C) 2016-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "heatExchangerSource.H"
30#include "heatExchangerModel.H"
31#include "fvMatrix.H"
32#include "basicThermo.H"
35// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36
37namespace Foam
38{
39namespace fv
40{
43}
44}
45
46
47// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48
50(
51 const word& name,
52 const word& modelType,
53 const dictionary& dict,
54 const fvMesh& mesh
55)
56:
57 fv::cellSetOption(name, modelType, dict, mesh),
58 heatExchangerModelPtr_(heatExchangerModel::New(mesh, name, coeffs_))
59{
60 read(dict);
61
62 // Set the field name to that of the energy
63 // field from which the temperature is obtained
64
66
67 fieldNames_.resize(1, thermo.he().name());
68
71 heatExchangerModelPtr_->initialise();
72}
73
74
75// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
76
78(
79 const volScalarField& rho,
81 const label
82)
83{
84 const scalarField Q(heatExchangerModelPtr_->energyDensity(cells_));
85
86 if (this->V() > VSMALL)
87 {
88 const word& UName = heatExchangerModelPtr_->U();
89 const auto& U = mesh_.lookupObject<volVectorField>(UName);
90
91 const scalarField& V = mesh_.V();
92 scalarField& heSource = eqn.source();
93
94 forAll(cells_, i)
95 {
96 const label celli = cells_[i];
97 heSource[celli] -= Q[i]*V[celli]*mag(U[celli]);
98 }
99 }
100
101 heatExchangerModelPtr_->write(log);
102}
103
104
106{
107 if (!fv::cellSetOption::read(dict) || !heatExchangerModelPtr_->read(dict))
108 {
109 return false;
110 }
111
112 return true;
113}
114
115
116// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
const word UName(propsDict.getOrDefault< word >("U", "U"))
void resize(const label len)
Adjust allocated size of list.
Definition ListI.H:153
Abstract base-class for fluid and solid thermodynamic properties.
Definition basicThermo.H:62
static const word dictName
The dictionary name ("thermophysicalProperties").
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition fvMatrix.H:118
Field< Type > & source() noexcept
Definition fvMatrix.H:535
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
scalar V() const noexcept
Return const access to the total cell volume.
labelList cells_
Set of cells to apply source to.
virtual bool read(const dictionary &dict)
Read source dictionary.
cellSetOption(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Heat exchanger source model for compressible flows, where the heat exchanger is modelled as an energy...
virtual bool read(const dictionary &dict)
Read top-level dictionary.
virtual void addSup(fvMatrix< scalar > &eqn, const label fieldi)
Add explicit/implicit contribution to momentum equation.
heatExchangerSource(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Base abstract class for handling finite volume options (i.e. fvOption).
Definition fvOption.H:124
const word & name() const noexcept
Return const access to the source name.
Definition fvOptionI.H:24
const fvMesh & mesh_
Reference to the mesh database.
Definition fvOption.H:142
static autoPtr< option > New(const word &name, const dictionary &dict, const fvMesh &mesh)
Return a reference to the selected fvOption model.
Definition fvOption.C:78
wordList fieldNames_
Field names to apply source to - populated by derived models.
Definition fvOption.H:157
dictionary coeffs_
Dictionary containing source coefficients.
Definition fvOption.H:152
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
Definition fvOption.C:41
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition fvOptionI.H:30
bool log
Switch write log to Info.
Definition fvOption.H:183
Base class for heat exchanger models to handle various characteristics for the heatExchangerSource fv...
const Type & lookupObject(const word &name, const bool recursive=false) const
Lookup and return const reference to the object of the given Type. Fatal if not found or the wrong ty...
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
U
Definition pEqn.H:72
dynamicFvMesh & mesh
Namespace for finite-volume.
Namespace for OpenFOAM.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
GeometricField< vector, fvPatchField, volMesh > volVectorField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensionedScalar log(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299