www.cemf.ir
systemControl.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 
22 #ifndef __systemControl_hpp__
23 #define __systemControl_hpp__
24 
25 
26 // top-level entity repository for the whole application
27 // Each application that is executed in pFlow, should have
28 // settings/systemControl file in it.
29 
30 
31 #include "types.hpp"
32 #include "Time.hpp"
33 #include "fileDictionary.hpp"
34 #include "Timers.hpp"
35 #include "dynamicLinkLibs.hpp"
36 #include "Set.hpp"
37 
38 namespace pFlow
39 {
40 
42 :
43  public repository
44 {
45 protected:
46 
47  // run name
48  const word runName_;
49 
50  // - path to top-level folder
52 
55 
58 
61 
64 
67 
69  size_t outFilePrecision_ = 6;
70 
71 
73  bool externalTimeControl_ = false;
74 
75  // all timers
77 
79 
81 
83 
85 
86 
87  bool readIncludeExclue(const dictionary& dict);
88 
89  static word getRunName( const fileSystem& path);
90 
91  static word getTopFolder(const fileSystem& path);
92 
93 
94 public:
95 
96  systemControl(const fileSystem path = CWD());
97 
99  const real startTime,
100  const real endTime,
101  const real saveInterval,
102  const word startTimeName,
103  const fileSystem path = CWD() );
104 
105  const repository& settings() const{
106  return settings_();
107  }
108 
110  return settings_();
111  }
112 
113  const repository& caseSetup()const{
114  return caseSetup_();
115  }
116 
118  return caseSetup_();
119  }
120 
121 
122  const Time& time() const
123  {
124  return Time_;
125  }
126 
128  {
129  return Time_;
130  }
131 
132  const repository& geometry()const
133  {
134  return Time_.geometry();
135  }
136 
138  {
139  return Time_.geometry();
140  }
141 
142  const Timers& timers()const
143  {
144  return timers_;
145  }
146 
148  {
149  return timers_;
150  }
151 
152  inline bool timersReport()const
153  {
154  return timersReport_();
155  }
156 
158  return settingsDict_();
159  }
160 
162  return settingsDict_();
163  }
164 
165  //fileDictionary& domainDict();
166 
167 
168  virtual word runName() const
169  {
170  return runName_;
171  }
172 
173  inline const realx3 g()const
174  {
175  return settingsDict_().getVal<realx3>("g");
176  }
177 
178  bool operator ++(int);
179 
181  bool saveToFile,
182  const word& timeName = "wrongTimeFolder")
183  {
184  Time_.setSaveTimeFolder(saveToFile, timeName);
185  }
186 
187  size_t outFilePrecision() const override
188  {
189  return outFilePrecision_;
190  }
191 
192 
193  bool isIncluded(const word& objName)const final
194  {
195  return includeList_.count(objName) == static_cast<size_t>(1);
196  }
197 
198 
199  bool isExcluded(const word& objName)const final
200  {
201  return excludeList_.count(objName) == static_cast<size_t>(1);
202  }
203 
205  {
206  includeList_.clear();
207  excludeList_.clear();
208  }
209 
210  bool addInclude(const word& objName)
211  {
212  auto [iter, success] = includeList_.insert(objName);
213  return success;
214  }
215 
216  bool addExclude(const word& objName)
217  {
218  auto [ite, success] = excludeList_.insert(objName);
219  return success;
220  }
221 
222 };
223 
224 
225 
226 } // pFlow
227 
228 
229 #endif // __systemControl_hpp__
pFlow::systemControl::settings
repository & settings()
Definition: systemControl.hpp:109
pFlow::systemControl::isIncluded
bool isIncluded(const word &objName) const final
Definition: systemControl.hpp:193
pFlow::systemControl::setSaveTimeFolder
void setSaveTimeFolder(bool saveToFile, const word &timeName="wrongTimeFolder")
Definition: systemControl.hpp:180
pFlow::systemControl::writeToFileTimer_
Timer writeToFileTimer_
Definition: systemControl.hpp:80
pFlow::systemControl::topLevelFolder_
const fileSystem topLevelFolder_
Definition: systemControl.hpp:51
pFlow::systemControl::timers
Timers & timers()
Definition: systemControl.hpp:147
pFlow::systemControl::caseSetup
repository & caseSetup()
Definition: systemControl.hpp:117
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::systemControl::addInclude
bool addInclude(const word &objName)
Definition: systemControl.hpp:210
pFlow::systemControl::clearIncludeExclude
void clearIncludeExclude()
Definition: systemControl.hpp:204
Set.hpp
pFlow::systemControl::timersReport
bool timersReport() const
Definition: systemControl.hpp:152
types.hpp
pFlow::systemControl::g
const realx3 g() const
Definition: systemControl.hpp:173
pFlow::systemControl::isExcluded
bool isExcluded(const word &objName) const final
Definition: systemControl.hpp:199
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::systemControl::readIncludeExclue
bool readIncludeExclue(const dictionary &dict)
Definition: systemControl.cpp:28
pFlow::systemControl
Definition: systemControl.hpp:41
pFlow::systemControl::timers_
Timers timers_
Definition: systemControl.hpp:76
pFlow::systemControl::outFilePrecision_
size_t outFilePrecision_
precision for writing to file
Definition: systemControl.hpp:69
pFlow::Time::geometry
const repository & geometry() const
Definition: Time.hpp:68
pFlow::systemControl::settingsDict_
uniquePtr< fileDictionary > settingsDict_
settingsDict fileDictionary
Definition: systemControl.hpp:54
pFlow::Timers
Definition: Timers.hpp:32
pFlow::systemControl::outFilePrecision
size_t outFilePrecision() const override
Definition: systemControl.hpp:187
pFlow::systemControl::caseSetup
const repository & caseSetup() const
Definition: systemControl.hpp:113
pFlow::systemControl::settingsDict
fileDictionary & settingsDict()
Definition: systemControl.hpp:161
pFlow
Definition: demGeometry.hpp:27
pFlow::systemControl::runName_
const word runName_
Definition: systemControl.hpp:48
pFlow::systemControl::geometry
repository & geometry()
Definition: systemControl.hpp:137
pFlow::fileSystem
Manages file pathes, manupulate and combines them.
Definition: fileSystem.hpp:71
pFlow::systemControl::getTopFolder
static word getTopFolder(const fileSystem &path)
Definition: systemControl.cpp:75
pFlow::systemControl::systemControl
systemControl(const fileSystem path=CWD())
Definition: systemControl.cpp:100
pFlow::systemControl::timersReport_
Logical timersReport_
Definition: systemControl.hpp:78
pFlow::systemControl::caseSetup_
uniquePtr< repository > caseSetup_
caseSetup folder repository
Definition: systemControl.hpp:63
pFlow::systemControl::time
const Time & time() const
Definition: systemControl.hpp:122
pFlow::Timer
Definition: Timer.hpp:33
pFlow::systemControl::addExclude
bool addExclude(const word &objName)
Definition: systemControl.hpp:216
Time.hpp
pFlow::systemControl::getRunName
static word getRunName(const fileSystem &path)
Definition: systemControl.cpp:50
pFlow::systemControl::time
Time & time()
Definition: systemControl.hpp:127
pFlow::dynamicLinkLibs
Definition: dynamicLinkLibs.hpp:32
pFlow::systemControl::settingsDict
const fileDictionary & settingsDict() const
Definition: systemControl.hpp:157
pFlow::systemControl::settings
const repository & settings() const
Definition: systemControl.hpp:105
pFlow::repository::path
virtual fileSystem path() const
Definition: repository.cpp:70
pFlow::systemControl::Time_
Time Time_
time repository
Definition: systemControl.hpp:57
pFlow::systemControl::operator++
bool operator++(int)
Definition: systemControl.cpp:182
pFlow::systemControl::settings_
uniquePtr< repository > settings_
settings folder repository
Definition: systemControl.hpp:60
pFlow::Logical
Holds a bool value and converts strings to bool.
Definition: Logical.hpp:39
fileDictionary.hpp
Timers.hpp
pFlow::systemControl::geometry
const repository & geometry() const
Definition: systemControl.hpp:132
pFlow::fileDictionary
Definition: fileDictionary.hpp:29
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
dynamicLinkLibs.hpp
pFlow::systemControl::runName
virtual word runName() const
Definition: systemControl.hpp:168
pFlow::wordSet
Set< word > wordSet
Definition: Set.hpp:35
pFlow::systemControl::includeList_
wordSet includeList_
Definition: systemControl.hpp:82
pFlow::CWD
fileSystem CWD()
Free function to reture current working directory.
Definition: fileSystem.hpp:221
pFlow::repository
Definition: repository.hpp:34
pFlow::systemControl::excludeList_
wordSet excludeList_
Definition: systemControl.hpp:84
pFlow::timeControl::setSaveTimeFolder
void setSaveTimeFolder(bool saveToFile, const word &timeName="wrongTimeFolder")
Definition: timeControl.cpp:192
pFlow::triple< real >
pFlow::systemControl::libs_
dynamicLinkLibs libs_
extra libs to be loaded
Definition: systemControl.hpp:66
pFlow::dictionary
Dictionary holds a set of data entries or sub-dictionaries that are enclosed in a curely braces or ar...
Definition: dictionary.hpp:67
pFlow::systemControl::externalTimeControl_
bool externalTimeControl_
if time control is managed externaly
Definition: systemControl.hpp:73
pFlow::systemControl::timers
const Timers & timers() const
Definition: systemControl.hpp:142
pFlow::Time
Definition: Time.hpp:37