原始目的是基于已有的injection模型中添加lookuptable的功能。

然后基于KinematicLookupTableInjectionThermoLookupTableInjection, ReactingLookupTableInjectionReactingMultiphaseLookupTableInjection中的数据类型的简历方式,建立了这个模型,名为compositionData,主要目的就是在于可以在injection的时候定义parcel的组分Y的相关变量。

compositionData.C

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

#include "compositionData.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

namespace Foam
{
defineTypeNameAndDebug(compositionData, 0);
}

// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

Foam::compositionData::compositionData()
: rho_(0.0),
T_(0.0),
Cp_(0.0),
Y_(),
YGas_(),
YLiquid_(),
YSolid_()

{
}


Foam::compositionData::compositionData(
const dictionary& dict)
:
rho_(readScalar(dict.lookup("rho"))),
T_(readScalar(dict.lookup("T"))),
Cp_(readScalar(dict.lookup("Cp"))),
Y_(dict.lookup("Y")),
YGas_(dict.lookup("YGas")),
YLiquid_(dict.lookup("YLiquid")),
YSolid_(dict.lookup("YSolid"))
{
}

// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

Foam::compositionData::~compositionData()
{
}


// ************************************************************************* //


compositionData.H

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.

Class
Foam::compositionData

Description
Container class to provide injection data for kinematic parcels

SourceFiles
compositionData.C

\*---------------------------------------------------------------------------*/

#ifndef compositionData_H
# define compositionData_H

# include "dictionary.H"
# include "vector.H"
# include "point.H"
# include "scalarList.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

// Forward declaration of classes
class compositionData;

// Forward declaration of friend functions

Ostream& operator<<(
Ostream&,
const compositionData&);

Istream& operator>>(
Istream&,
compositionData&);

/*---------------------------------------------------------------------------*\
Class compositionData Declaration
\*---------------------------------------------------------------------------*/

class compositionData
{
protected:
// Parcel properties

//- Density [kg/m3]
scalar rho_;

//- Temperature [K]
scalar T_;

//- Specific heat capacity [J/kg/K]
scalar Cp_;

//- List of mass fractions
scalarList Y_;

//- List of gaseous mass fractions
scalarList YGas_;

//- List of liquid mass fractions
scalarList YLiquid_;

//- List of solid mass fractions
scalarList YSolid_;


public:
//- Runtime type information
TypeName("compositionData");

// Constructors

//- Null constructor
compositionData();

//- Construct from dictionary
compositionData(const dictionary& dict);

//- Construct from Istream
compositionData(Istream& is);


//-Destructor
virtual ~compositionData();


// Access

//- Return const access to the density
inline scalar rho() const;

//- Return const access to the temperature
inline scalar T() const;

//- Return const access to the specific heat capacity
inline scalar Cp() const;

//- Return const access to the list of mass fractions
inline const scalarList& Y() const;

//- Return const access to the list of gaseous mass fractions
inline const scalarList& YGas() const;

//- Return const access to the list of liquid mass fractions
inline const scalarList& YLiquid() const;

//- Return const access to the list of solid mass fractions
inline const scalarList& YSolid() const;



// Edit

//- Return access to the density
inline scalar& rho();

//- Return access to the temperature
inline scalar& T();

//- Return access to the specific heat capacity
inline scalar& Cp();

//- Return access to the mass fractions
inline scalarList& Y();
//- Return access to the gaseous mass fractions
inline scalarList& YGas();

//- Return access to the liquid mass fractions
inline scalarList& YLiquid();

//- Return access to the solid mass fractions
inline scalarList& YSolid();

// Friend Operators

friend bool operator==(
const compositionData& a,
const compositionData& b)
{
NotImplemented;

return false;
}

friend bool operator!=(
const compositionData& a,
const compositionData& b)
{
NotImplemented;

return false;
}


// I-O

//- Ostream operator
friend Ostream& operator<<(
Ostream& os,
const compositionData& data);

//- Istream operator
friend Istream& operator>>(
Istream& is,
compositionData& data);
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

# include "compositionDataI.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //

compositionDataI.H

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

#include "compositionData.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


inline Foam::scalar Foam::compositionData::rho() const
{
return rho_;
}

inline Foam::scalar& Foam::compositionData::rho()
{
return rho_;
}

inline Foam::scalar Foam::compositionData::T() const
{
return T_;
}


inline Foam::scalar Foam::compositionData::Cp() const
{
return Cp_;
}


inline Foam::scalar& Foam::compositionData::T()
{
return T_;
}


inline Foam::scalar& Foam::compositionData::Cp()
{
return Cp_;
}

inline const Foam::scalarList& Foam::compositionData::Y() const
{
return Y_;
}


inline Foam::scalarList& Foam::compositionData::Y()
{
return Y_;
}


inline const Foam::scalarList&
Foam::compositionData::YGas() const
{
return YGas_;
}


inline const Foam::scalarList&
Foam::compositionData::YLiquid() const
{
return YLiquid_;
}


inline const Foam::scalarList&
Foam::compositionData::YSolid() const
{
return YSolid_;
}


inline Foam::scalarList& Foam::compositionData::YGas()
{
return YGas_;
}


inline Foam::scalarList& Foam::compositionData::YLiquid()
{
return YLiquid_;
}


inline Foam::scalarList& Foam::compositionData::YSolid()
{
return YSolid_;
}


// ************************************************************************* //

compositionDataIO.C

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

#include "compositionData.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Foam::compositionData::compositionData(Istream& is)
{

is.check("reading rho");
is >> rho_;

is.check("reading T");
is >> T_;

is.check("reading Cp");
is >> Cp_;

is.check("reading Y's");
is >> Y_;

is.check("reading YGas's");
is >> YGas_;

is.check("reading YLiquid's");
is >> YLiquid_;

is.check("reading YSolid's");
is >> YSolid_;

is.check("compositionData(Istream& is)");
}


// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //

Foam::Ostream& Foam::operator<<(
Ostream& os,
const compositionData& data)
{
os << data.rho_ << data.T_ << data.Cp_ << data.Y_ << data.YGas_ << data.YLiquid_
<< data.YSolid_;

return os;
}


Foam::Istream& Foam::operator>>(Istream& is, compositionData& data)
{

is.check("reading rho");
is >> data.rho_;

is.check("reading T");
is >> data.T_;

is.check("reading Cp");
is >> data.Cp_;

is.check("reading Y's");
is >> data.Y_;

is.check("reading YGas's");
is >> data.YGas_;

is.check("reading YLiquid's");
is >> data.YLiquid_;

is.check("reading YSolid's");
is >> data.YSolid_;

is.check("operator(Istream&, compositionData&)");

return is;
}


// ************************************************************************* //

compositionDataIOList.C

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

#include "compositionDataIOList.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
defineTemplateTypeNameAndDebug(IOList<compositionData>, 0);
}


// ************************************************************************* //

compositionDataIOList.H

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.

Class
Foam::compositionDataIOList

Description

SourceFiles
compositionDataIOList.C

\*---------------------------------------------------------------------------*/

#ifndef compositionDataIOList_H
# define compositionDataIOList_H

# include "IOList.H"
# include "compositionData.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
typedef IOList<compositionData>
compositionDataIOList;
}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //

最后还需要在 Make/files 中添加下列语句,才能编译出来。

1
2
3
4
COMPOSITIONINJECTION=submodels/Reacting/InjectionModel/compositionData
$(COMPOSITIONINJECTION)/compositionData.C
$(COMPOSITIONINJECTION)/compositionDataIO.C
$(COMPOSITIONINJECTION)/compositionDataIOList.C

使用方法也很简单,在对应的XXXinjection.H文件中,定义变量injectors_ 为例子

1
2
//- List of injectors
compositionDataIOList injectors_;

XXXinjection.C中 添加

1
2
3
4
5
6
7
8
9
10
11
12
13
14
//Constructors处  
compositionFile_(this->coeffDict().lookup("compositionFile")),
injectors_(
IOobject(
compositionFile_,
owner.db().time().constant(),
owner.db(),
IOobject::MUST_READ,
IOobject::NO_WRITE))

// 第二部分
compositionFile_(im.compositionFile_),
injectors_(im.injectors_)

最后在setProperties 方程中添加,下面的语句只会读取文件中的第一行设置。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  // set particle density
parcel.rho() = injectors_[0].rho();

// set particle temperature
parcel.T() = injectors_[0].T();

// // set particle specific heat capacity
parcel.Cp() = injectors_[0].Cp();

// set particle component mass fractions
parcel.Y() = injectors_[0].Y();

// set particle gaseous component mass fractions
parcel.YGas() = injectors_[0].YGas();

// set particle liquid component mass fractions
parcel.YLiquid() = injectors_[0].YLiquid();

// set particle solid component mass fractions
parcel.YSolid() = injectors_[0].YSolid();

reactingCloudProperties

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
singleMixtureFractionCoeffs
{
phases
(
gas
{
}
liquid
{
}
solid
{
C 0.5;
ash 0.5;

}
);
YGasTot0 0.0;
YLiquidTot0 0.0;
YSolidTot0 1.0;
}

设置文件1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.x |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object scalarListList;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// rho T Cp (Y0..Y2) (Yg0..YgN) (Yl0..YlN) (Ys0..YsN)
(
1500 300 4200 (0 0 1) () () (1 0)
);
// ************************************************************************* //

设置文件2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.x |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object scalarListList;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// (x y z) (u v w) d rho mDot T Cp (Y0..Y2) (Yg0..YgN) (Yl0..YlN) (Ys0..YsN)
(
2500 300 4200 (0 0 1) () () (0 1)
);
// ************************************************************************* //

最终在injection的时候就会按照文件中所设置的变量进行injection

这只是我的应用。

这个数据类型完全可以扩展到其他的地方,当你要读取一个数据文件的情况下,或者你的数据文件包含多个配置。