pureZoneMixture.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) 2021,2022 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "pureZoneMixture.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 template<class ThermoType>
34 (
35  const dictionary& thermoDict
36 )
37 {
38  const auto& czs = mesh_.cellZones();
39 
40  const auto* dictPtr = thermoDict.findDict("none");
41 
42  speciesData_.setSize(dictPtr ? czs.size()+1 : czs.size());
43  forAll(czs, i)
44  {
45  speciesData_.set
46  (
47  i,
48  new ThermoType(thermoDict.subDict(czs[i].name()))
49  );
50  }
51 
52  if (dictPtr)
53  {
54  speciesData_.set(czs.size(), new ThermoType(*dictPtr));
55  }
56 
57  return speciesData_[0];
58 }
59 
60 
61 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
62 
63 
64 template<class ThermoType>
66 (
67  const dictionary& thermoDict,
68  const fvMesh& mesh,
69  const word& phaseName
70 )
71 :
72  basicMixture(thermoDict, mesh, phaseName),
73  mesh_(mesh),
74  mixture_("mixture", constructSpeciesData(thermoDict.subDict("mixture")))
75 {
76  // Cache index per cell. This is the cellZone except for unzoned cells
77  // which are last
78 
79  const auto& czs = mesh_.cellZones();
80  zoneID_.setSize(mesh_.nCells(), czs.size());
81  for (const auto& cz : czs)
82  {
83  UIndirectList<label>(zoneID_, cz) = cz.index();
84  }
85 
86  // Check if any unzoned cells but no 'none' specification
87  if (speciesData_.size() == czs.size())
88  {
89  const label noneCelli = zoneID_.find(czs.size());
90  if (noneCelli != -1)
91  {
92  FatalErrorInFunction << "Have unzoned cell " << noneCelli
93  << " at " << mesh_.cellCentres()[noneCelli]
94  << " but no \"none\" entry in \"mixture\""
95  << exit(FatalError);
96  }
97  }
98 }
99 
100 
101 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 
103 template<class ThermoType>
105 (
106  const label celli
107 ) const
108 {
109  mixture_ = speciesData_[zoneID_[celli]];
110  return mixture_;
111 }
112 
113 
114 template<class ThermoType>
116 (
117  const label patchi,
118  const label facei
119 ) const
120 {
121  const label celli = mesh_.boundary()[patchi].faceCells()[facei];
122  mixture_ = speciesData_[zoneID_[celli]];
123  return mixture_;
124 }
125 
126 
127 template<class ThermoType>
129 (
130  const scalar p,
131  const scalar T,
132  const label celli
133 ) const
134 {
135  // (per zone) constant density
136  return this->cellMixture(celli);
137 }
138 
139 
140 template<class ThermoType>
141 const ThermoType& Foam::pureZoneMixture<ThermoType>::
143 (
144  const scalar p,
145  const scalar T,
146  const label patchi,
147  const label facei
148 ) const
149 {
150  return this->patchFaceMixture(patchi, facei);
151 }
152 
153 
154 template<class ThermoType>
156 (
157  const dictionary& thermoDict
158 )
159 {
160  constructSpeciesData(thermoDict);
161 }
162 
163 
164 // ************************************************************************* //
void read(const dictionary &)
Read dictionary.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
Version of pureMixture that uses different mixtures for different cellZones. Every cellZone has to pr...
const ThermoType & cellVolMixture(const scalar p, const scalar T, const label celli) const
void setSize(const label n)
Alias for resize()
Definition: List.H:316
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
label size() const noexcept
The number of entries in the list.
Definition: UPtrListI.H:106
const dictionary & thermoDict
Definition: EEqn.H:16
const vectorField & cellCentres() const
label find(const T &val) const
Find index of the first occurrence of the value.
Definition: UList.C:173
Foam::basicMixture.
Definition: basicMixture.H:47
const ThermoType & cellMixture(const label celli) const
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
const ThermoType & patchFaceVolMixture(const scalar p, const scalar T, const label patchi, const label facei) const
label nCells() const noexcept
Number of mesh cells.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
A List with indirect addressing. Like IndirectList but does not store addressing. ...
Definition: faMatrix.H:56
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
Definition: polyMesh.H:678
volScalarField & p
const ThermoType & patchFaceMixture(const label patchi, const label facei) const