stopAtEmptyClouds.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
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 "stopAtEmptyClouds.H"
27 #include "parcelCloudList.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace functionObjects
35 {
38 }
39 }
40 
41 
42 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
43 
44 bool Foam::functionObjects::stopAtEmptyClouds::condition() const
45 {
46  // Potentially nothing has been injected yet. Wait for a step. If the
47  // clouds begin injection later than this, then time controls will be
48  // needed to delay the execution of this function.
50  {
51  return false;
52  }
53 
54  // Loop all regions and all clouds in each region. If a non-empty cloud is
55  // found then do not stop.
56  bool noClouds = true;
57 
58  const HashTable<const polyMesh*> meshes =
59  time_.lookupClass<polyMesh>();
60 
61  forAllConstIter(HashTable<const polyMesh*>, meshes, meshIter)
62  {
63  const HashTable<const parcelCloud*> clouds =
64  meshIter()->lookupClass<parcelCloud>();
65 
66  forAllConstIter(HashTable<const parcelCloud*>, clouds, cloudIter)
67  {
68  noClouds = false;
69 
70  if (returnReduce(cloudIter()->nParcels(), sumOp<label>()) != 0)
71  {
72  return false;
73  }
74  }
75  }
76 
77  // Either there are no clouds or there are clouds and all of them are
78  // empty. Stop if the latter.
79  return !noClouds;
80 }
81 
82 
83 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
84 
86 (
87  const word& name,
88  const Time& runTime,
89  const dictionary& dict
90 )
91 :
92  stopAt(name, runTime, dict)
93 {
94  read(dict);
95 }
96 
97 
98 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
99 
101 {}
102 
103 
104 // ************************************************************************* //
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
Macros for easy insertion into run-time selection tables.
label timeIndex() const
Return current time index.
Definition: TimeStateI.H:28
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
virtual label startTimeIndex() const
Return start time index.
Definition: Time.C:785
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Abstract base-class for Time/database functionObjects.
const Time & time_
Reference to time.
Stops the run when all parcel clouds are empty.
stopAtEmptyClouds(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Abstract base class for stop conditions.
Definition: stopAt.H:59
virtual bool read(const dictionary &)
Read the dictionary settings.
Definition: stopAt.C:83
HashTable< const Type * > lookupClass(const bool strict=false) const
Lookup and return all objects of the given Type.
A class for handling words, derived from string.
Definition: word.H:62
defineTypeNameAndDebug(adjustTimeStepToCombustion, 0)
addToRunTimeSelectionTable(functionObject, adjustTimeStepToCombustion, dictionary)
Namespace for OpenFOAM.
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
dictionary dict