Loading...
Searching...
No Matches
fixedTemperatureConstraint.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) 2012-2016 OpenFOAM Foundation
9 Copyright (C) 2020-2021 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
30#include "fvMesh.H"
31#include "fvMatrices.H"
32#include "basicThermo.H"
35// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36
37namespace Foam
38{
39 namespace fv
40 {
43 (
44 option,
47 );
48 }
49}
50
51const Foam::Enum
52<
54>
56({
58 { temperatureMode::tmLookup, "lookup" },
59});
60
61
62// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
63
65(
66 const word& name,
67 const word& modelType,
68 const dictionary& dict,
69 const fvMesh& mesh
70)
71:
72 fv::cellSetOption(name, modelType, dict, mesh),
73 mode_(temperatureModeNames_.get("mode", coeffs_)),
74 Tuniform_(nullptr),
75 TName_("T")
76{
77 switch (mode_)
78 {
79 case tmUniform:
80 {
81 Tuniform_.reset
82 (
83 Function1<scalar>::New("temperature", coeffs_, &mesh_)
84 );
85 break;
86 }
87 case tmLookup:
88 {
89 TName_ = coeffs_.getOrDefault<word>("T", "T");
90 break;
91 }
92 default:
93 {
94 // Error handling already done by Enum
95 }
96 }
97
98
99 // Set the field name to that of the energy
100 // field from which the temperature is obtained
101
102 const auto& thermo = mesh_.lookupObject<basicThermo>(basicThermo::dictName);
103
104 fieldNames_.resize(1, thermo.he().name());
107}
108
109
110// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
111
113(
114 fvMatrix<scalar>& eqn,
115 const label
116)
117{
118 const auto& thermo = mesh_.lookupObject<basicThermo>(basicThermo::dictName);
119
120 switch (mode_)
121 {
122 case tmUniform:
123 {
124 const scalar t = mesh_.time().value();
125 scalarField Tuni(cells_.size(), Tuniform_->value(t));
126 eqn.setValues(cells_, thermo.he(thermo.p(), Tuni, cells_));
127
128 break;
129 }
130 case tmLookup:
131 {
132 const auto& T = mesh().lookupObject<volScalarField>(TName_);
133
134 scalarField Tlkp(T, cells_);
135 eqn.setValues(cells_, thermo.he(thermo.p(), Tlkp, cells_));
136
137 break;
138 }
139 default:
141 // Error handling already done by Enum
142 }
143 }
144}
145
146
148{
150 {
151 if (Tuniform_ && coeffs_.found(Tuniform_->name(), keyType::LITERAL))
152 {
153 Tuniform_.reset
154 (
155 Function1<scalar>::New(Tuniform_->name(), dict, &mesh_)
156 );
157 }
158
159 coeffs_.readIfPresent("T", TName_);
160
161 return true;
162 }
163
164 return false;
165}
166
167
168// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
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
void setValues(const labelUList &cellLabels, const Type &value)
Set solution in given cells to the specified value and eliminate the corresponding equations from the...
Definition fvMatrix.C:971
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
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.
Constrain temperature equation (i.e. T) with a given set of fixed values within a specified region.
autoPtr< Function1< scalar > > Tuniform_
Uniform temperature [K].
fixedTemperatureConstraint(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
virtual bool read(const dictionary &dict)
Read dictionary.
virtual void constrain(fvMatrix< scalar > &eqn, const label fieldi)
Constrain energy equation to fix the temperature.
static const Enum< temperatureMode > temperatureModeNames_
String representation of temperatureMode enums.
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
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
@ LITERAL
String literal.
Definition keyType.H:82
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
dynamicFvMesh & mesh
A special matrix type and solver, designed for finite volume solutions of scalar equations.
auto & name
Namespace for finite-volume.
Namespace for OpenFOAM.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
labelList fv(nPoints)
dictionary dict
psiReactionThermo & thermo