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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2012-2016 OpenFOAM Foundation
9  Copyright (C) 2015 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "cloudInfo.H"
30 #include "kinematicCloud.H"
31 #include "dictionary.H"
32 #include "PstreamReduceOps.H"
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 namespace functionObjects
40 {
41  defineTypeNameAndDebug(cloudInfo, 0);
42 
44  (
45  functionObject,
46  cloudInfo,
47  dictionary
48  );
49 }
50 }
51 
52 
53 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
54 
56 {
57  writeHeader(os, "Cloud information");
58  writeCommented(os, "Time");
59  writeTabbed(os, "nParcels");
60  writeTabbed(os, "mass");
61  writeTabbed(os, "Dmax");
62  writeTabbed(os, "D10");
63  writeTabbed(os, "D32");
64  os << endl;
65 }
66 
67 
68 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
69 
71 (
72  const word& name,
73  const Time& runTime,
74  const dictionary& dict
75 )
76 :
78  logFiles(obr_, name, dict)
79 {
80  read(dict);
81 }
82 
83 
84 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
85 
87 {
89  {
90  logFiles::resetNames(dict.get<wordList>("clouds"));
91 
92  Info<< type() << " " << name() << ": ";
93  if (writeToFile() && names().size())
94  {
95  Info<< "applying to clouds:" << nl;
96  forAll(names(), cloudi)
97  {
98  Info<< " " << names()[cloudi] << nl;
99  writeFileHeader(files(cloudi));
100  }
101  Info<< endl;
102  }
103  else
104  {
105  Info<< "no clouds to be processed" << nl << endl;
106  }
107  }
108 
109  return true;
110 }
111 
112 
114 {
115  return true;
116 }
117 
118 
120 {
121  forAll(names(), cloudi)
122  {
123  const word& cloudName = names()[cloudi];
124 
125  const kinematicCloud& cloud =
127 
128  const label nTotParcels =
130 
131  const scalar totMass =
132  returnReduce(cloud.massInSystem(), sumOp<scalar>());
133 
134  const scalar Dmax = cloud.Dmax();
135  const scalar D10 = cloud.Dij(1, 0);
136  const scalar D32 = cloud.Dij(3, 2);
137 
138  Log << type() << " " << name() << " write:" << nl
139  << " number of parcels : " << nTotParcels << nl
140  << " mass in system : " << totMass << nl
141  << " maximum diameter : " << Dmax << nl
142  << " D10 diameter : " << D10 << nl
143  << " D32 diameter : " << D32 << nl
144  << endl;
145 
146  if (writeToFile())
147  {
148  auto& os = files(cloudi);
149 
150  writeCurrentTime(os);
151  os
152  << token::TAB << nTotParcels
153  << token::TAB << totMass
154  << token::TAB << Dmax
155  << token::TAB << D10
156  << token::TAB << D32
157  << endl;
158  }
159  }
160 
161  return true;
162 }
163 
164 
165 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Log
#define Log
Definition: PDRblock.C:28
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
cloudName
const word cloudName(propsDict.get< word >("cloud"))
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:63
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:88
kinematicCloud.H
Foam::read
bool read(const char *buf, int32_t &val)
Definition: int32.H:125
Foam::functionObjects::cloudInfo::execute
virtual bool execute()
Definition: cloudInfo.C:106
Foam::endl
Ostream & endl(Ostream &os)
Definition: Ostream.H:381
Foam::sumOp
Definition: ops.H:207
forAll
#define forAll(list, i)
Definition: stdFoam.H:349
Foam::functionObjects::cloudInfo::writeFileHeader
virtual void writeFileHeader(Ostream &os) const
Definition: cloudInfo.C:48
Foam::functionObjects::writeFile::writeHeader
virtual void writeHeader(Ostream &os, const string &str) const
Definition: writeFile.C:291
Foam::functionObjects::writeFile::read
virtual bool read(const dictionary &dict)
Definition: writeFile.C:206
Foam::kinematicCloud
Virtual abstract base class for templated KinematicCloud.
Definition: kinematicCloud.H:48
Foam::functionObjects::cloudInfo::cloudInfo
cloudInfo(const cloudInfo &)=delete
Foam::Info
messageStream Info
Foam::objectRegistry::lookupObject
const Type & lookupObject(const word &name, const bool recursive=false) const
Definition: objectRegistryTemplates.C:427
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:119
Foam::functionObjects::regionFunctionObject::read
virtual bool read(const dictionary &dict)
Definition: regionFunctionObject.C:166
os
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Definition: atmBoundaryLayer.C:26
PstreamReduceOps.H
Inter-processor communication reduction functions.
Foam::functionObjects::logFiles
functionObject base class for creating, maintaining and writing log files e.g. integrated or averaged...
Definition: logFiles.H:55
Foam::functionObjects::logFiles::resetNames
virtual void resetNames(const wordList &names)
Definition: logFiles.C:48
Foam::functionObjects::cloudInfo::read
virtual bool read(const dictionary &dict)
Definition: cloudInfo.C:79
Foam::cloud
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:53
Foam::functionObjects::writeFile::writeCommented
virtual void writeCommented(Ostream &os, const string &str) const
Definition: writeFile.C:265
Foam::nl
constexpr char nl
Definition: Ostream.H:424
Foam::functionObjects::addToRunTimeSelectionTable
addToRunTimeSelectionTable(functionObject, ObukhovLength, dictionary)
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:58
Foam::functionObjects::cloudInfo::write
virtual bool write()
Definition: cloudInfo.C:112
Foam::token::TAB
@ TAB
Tab [isspace].
Definition: token.H:119
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Definition: POSIX.C:717
dictionary.H
Foam::functionObjects::defineTypeNameAndDebug
defineTypeNameAndDebug(ObukhovLength, 0)
Foam::name
word name(const expressions::valueTypeCode typeCode)
Definition: exprTraits.C:52
Foam::functionObjects::regionFunctionObject
Specialization of Foam::functionObject for a region and providing a reference to the region Foam::obj...
Definition: regionFunctionObject.H:86
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:52
Foam::PtrListOps::names
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Foam::cloud::nParcels
virtual label nParcels() const
Definition: cloud.C:70
cloudInfo.H
Foam::functionObjects::writeFile::writeTabbed
virtual void writeTabbed(Ostream &os, const string &str) const
Definition: writeFile.C:281