FreeFOAM The Cross-Platform CFD Toolkit
basicSourceList.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 "basicSourceList.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 Foam::basicSourceList::basicSourceList
31 (
32  const fvMesh& mesh,
33  const dictionary& dict
34 )
35 :
37  mesh_(mesh)
38 {
39  label count = 0;
40  forAllConstIter(dictionary, dict, iter)
41  {
42  // safety:
43  if (iter().isDict())
44  {
45  count ++;
46  }
47  }
48 
49  this->setSize(count);
50  label i = 0;
51  forAllConstIter(dictionary, dict, iter)
52  {
53  const word& name = iter().keyword();
54  const dictionary& dict = iter().dict();
55 
56  this->set
57  (
58  i++,
59  basicSource::New(name, dict, mesh)
60  );
61  }
62 }
63 
64 
65 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
66 
67 
69 {
70  forAll(*this, i)
71  {
72  if (this->operator[](i).isActive())
73  {
74  this->operator[](i).addSu(Eqn);
75  }
76  }
77 }
78 
79 
81 {
82 
83  forAll(*this, i)
84  {
85  if (this->operator[](i).isActive())
86  {
87  this->operator[](i).addSu(Eqn);
88  }
89  }
90 }
91 
92 
94 {
95 
96  forAll(*this, i)
97  {
98  if (this->operator[](i).isActive())
99  {
100  this->operator[](i).addExplicitSources();
101  }
102  }
103 }
104 
105 
107 (
109 )
110 {
111  forAll(*this, i)
112  {
113  if (this->operator[](i).isActive())
114  {
115  this->operator[](i).addSu(field);
116  }
117  }
118 }
119 
120 
122 (
124 )
125 {
126  forAll(*this, i)
127  {
128  if (this->operator[](i).isActive())
129  {
130  this->operator[](i).addSu(field);
131  }
132  }
133 }
134 
135 
137 {
138  forAll(*this, i)
139  {
140  this->operator[](i).read(dict);
141  }
142  return true;
143 }
144 
145 
147 {
148  // Write size of list
149  os << nl << this->size();
150 
151  // Write beginning of contents
152  os << nl << token::BEGIN_LIST;
153 
154  // Write list contents
155  forAll(*this, i)
156  {
157  os << nl;
158  this->operator[](i).writeData(os);
159  }
160 
161  // Write end of contents
163 
164  // Check state of IOstream
165  return os.good();
166 }
167 
168 
169 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
170 
171 Foam::Ostream& Foam::operator<<
172 (
173  Ostream& os,
174  const basicSourceList& sources
175 )
176 {
177  sources.writeData(os);
178  return os;
179 }
180 
181 
182 // ************************************************************************* //