cloudInfo.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) 2012-2021 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 "cloudInfo.H"
27 #include "parcelCloud.H"
28 #include "dictionary.H"
29 #include "PstreamReduceOps.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace functionObjects
37 {
38  defineTypeNameAndDebug(cloudInfo, 0);
39 
41  (
42  functionObject,
43  cloudInfo,
44  dictionary
45  );
46 }
47 }
48 
49 
50 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
51 
53 {
54  writeHeader(file(), "Cloud information");
55  writeCommented(file(), "Time");
56  writeTabbed(file(), "nParcels");
57  writeTabbed(file(), "mass");
58  file() << endl;
59 }
60 
61 
62 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
63 
65 (
66  const word& name,
67  const Time& runTime,
68  const dictionary& dict
69 )
70 :
71  regionFunctionObject(name, runTime, dict),
72  logFiles(obr_, name)
73 {
74  read(dict);
75 }
76 
77 
78 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
79 
81 {}
82 
83 
84 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
85 
87 {
89 
90  Info<< type() << " " << name() << ": ";
91  if (names().size())
92  {
93  Info<< "applying to clouds:" << nl;
94  forAll(names(), i)
95  {
96  Info<< " " << names()[i] << nl;
97  }
98  Info<< endl;
99  }
100  else
101  {
102  Info<< "no clouds to be processed" << nl << endl;
103  }
104 
105  resetNames(dict.lookup("clouds"));
106 
107  return true;
108 }
109 
110 
112 {
113  return true;
114 }
115 
116 
118 {
119  logFiles::write();
120 
121  forAll(names(), i)
122  {
123  const word& cloudName = names()[i];
124 
126 
127  label nParcels = returnReduce(cloud.nParcels(), sumOp<label>());
128  scalar massInSystem =
130 
131  if (Pstream::master())
132  {
133  writeTime(file(i));
134  file(i)
135  << tab
136  << nParcels << tab
137  << massInSystem << endl;
138  }
139  }
140 
141  return true;
142 }
143 
144 
145 // ************************************************************************* //
Specialisation of Foam::functionObject for a region and providing a reference to the region Foam::obj...
Virtual abstract base class for parcel clouds. As parcelCloudBase but with additional virtualisation ...
Definition: parcelCloud.H:54
virtual bool execute()
Execute, currently does nothing.
Definition: cloudInfo.C:111
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
virtual bool write()
Write function.
Definition: logFiles.C:167
Inter-processor communication reduction functions.
static const char tab
Definition: Ostream.H:259
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual ~cloudInfo()
Destructor.
Definition: cloudInfo.C:80
addToRunTimeSelectionTable(functionObject, Qdot, dictionary)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
static bool master(const label communicator=0)
Am I the master process.
Definition: UPstream.H:423
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
Macros for easy insertion into run-time selection tables.
virtual bool read(const dictionary &)
Read the controls.
Definition: cloudInfo.C:86
virtual bool read(const dictionary &)
Read optional controls.
bool read(const char *, int32_t &)
Definition: int32IO.C:85
void writeHeader(std::ostream &, const bool isBinary, const std::string &title)
Write header.
A class for handling words, derived from string.
Definition: word.H:59
virtual scalar massInSystem() const =0
Total mass in system.
A cloud is a collection of lagrangian particles.
Definition: cloud.H:51
virtual bool write()
Write.
Definition: cloudInfo.C:117
static const char nl
Definition: Ostream.H:260
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
defineTypeNameAndDebug(Qdot, 0)
cloudInfo(const word &name, const Time &runTime, const dictionary &)
Construct from Time and dictionary.
Definition: cloudInfo.C:65
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
messageStream Info
virtual void writeFileHeader(const label i)
File header information.
Definition: cloudInfo.C:52
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
const word cloudName(propsDict.lookup("cloudName"))
virtual label nParcels() const =0
Number of parcels.
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:864
functionObject base class for creating, maintaining and writing log files e.g. integrated of averaged...
Definition: logFiles.H:57