cloudInfo.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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 "dictionary.H"
28 #include "kinematicCloud.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  defineTypeNameAndDebug(cloudInfo, 0);
35 }
36 
37 
38 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
39 
41 {
42  writeHeader(os, "Cloud information");
43  writeCommented(os, "Time");
44  writeTabbed(os, "nParcels");
45  writeTabbed(os, "mass");
46  writeTabbed(os, "Dmax");
47  writeTabbed(os, "D10");
48  writeTabbed(os, "D32");
49  os << endl;
50 }
51 
52 
53 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
54 
56 (
57  const word& name,
58  const objectRegistry& obr,
59  const dictionary& dict,
60  const bool loadFromFiles
61 )
62 :
64  name_(name),
65  obr_(obr),
66  active_(true),
67  log_(true),
68  cloudNames_(),
69  filePtrs_()
70 {
71  read(dict);
72 }
73 
74 
75 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
76 
78 {}
79 
80 
81 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
82 
84 {
85  if (active_)
86  {
88 
89  log_ = dict.lookupOrDefault<Switch>("log", true);
90  dict.lookup("clouds") >> cloudNames_;
91 
92  if (log_)
93  {
94  Info<< type() << " " << name_ << ": ";
95 
96  if (cloudNames_.size())
97  {
98  Info<< "applying to clouds:" << nl;
99  forAll(cloudNames_, i)
100  {
101  Info<< " " << cloudNames_[i] << nl;
102  }
103  Info<< endl;
104  }
105  else
106  {
107  Info<< "no clouds to be processed" << nl << endl;
108  }
109  }
110 
111  if (writeToFile())
112  {
113  filePtrs_.setSize(cloudNames_.size());
114  forAll(filePtrs_, fileI)
115  {
116  const word& cloudName = cloudNames_[fileI];
117  filePtrs_.set(fileI, createFile(cloudName));
118  writeFileHeader(filePtrs_[fileI]);
119  }
120  }
121  }
122 }
123 
124 
126 {
127  // Do nothing
128 }
129 
130 
132 {
133  // Do nothing
134 }
135 
136 
138 {
139  // Do nothing
140 }
141 
142 
144 {
145  if (active_)
146  {
147  forAll(cloudNames_, cloudI)
148  {
149  const word& cloudName = cloudNames_[cloudI];
150 
151  const kinematicCloud& cloud =
153 
154  label nParcels = returnReduce(cloud.nParcels(), sumOp<label>());
155  scalar massInSystem =
156  returnReduce(cloud.massInSystem(), sumOp<scalar>());
157 
158  scalar Dmax = cloud.Dmax();
159  scalar D10 = cloud.Dij(1, 0);
160  scalar D32 = cloud.Dij(3, 2);
161 
162  if (Pstream::master() && writeToFile())
163  {
164  writeTime(filePtrs_[cloudI]);
165  filePtrs_[cloudI]
166  << token::TAB
167  << nParcels << token::TAB
168  << massInSystem << token::TAB
169  << Dmax << token::TAB
170  << D10 << token::TAB
171  << D32 << token::TAB
172  << endl;
173  }
174 
175  if (log_) Info
176  << type() << " " << name_ << " output:" << nl
177  << " number of parcels : " << nParcels << nl
178  << " mass in system : " << massInSystem << nl
179  << " maximum diameter : " << Dmax << nl
180  << " D10 diameter : " << D10 << nl
181  << " D32 diameter : " << D32 << nl
182  << endl;
183  }
184  }
185 }
186 
187 
188 // ************************************************************************* //
Foam::token::TAB
@ TAB
Definition: token.H:96
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::cloudInfo::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: cloudInfo.C:137
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:86
kinematicCloud.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::cloudInfo::write
virtual void write()
Write.
Definition: cloudInfo.C:143
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
Foam::functionObjectFile::writeTabbed
void writeTabbed(Ostream &os, const string &str) const
Write a tabbed string to stream.
Definition: functionObjectFile.C:230
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::dictionary::lookupOrDefault
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Definition: dictionaryTemplates.C:33
Foam::functionObjectFile::read
void read(const dictionary &dict)
Read.
Definition: functionObjectFile.C:178
Foam::cloudInfo::read
virtual void read(const dictionary &)
Read the field min/max data.
Definition: cloudInfo.C:83
Foam::cloudInfo::~cloudInfo
virtual ~cloudInfo()
Destructor.
Definition: cloudInfo.C:77
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::cloudInfo::writeFileHeader
virtual void writeFileHeader(Ostream &os) const
File header information.
Definition: cloudInfo.C:40
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::kinematicCloud
Virtual abstract base class for templated KinematicCloud.
Definition: kinematicCloud.H:49
Foam::label
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
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::cloudInfo::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: cloudInfo.C:131
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::functionObjectFile::writeHeader
void writeHeader(Ostream &os, const string &str) const
Write a commented header to stream.
Definition: functionObjectFile.C:240
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::UPstream::master
static bool master(const label communicator=0)
Am I the master process.
Definition: UPstream.H:399
Foam::cloud
A cloud is a collection of lagrangian particles.
Definition: cloud.H:51
Foam::sumOp
Definition: ops.H:162
Foam::cloudInfo::execute
virtual void execute()
Execute, currently does nothing.
Definition: cloudInfo.C:125
Foam::functionObjectFile
Base class for output file data handling.
Definition: functionObjectFile.H:57
dictionary.H
cloudName
const word cloudName(propsDict.lookup("cloudName"))
Foam::cloudInfo::cloudInfo
cloudInfo(const cloudInfo &)
Disallow default bitwise copy construct.
Foam::objectRegistry::lookupObject
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
Definition: objectRegistryTemplates.C:165
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::functionObjectFile::writeCommented
void writeCommented(Ostream &os, const string &str) const
Write a commented string to stream.
Definition: functionObjectFile.C:219
cloudInfo.H
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47