Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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
32template<class ThermoType>
33const ThermoType& Foam::pureZoneMixture<ThermoType>::constructSpeciesData
34(
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];
59
60
61// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
62
63
64template<class ThermoType>
65Foam::pureZoneMixture<ThermoType>::pureZoneMixture
66(
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
103template<class ThermoType>
105(
106 const label celli
107) const
109 mixture_ = speciesData_[zoneID_[celli]];
110 return mixture_;
111}
112
113
114template<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
127template<class ThermoType>
129(
130 const scalar p,
131 const scalar T,
132 const label celli
133) const
135 // (per zone) constant density
136 return this->cellMixture(celli);
137}
138
139
140template<class 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
154template<class ThermoType>
156(
158)
159{
160 constructSpeciesData(thermoDict);
161}
162
163
164// ************************************************************************* //
for(const label curEdgei :curPointEdges)
void setSize(label n)
Alias for resize().
Definition List.H:536
A List with indirect addressing. Like IndirectList but does not store addressing.
label size() const noexcept
The number of entries in the list.
Definition UPtrListI.H:106
Foam::basicMixture.
basicMixture(const dictionary &, const fvMesh &, const word &)
Construct from dictionary, mesh and phase name.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
Definition polyMesh.H:679
label nCells() const noexcept
Number of mesh cells.
const ThermoType & cellMixture(const label celli) const
const ThermoType & cellVolMixture(const scalar p, const scalar T, const label celli) const
const ThermoType & patchFaceMixture(const label patchi, const label facei) const
const ThermoType & patchFaceVolMixture(const scalar p, const scalar T, const label patchi, const label facei) const
void read(const dictionary &)
Read dictionary.
A class for handling words, derived from Foam::string.
Definition word.H:66
volScalarField & p
const dictionary & thermoDict
Definition EEqn.H:16
dynamicFvMesh & mesh
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299