1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
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
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"
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 Foam::cloudSolution::cloudSolution
34 const dictionary& dict
39 active_(dict.lookup("active")),
46 cellValueSourceCorrection_(false),
48 resetSourcesOnStartup_(true),
58 Foam::cloudSolution::cloudSolution
60 const cloudSolution& cs
66 transient_(cs.transient_),
67 calcFrequency_(cs.calcFrequency_),
70 trackTime_(cs.trackTime_),
71 coupled_(cs.coupled_),
72 cellValueSourceCorrection_(cs.cellValueSourceCorrection_),
73 maxTrackTime_(cs.maxTrackTime_),
74 resetSourcesOnStartup_(cs.resetSourcesOnStartup_),
79 Foam::cloudSolution::cloudSolution
85 dict_(dictionary::null),
93 cellValueSourceCorrection_(false),
95 resetSourcesOnStartup_(false),
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_;
116 dict_.lookup("calcFrequency") >> calcFrequency_;
117 dict_.lookup("maxCo") >> maxCo_;
118 dict_.lookup("maxTrackTime") >> maxTrackTime_;
122 dict_.subDict("sourceTerms").lookup("resetOnStartup")
123 >> resetSourcesOnStartup_;
130 schemesDict(dict_.subDict("sourceTerms").subDict("schemes"));
132 wordList vars(schemesDict.toc());
133 schemes_.setSize(vars.size());
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")
144 schemes_[i].second().first() = true;
146 else if (scheme == "explicit")
148 schemes_[i].second().first() = false;
152 FatalErrorIn("void cloudSolution::read()")
153 << "Invalid scheme " << scheme << ". Valid schemes are "
154 << "explicit and semiImplicit" << exit(FatalError);
157 // read under-relaxation factor
158 is >> schemes_[i].second().second();
164 Foam::scalar Foam::cloudSolution::relaxCoeff(const word& fieldName) const
168 if (fieldName == schemes_[i].first())
170 return schemes_[i].second().second();
174 FatalErrorIn("scalar cloudSolution::relaxCoeff(const word&) const")
175 << "Field name " << fieldName << " not found in schemes"
176 << abort(FatalError);
182 bool Foam::cloudSolution::semiImplicit(const word& fieldName) const
186 if (fieldName == schemes_[i].first())
188 return schemes_[i].second().first();
192 FatalErrorIn("bool cloudSolution::semiImplicit(const word&) const")
193 << "Field name " << fieldName << " not found in schemes"
194 << abort(FatalError);
200 bool Foam::cloudSolution::solveThisStep() const
205 mesh_.time().outputTime()
206 || (mesh_.time().timeIndex() % calcFrequency_ == 0)
211 bool Foam::cloudSolution::canEvolve()
215 trackTime_ = mesh_.time().deltaTValue();
219 trackTime_ = maxTrackTime_;
222 return solveThisStep();
226 bool Foam::cloudSolution::output() const
228 return active_ && mesh_.time().outputTime();
232 // ************************************************************************* //