Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
finiteVolume
cfdTools
general
fieldSources
timeActivatedExplicitSource
TimeActivatedExplicitSourceList.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 | Copyright (C) 2010-2010 OpenCFD Ltd.
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 "
TimeActivatedExplicitSourceList.H
"
27
28
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29
30
template
<
class
Type>
31
Foam::TimeActivatedExplicitSourceList<Type>::TimeActivatedExplicitSourceList
32
(
33
const
word
&
name
,
34
const
fvMesh
&
mesh
,
35
const
dimensionSet
& dimensions,
36
const
wordList
&
fieldNames
37
)
38
:
39
IOPtrList<TimeActivatedExplicitSource<Type>
>
40
(
41
IOobject
42
(
43
name +
"SourceProperties"
,
44
mesh.
time
().
constant
(),
45
mesh
,
46
IOobject::MUST_READ,
47
IOobject::NO_WRITE
48
),
49
typename
TimeActivatedExplicitSource<Type>::iNew
(mesh, fieldNames)
50
),
51
name_(name),
52
mesh_(mesh),
53
dimensions_(dimensions),
54
fieldNames_(fieldNames)
55
{}
56
57
58
template
<
class
Type>
59
Foam::TimeActivatedExplicitSourceList<Type>::TimeActivatedExplicitSourceList
60
(
61
const
word
& name,
62
const
fvMesh
& mesh,
63
const
dimensionSet
& dimensions,
64
const
word
& fieldName
65
)
66
:
67
IOPtrList<TimeActivatedExplicitSource<Type>
>
68
(
69
IOobject
70
(
71
name +
"SourceProperties"
,
72
mesh.
time
().
constant
(),
73
mesh
,
74
IOobject::MUST_READ,
75
IOobject::NO_WRITE
76
),
77
typename
TimeActivatedExplicitSource<Type>::iNew
78
(
79
mesh,
80
IStringStream
(
'('
+ fieldName +
')'
)()
81
)
82
),
83
name_(name),
84
mesh_(mesh),
85
dimensions_(dimensions),
86
fieldNames_(1, fieldName)
87
{}
88
89
90
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
91
92
template
<
class
Type>
93
Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh>
>
94
Foam::TimeActivatedExplicitSourceList<Type>::Su
(
const
label fieldI)
95
{
96
tmp<DimensionedField<Type, volMesh>
> tSu
97
(
98
new
DimensionedField<Type, volMesh>
99
(
100
IOobject
101
(
102
name_ +
"Source_"
+ fieldNames_[fieldI],
103
mesh_.time().timeName(),
104
mesh_,
105
IOobject::NO_READ,
106
IOobject::NO_WRITE
107
),
108
mesh_,
109
dimensioned<Type>
(
"zero"
, dimensions_,
pTraits<Type>::zero
)
110
)
111
);
112
113
DimensionedField<Type, volMesh>
&
Su
= tSu();
114
115
forAll
(*
this
, i)
116
{
117
this->operator[](i).addToField(Su, fieldI);
118
}
119
120
return
tSu;
121
}
122
123
124
template
<
class
Type>
125
Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh>
>
126
Foam::TimeActivatedExplicitSourceList<Type>::SuTot
()
127
{
128
tmp<DimensionedField<Type, volMesh>
> tSuTot
129
(
130
new
DimensionedField<Type, volMesh>
131
(
132
IOobject
133
(
134
name_ +
"TotalSource"
,
135
mesh_.time().timeName(),
136
mesh_,
137
IOobject::NO_READ,
138
IOobject::NO_WRITE
139
),
140
mesh_,
141
dimensioned<Type>
(
"zero"
, dimensions_,
pTraits<Type>::zero
)
142
)
143
);
144
145
DimensionedField<Type, volMesh>
& SuTot = tSuTot();
146
147
forAll
(fieldNames_, fieldI)
148
{
149
forAll
(*
this
, sourceI)
150
{
151
this->operator[](sourceI).addToField(SuTot, fieldI);
152
}
153
}
154
155
return
tSuTot;
156
}
157
158
159
template
<
class
Type>
160
bool
Foam::TimeActivatedExplicitSourceList<Type>::readData
(
Istream
& is)
161
{
162
this->
clear
();
163
164
IOPtrList<TimeActivatedExplicitSource<Type>
> newSources
165
(
166
IOobject
167
(
168
name_ +
"TimeActivatedExplicitSource"
,
169
mesh_.time().constant(),
170
mesh_,
171
IOobject::MUST_READ,
172
IOobject::NO_WRITE,
173
false
174
),
175
typename
TimeActivatedExplicitSource<Type>::iNew
(mesh_, fieldNames_)
176
);
177
178
transfer(newSources);
179
180
return
is.
good
();
181
}
182
183
184
template
<
class
Type>
185
bool
Foam::TimeActivatedExplicitSourceList<Type>::writeData
(
Ostream
& os)
const
186
{
187
// Write size of list
188
os <<
nl
<< this->size();
189
190
// Write beginning of contents
191
os <<
nl
<< token::BEGIN_LIST;
192
193
// Write list contents
194
forAll
(*
this
, i)
195
{
196
os <<
nl
;
197
this->operator[](i).writeData(os);
198
}
199
200
// Write end of contents
201
os << token::END_LIST << token::END_STATEMENT <<
nl
;
202
203
// Check state of IOstream
204
return
os.
good
();
205
}
206
207
208
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
209
210
template
<
class
Type>
211
Foam::Ostream
& Foam::operator<<
212
(
213
Ostream
& os,
214
const
TimeActivatedExplicitSourceList<Type>
& sources
215
)
216
{
217
sources.writeData(os);
218
return
os;
219
}
220
221
222
// ************************ vim: set sw=4 sts=4 et: ************************ //