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-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 "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 {
39 
41  (
43  cloudInfo,
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 =
129  returnReduce(cloud.massInSystem(), sumOp<scalar>());
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 // ************************************************************************* //
Inter-processor communication reduction functions.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Macros for easy insertion into run-time selection tables.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
static bool master(const label communicator=0)
Am I the master process.
Definition: UPstream.H:423
A cloud is a collection of lagrangian particles.
Definition: cloud.H:55
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.
Outputs Lagrangian cloud information to a file.
Definition: cloudInfo.H:104
virtual ~cloudInfo()
Destructor.
Definition: cloudInfo.C:80
virtual void writeFileHeader(const label i)
File header information.
Definition: cloudInfo.C:52
cloudInfo(const word &name, const Time &runTime, const dictionary &)
Construct from Time and dictionary.
Definition: cloudInfo.C:65
virtual bool execute()
Execute, currently does nothing.
Definition: cloudInfo.C:111
virtual bool write()
Write.
Definition: cloudInfo.C:117
virtual bool read(const dictionary &)
Read the controls.
Definition: cloudInfo.C:86
functionObject base class for creating, maintaining and writing log files e.g. integrated of averaged...
Definition: logFiles.H:60
OFstream & file()
Return access to the file (if only 1)
Definition: logFiles.C:113
virtual bool write()
Write function.
Definition: logFiles.C:173
Specialisation of Foam::functionObject for a region and providing a reference to the region Foam::obj...
virtual bool read(const dictionary &)
Read optional controls.
void writeTabbed(Ostream &os, const string &str) const
Write a tabbed string to stream.
Definition: writeFile.C:121
void writeHeader(Ostream &os, const string &str) const
Write a commented header to stream.
Definition: writeFile.C:131
void writeCommented(Ostream &os, const string &str) const
Write a commented string to stream.
Definition: writeFile.C:110
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
Virtual abstract base class for parcel clouds. As parcelCloudBase but with additional virtualisation ...
Definition: parcelCloud.H:57
A class for handling words, derived from string.
Definition: word.H:62
defineTypeNameAndDebug(adjustTimeStepToCombustion, 0)
addToRunTimeSelectionTable(functionObject, adjustTimeStepToCombustion, dictionary)
Namespace for OpenFOAM.
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
static const char tab
Definition: Ostream.H:265
messageStream Info
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
static const char nl
Definition: Ostream.H:266
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
dictionary dict
const word cloudName(propsDict.lookup("cloudName"))