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:35
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
cloudName
const word cloudName(propsDict.get< word >("cloud"))
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:94
kinematicCloud.H
Foam::read
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition: int32.H:108
Foam::functionObjects::cloudInfo::execute
virtual bool execute()
Execute, currently does nothing.
Definition: cloudInfo.C:113
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::sumOp
Definition: ops.H:213
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::functionObjects::cloudInfo::writeFileHeader
virtual void writeFileHeader(Ostream &os) const
File header information.
Definition: cloudInfo.C:55
Foam::functionObjects::writeFile::writeHeader
virtual void writeHeader(Ostream &os, const string &str) const
Write a commented header to stream.
Definition: writeFile.C:298
Foam::functionObjects::writeFile::read
virtual bool read(const dictionary &dict)
Read.
Definition: writeFile.C:213
Foam::kinematicCloud
Virtual abstract base class for templated KinematicCloud.
Definition: kinematicCloud.H:52
Foam::functionObjects::cloudInfo::cloudInfo
cloudInfo(const cloudInfo &)=delete
No copy construct.
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::objectRegistry::lookupObject
const Type & lookupObject(const word &name, const bool recursive=false) const
Definition: objectRegistryTemplates.C:434
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:123
Foam::functionObjects::regionFunctionObject::read
virtual bool read(const dictionary &dict)
Read optional controls.
Definition: regionFunctionObject.C:173
os
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
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:59
Foam::functionObjects::logFiles::resetNames
virtual void resetNames(const wordList &names)
Reset the list of names from a wordList.
Definition: logFiles.C:55
Foam::functionObjects::cloudInfo::read
virtual bool read(const dictionary &dict)
Read the controls.
Definition: cloudInfo.C:86
Foam::cloud
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:57
Foam::functionObjects::writeFile::writeCommented
virtual void writeCommented(Ostream &os, const string &str) const
Write a commented string to stream.
Definition: writeFile.C:272
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::functionObjects::addToRunTimeSelectionTable
addToRunTimeSelectionTable(functionObject, ObukhovLength, dictionary)
Foam::List< word >
Foam::functionObjects::cloudInfo::write
virtual bool write()
Write.
Definition: cloudInfo.C:119
Foam::token::TAB
Tab [isspace].
Definition: token.H:123
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
dictionary.H
Foam::functionObjects::defineTypeNameAndDebug
defineTypeNameAndDebug(ObukhovLength, 0)
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::functionObjects::regionFunctionObject
Specialization of Foam::functionObject for a region and providing a reference to the region Foam::obj...
Definition: regionFunctionObject.H:90
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::PtrListOps::names
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Foam::cloud::nParcels
virtual label nParcels() const
Number of parcels for the hosting cloud.
Definition: cloud.C:77
cloudInfo.H
Foam::functionObjects::writeFile::writeTabbed
virtual void writeTabbed(Ostream &os, const string &str) const
Write a tabbed string to stream.
Definition: writeFile.C:288