BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / lagrangian / intermediate / clouds / Templates / KinematicCloud / cloudSolution / cloudSolution.C
blobfd7bf317068df79638838021dccc6ab6d323f514
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "cloudSolution.H"
27 #include "Time.H"
29 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
31 Foam::cloudSolution::cloudSolution
33     const fvMesh& mesh,
34     const dictionary& dict
37     mesh_(mesh),
38     dict_(dict),
39     active_(dict.lookup("active")),
40     transient_(false),
41     calcFrequency_(1),
42     maxCo_(0.3),
43     iter_(1),
44     trackTime_(0.0),
45     coupled_(false),
46     cellValueSourceCorrection_(false),
47     maxTrackTime_(0.0),
48     resetSourcesOnStartup_(true),
49     schemes_()
51     if (active_)
52     {
53         read();
54     }
58 Foam::cloudSolution::cloudSolution
60     const cloudSolution& cs
63     mesh_(cs.mesh_),
64     dict_(cs.dict_),
65     active_(cs.active_),
66     transient_(cs.transient_),
67     calcFrequency_(cs.calcFrequency_),
68     maxCo_(cs.maxCo_),
69     iter_(cs.iter_),
70     trackTime_(cs.trackTime_),
71     coupled_(cs.coupled_),
72     cellValueSourceCorrection_(cs.cellValueSourceCorrection_),
73     maxTrackTime_(cs.maxTrackTime_),
74     resetSourcesOnStartup_(cs.resetSourcesOnStartup_),
75     schemes_(cs.schemes_)
79 Foam::cloudSolution::cloudSolution
81     const fvMesh& mesh
84     mesh_(mesh),
85     dict_(dictionary::null),
86     active_(false),
87     transient_(false),
88     calcFrequency_(0),
89     maxCo_(GREAT),
90     iter_(0),
91     trackTime_(0.0),
92     coupled_(false),
93     cellValueSourceCorrection_(false),
94     maxTrackTime_(0.0),
95     resetSourcesOnStartup_(false),
96     schemes_()
100 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
102 Foam::cloudSolution::~cloudSolution()
106 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
108 void Foam::cloudSolution::read()
110     dict_.lookup("transient") >> transient_;
111     dict_.lookup("coupled") >> coupled_;
112     dict_.lookup("cellValueSourceCorrection") >> cellValueSourceCorrection_;
114     if (steadyState())
115     {
116         dict_.lookup("calcFrequency") >> calcFrequency_;
117         dict_.lookup("maxCo") >> maxCo_;
118         dict_.lookup("maxTrackTime") >> maxTrackTime_;
120         if (coupled_)
121         {
122             dict_.subDict("sourceTerms").lookup("resetOnStartup")
123                 >> resetSourcesOnStartup_;
124         }
125     }
127     if (coupled_)
128     {
129         const dictionary&
130             schemesDict(dict_.subDict("sourceTerms").subDict("schemes"));
132         wordList vars(schemesDict.toc());
133         schemes_.setSize(vars.size());
134         forAll(vars, i)
135         {
136             // read solution variable name
137             schemes_[i].first() = vars[i];
139             // set semi-implicit (1) explicit (0) flag
140             Istream& is = schemesDict.lookup(vars[i]);
141             const word scheme(is);
142             if (scheme == "semiImplicit")
143             {
144                 schemes_[i].second().first() = true;
145             }
146             else if (scheme == "explicit")
147             {
148                 schemes_[i].second().first() = false;
149             }
150             else
151             {
152                 FatalErrorIn("void cloudSolution::read()")
153                     << "Invalid scheme " << scheme << ". Valid schemes are "
154                     << "explicit and semiImplicit" << exit(FatalError);
155             }
157             // read under-relaxation factor
158             is  >> schemes_[i].second().second();
159         }
160     }
164 Foam::scalar Foam::cloudSolution::relaxCoeff(const word& fieldName) const
166     forAll(schemes_, i)
167     {
168         if (fieldName == schemes_[i].first())
169         {
170             return schemes_[i].second().second();
171         }
172     }
174     FatalErrorIn("scalar cloudSolution::relaxCoeff(const word&) const")
175         << "Field name " << fieldName << " not found in schemes"
176         << abort(FatalError);
178     return 1.0;
182 bool Foam::cloudSolution::semiImplicit(const word& fieldName) const
184     forAll(schemes_, i)
185     {
186         if (fieldName == schemes_[i].first())
187         {
188             return schemes_[i].second().first();
189         }
190     }
192     FatalErrorIn("bool cloudSolution::semiImplicit(const word&) const")
193         << "Field name " << fieldName << " not found in schemes"
194         << abort(FatalError);
196     return false;
200 bool Foam::cloudSolution::solveThisStep() const
202     return
203         active_
204      && (
205             mesh_.time().outputTime()
206          || (mesh_.time().timeIndex() % calcFrequency_ == 0)
207         );
211 bool Foam::cloudSolution::canEvolve()
213     if (transient_)
214     {
215         trackTime_ = mesh_.time().deltaTValue();
216     }
217     else
218     {
219         trackTime_ = maxTrackTime_;
220     }
222     return solveThisStep();
226 bool Foam::cloudSolution::output() const
228     return active_ && mesh_.time().outputTime();
232 // ************************************************************************* //