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 |
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(file(), "Cloud information");
43  writeCommented(file(), "Time");
44  writeTabbed(file(), "nParcels");
45  writeTabbed(file(), "mass");
46  file() << endl;
47 }
48 
49 
50 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
51 
53 (
54  const word& name,
55  const objectRegistry& obr,
56  const dictionary& dict,
57  const bool loadFromFiles
58 )
59 :
60  functionObjectFile(obr, name),
61  name_(name),
62  obr_(obr),
63  active_(true)
64 {
65  read(dict);
66 }
67 
68 
69 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
70 
72 {}
73 
74 
75 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
76 
78 {
79  if (active_)
80  {
81  functionObjectFile::resetNames(dict.lookup("clouds"));
82 
83  Info<< type() << " " << name_ << ": ";
84  if (names().size())
85  {
86  Info<< "applying to clouds:" << nl;
87  forAll(names(), i)
88  {
89  Info<< " " << names()[i] << nl;
90  }
91  Info<< endl;
92  }
93  else
94  {
95  Info<< "no clouds to be processed" << nl << endl;
96  }
97  }
98 }
99 
100 
102 {}
103 
104 
106 {}
107 
108 
110 {}
111 
112 
114 {
115  if (active_)
116  {
118 
119  forAll(names(), i)
120  {
121  const word& cloudName = names()[i];
122 
123  const kinematicCloud& cloud =
125 
126  label nParcels = returnReduce(cloud.nParcels(), sumOp<label>());
127  scalar massInSystem =
129 
130  if (Pstream::master())
131  {
132  file(i)
133  << obr_.time().value() << token::TAB
134  << nParcels << token::TAB
135  << massInSystem << endl;
136  }
137  }
138  }
139 }
140 
141 
142 // ************************************************************************* //
virtual void read(const dictionary &)
Read the field min/max data.
Definition: cloudInfo.C:77
const word cloudName(propsDict.lookup("cloudName"))
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: cloudInfo.C:105
Virtual abstract base class for templated KinematicCloud.
virtual ~cloudInfo()
Destructor.
Definition: cloudInfo.C:71
A class for handling words, derived from string.
Definition: word.H:59
virtual void resetNames(const wordList &names)
Reset the list of names from a wordList.
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
messageStream Info
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: cloudInfo.C:109
cloudInfo(const cloudInfo &)
Disallow default bitwise copy construct.
Namespace for OpenFOAM.
static const char nl
Definition: Ostream.H:260
virtual void write()
Write.
Definition: cloudInfo.C:113
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
#define forAll(list, i)
Definition: UList.H:421
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
virtual label nParcels() const =0
Number of parcels.
A cloud is a collection of lagrangian particles.
Definition: cloud.H:51
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:589
virtual void write()
Write function.
virtual void writeFileHeader(const label i)
File header information.
Definition: cloudInfo.C:40
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
Registry of regIOobjects.
virtual void execute()
Execute, currently does nothing.
Definition: cloudInfo.C:101
Base class for output file data handling.
static bool master(const label communicator=0)
Am I the master process.
Definition: UPstream.H:398
bool read(const char *, int32_t &)
Definition: int32IO.C:87
virtual scalar massInSystem() const =0
Total mass in system.
defineTypeNameAndDebug(combustionModel, 0)