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-2018 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 "kinematicCloud.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  logFiles::resetNames(dict.lookup("clouds"));
91 
92  Info<< type() << " " << name() << ": ";
93  if (names().size())
94  {
95  Info<< "applying to clouds:" << nl;
96  forAll(names(), i)
97  {
98  Info<< " " << names()[i] << nl;
99  }
100  Info<< endl;
101  }
102  else
103  {
104  Info<< "no clouds to be processed" << nl << endl;
105  }
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 
125  const kinematicCloud& cloud =
127 
128  label nParcels = returnReduce(cloud.nParcels(), sumOp<label>());
129  scalar massInSystem =
131 
132  if (Pstream::master())
133  {
134  writeTime(file(i));
135  file(i)
136  << tab
137  << nParcels << tab
138  << massInSystem << endl;
139  }
140  }
141 
142  return true;
143 }
144 
145 
146 // ************************************************************************* //
Specialization of Foam::functionObject for a region and providing a reference to the region Foam::obj...
virtual bool execute()
Execute, currently does nothing.
Definition: cloudInfo.C:111
virtual scalar massInSystem() const =0
Total mass in system.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
virtual bool write()
Write function.
Definition: logFiles.C:180
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Inter-processor communication reduction functions.
static const char tab
Definition: Ostream.H:264
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
virtual ~cloudInfo()
Destructor.
Definition: cloudInfo.C:80
addToRunTimeSelectionTable(functionObject, Qdot, dictionary)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
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:68
Macros for easy insertion into run-time selection tables.
virtual label nParcels() const =0
Number of parcels.
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
A class for handling words, derived from string.
Definition: word.H:59
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:265
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
Virtual abstract base class for templated KinematicCloud.
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 void resetNames(const wordList &names)
Reset the list of names from a wordList.
Definition: logFiles.C:66
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:583
functionObject base class for creating, maintaining and writing log files e.g. integrated of averaged...
Definition: logFiles.H:57