multicomponentThermoI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2023-2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "multicomponentThermo.H"
27 
28 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
29 
31 (
32  const word& specieName
33 ) const
34 {
35  return species().found(specieName);
36 }
37 
38 
40 (
41  const label speciei
42 ) const
43 {
44  const_cast<List<bool>&>(speciesActive())[speciei] = true;
45  const_cast<volScalarField&>(Y()[speciei]).writeOpt() = IOobject::AUTO_WRITE;
46 }
47 
48 
50 (
51  const label speciei
52 ) const
53 {
54  const_cast<List<bool>&>(speciesActive())[speciei] = false;
55  const_cast<volScalarField&>(Y()[speciei]).writeOpt() = IOobject::NO_WRITE;
56 }
57 
58 
59 inline bool Foam::multicomponentThermo::solveSpecie(const label speciei) const
60 {
61  return speciei != defaultSpecie() && speciesActive()[speciei];
62 }
63 
64 
66 {
67  return Y()[speciei];
68 }
69 
70 
72 (
73  const label speciei
74 ) const
75 {
76  return Y()[speciei];
77 }
78 
79 
81 (
82  const word& specieName
83 )
84 {
85  return Y()[species()[specieName]];
86 }
87 
88 
90 (
91  const word& specieName
92 ) const
93 {
94  return Y()[species()[specieName]];
95 }
96 
97 
99 (
100  const volScalarField& Yi
101 ) const
102 {
103  return species()[Yi.member()];
104 }
105 
106 
107 inline Foam::volScalarFieldListSlicer
109 {
110  return volScalarFieldListSlicer(mesh(), Y_);
111 }
112 
113 
114 inline Foam::scalarFieldListSlice
116 (
117  const volScalarFieldListSlicer& Yslicer,
118  const label celli
119 ) const
120 {
121  return Yslicer.slice(celli);
122 }
123 
124 
125 inline Foam::scalarFieldListSlice
127 (
128  const volScalarFieldListSlicer& Yslicer,
129  const label patchi,
130  const label facei
131 ) const
132 {
133  return Yslicer.patchSlice(patchi, facei);
134 }
135 
136 
139 (
140  const fvSource& model,
141  const volScalarField::Internal& source
142 ) const
143 {
145 
146  forAll(Y_, i)
147  {
148  result.set
149  (
150  i,
151  Y_[i]
152  .sources()[model.name()]
153  .sourceValue(model, source)
154  .ptr()
155  );
156  }
157 
158  return result;
159 }
160 
161 
162 inline Foam::scalarFieldListSlice
164 (
166  const label i
167 ) const
168 {
169  return Yslicer.slice(i);
170 }
171 
172 
175 (
176  const fvSource& model,
177  const scalarField& source,
178  const labelUList& cells
179 ) const
180 {
181  PtrList<scalarField> result(Y_.size());
182 
183  forAll(Y_, i)
184  {
185  result.set
186  (
187  i,
188  Y_[i]
189  .sources()[model.name()]
190  .sourceValue(model, source, cells)
191  .ptr()
192  );
193  }
194 
195  return result;
196 }
197 
198 
199 inline Foam::scalarFieldListSlice
201 (
202  const PtrList<scalarField>& Yslicer,
203  const label i
204 ) const
205 {
206  return scalarFieldListSlice(Yslicer, i);
207 }
208 
209 
210 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic GeometricField class.
static word member(const word &name)
Return member (name without the extension)
Definition: IOobject.C:146
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
bool set(const label) const
Is element set.
Definition: PtrListI.H:62
const word & name() const
Return const access to the source name.
Definition: fvModelI.H:57
Base class for finite volume sources.
Definition: fvSource.H:52
bool found(const word &) const
Does the list contain the specified name.
scalarFieldListSlice cellComposition(const volScalarFieldListSlicer &Yslicer, const label celli) const
Get the composition of an internal cell.
volScalarFieldListSlicer Yslicer() const
Get the slicer.
scalarFieldListSlice patchFaceComposition(const volScalarFieldListSlicer &Yslicer, const label patchi, const label facei) const
Get the composition of a boundary face.
scalarFieldListSlice sourceCellComposition(const DimensionedFieldListAndSlicer< scalar, volMesh > &Yslicer, const label i) const
Get the composition of a source cell.
virtual const speciesTable & species() const =0
The table of species.
bool solveSpecie(const label speciei) const
Should the given specie be solved for? I.e., is it active and.
virtual PtrList< volScalarField > & Y()=0
Access the mass-fraction fields.
bool containsSpecie(const word &specieName) const
Does the mixture include this specie?
void setSpecieInactive(const label speciei) const
Set specie inactive.
void setSpecieActive(const label speciei) const
Set specie active.
label specieIndex(const volScalarField &Yi) const
Access the specie index of the given mass-fraction field.
A class for handling words, derived from string.
Definition: word.H:62
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
label patchi
const cellShapeList & cells
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
PtrList< volScalarField > & Y