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-2016 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"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace functionObjects
35 {
36  defineTypeNameAndDebug(cloudInfo, 0);
37 
39  (
40  functionObject,
41  cloudInfo,
42  dictionary
43  );
44 }
45 }
46 
47 
48 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
49 
51 {
52  writeHeader(file(), "Cloud information");
53  writeCommented(file(), "Time");
54  writeTabbed(file(), "nParcels");
55  writeTabbed(file(), "mass");
56  file() << endl;
57 }
58 
59 
60 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
61 
62 Foam::functionObjects::cloudInfo::cloudInfo
63 (
64  const word& name,
65  const Time& runTime,
66  const dictionary& dict
67 )
68 :
69  writeFiles(name, runTime, dict, name)
70 {
71  read(dict);
72 }
73 
74 
75 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
76 
78 {}
79 
80 
81 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
82 
84 {
85  writeFiles::resetNames(dict.lookup("clouds"));
86 
87  Info<< type() << " " << name() << ": ";
88  if (names().size())
89  {
90  Info<< "applying to clouds:" << nl;
91  forAll(names(), i)
92  {
93  Info<< " " << names()[i] << nl;
94  }
95  Info<< endl;
96  }
97  else
98  {
99  Info<< "no clouds to be processed" << nl << endl;
100  }
101 
102  return true;
103 }
104 
105 
107 {
108  return true;
109 }
110 
111 
113 {
115 
116  forAll(names(), i)
117  {
118  const word& cloudName = names()[i];
119 
120  const kinematicCloud& cloud =
122 
123  label nParcels = returnReduce(cloud.nParcels(), sumOp<label>());
124  scalar massInSystem =
126 
127  if (Pstream::master())
128  {
129  writeTime(file(i));
130  file(i)
131  << token::TAB
132  << nParcels << token::TAB
133  << massInSystem << endl;
134  }
135  }
136 
137  return true;
138 }
139 
140 
141 // ************************************************************************* //
virtual bool execute()
Execute, currently does nothing.
Definition: cloudInfo.C:106
virtual scalar massInSystem() const =0
Total mass in system.
virtual void resetNames(const wordList &names)
Reset the list of names from a wordList.
Definition: writeFiles.C:67
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
functionObject base class for writing files
Definition: writeFiles.H:56
virtual ~cloudInfo()
Destructor.
Definition: cloudInfo.C:77
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
static bool master(const label communicator=0)
Am I the master process.
Definition: UPstream.H:411
const word cloudName(propsDict.lookup("cloudName"))
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:83
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
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:112
static const char nl
Definition: Ostream.H:262
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Virtual abstract base class for templated KinematicCloud.
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:461
addToRunTimeSelectionTable(functionObject, blendingFactor, dictionary)
virtual bool write()
Write function.
Definition: writeFiles.C:197
messageStream Info
virtual void writeFileHeader(const label i)
File header information.
Definition: cloudInfo.C:50
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
defineTypeNameAndDebug(fvMeshFunctionObject, 0)
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:451