GranOO  3.0
A robust and versatile workbench to build 3D dynamic simulations based on the Discrete Element Method
Problem.hpp
Go to the documentation of this file.
1 // This file is part of GranOO, a workbench for DEM simulation.
2 //
3 // Author(s) : - Damien Andre IRCER/UNILIM, Limoges France
4 // <damien.andre@unilim.fr>
5 // - Jean-luc Charles Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
6 // <jean-luc.charles@ensam.eu>
7 // - Jeremie Girardot Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
8 // <jeremie.girardot@ensam.eu>
9 // - Cedric Hubert LAMIH/UPHF, Valenciennes France
10 // <cedric.hubert@uphf.fr>
11 // - Ivan Iordanoff Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
12 // <ivan.iordanoff@ensam.eu>
13 //
14 // Copyright (C) 2008-2019 D. Andre, JL. Charles, J. Girardot, C. Hubert, I. Iordanoff
15 //
16 // This program is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 // This program is distributed in the hope that it will be useful,
22 // but WITHOUT ANY WARRANTY; without_even the implied warranty of
23 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 // GNU General Public License for more details.
25 //
26 // You should have received a copy of the GNU General Public License
27 // along with this program. If not, see <http://www.gnu.org/licenses/>.
28 
29 
30 #ifndef _LibCore_Problem_HPP
31 #define _LibCore_Problem_HPP
32 
33 #include <string>
34 #include <vector>
35 #include <boost/filesystem/path.hpp>
36 #include <boost/program_options.hpp>
37 #include <chrono>
38 
41 #include "GranOO3/Core/PlugIn.hpp"
43 #include "GranOO3/Physic/Time.hpp"
44 
47 #include "GranOO3/Core/Logger.hpp"
48 #include "GranOO3/Core/Status.hpp"
51 
52 
53 class TiXmlElement;
54 
55 namespace GranOO3
56 {
57  namespace Core
58  {
59  class Problem : Core::Singleton<Problem>
60  {
61  GRANOO_SINGLETON_CLASS(Problem);
62 
63  public:
64  void run(int, char* []);
65  void run(const std::string &, const std::string &);
66  void end();
67  void stop(const std::string why = "");
68 
69  // Input file management
70  void read_xml_input_file(std::string inputFile);
71 
72  // Process management
73  void run_root_plugin();
74  std::string status() const;
75 
76  // Directory management
77  const boost::filesystem::path& get_output_directory() const;
78 
79  // PlugIn management
80  template<class P> P& get_plugin(unsigned int plugRank = 0);
81  template<class P> const P& get_plugin(unsigned int plugRank = 0) const;
82 
83  GRANOO_ACCESS_REF(root_plugin, std::vector<Core::PlugIn*>, _root_plugin)
84 
85  unsigned int status_UID() const;
86 
87  void set_current_status(const std::string&);
89  unsigned int get_total_number_of_thread();
90  const Core::PlugIn& get_current_plugin() const;
91  std::string get_current_plugin_ID() const;
92 
93  void store_file(const std::string& fileName, const std::string& content, const std::string desc = "");
94 
95  protected:
96  Problem();
97  ~Problem();
98 
99  private:
100  Problem & operator=(const Problem & source) = delete;
101  Problem(const Problem & source) = delete;
102 
103  void init_math();
104 
111 
112  protected:
113  std::vector<Core::PlugIn*> _root_plugin;
114  std::vector<boost::filesystem::path> _all_sample_file;
115  std::string _current_status;
118  unsigned int _status_UID;
119  std::map<const std::string, std::string> _all_stored_file;
120  };
121 
122 #ifndef DOXYGEN_SHOULD_SKIP_THIS
123 
124  inline void
125  Problem::set_current_status(const std::string& status) {
127  _status_UID++;
128  }
129 
130  inline unsigned int
131  Problem::status_UID() const {
132  return _status_UID;
133  }
134 
135  template<class P>
136  inline P&
137  Problem::get_plugin(unsigned int plugRank) {
138  return Core::PlugInInterface<P>::get(plugRank);
139  }
140 
141  template<class P>
142  inline const P&
143  Problem::get_plugin(unsigned int plugRank) const {
144  return Core::PlugInInterface<P>::get(plugRank);
145  }
146 
147 #endif
148  }
149 }
150 
151 #endif
Definition: IOManager.hpp:53
Definition: Logger.hpp:48
Definition: PlugIn.hpp:101
static T & get(unsigned int=0)
Definition: PlugIn.hpp:213
Definition: Problem.hpp:60
XmlReader _xml
Definition: Problem.hpp:106
std::string _current_status
Definition: Problem.hpp:115
std::vector< Core::PlugIn * > _root_plugin
Definition: Problem.hpp:113
IOManager _io
Definition: Problem.hpp:105
P & get_plugin(unsigned int plugRank=0)
const Core::PlugIn & get_current_plugin() const
Definition: Problem.cpp:369
void end()
Definition: Problem.cpp:221
void stop(const std::string why="")
Definition: Problem.cpp:248
Problem()
Definition: Problem.cpp:75
~Problem()
Definition: Problem.cpp:86
void store_file(const std::string &fileName, const std::string &content, const std::string desc="")
Definition: Problem.cpp:358
void set_current_plugin(Core::PlugIn *)
Definition: Problem.cpp:384
void read_xml_input_file(std::string inputFile)
Definition: Problem.cpp:324
const P & get_plugin(unsigned int plugRank=0) const
void run_root_plugin()
Definition: Problem.cpp:289
Core::PlugIn * _current_root_plugin
Definition: Problem.hpp:116
TimeManager _watch
Definition: Problem.hpp:109
Status _st
Definition: Problem.hpp:107
unsigned int get_total_number_of_thread()
Definition: Problem.cpp:353
void set_current_status(const std::string &)
Problem(const Problem &source)=delete
std::string status() const
Definition: Problem.cpp:258
std::string get_current_plugin_ID() const
Definition: Problem.cpp:375
Core::PlugIn * _current_plugin
Definition: Problem.hpp:117
Problem & operator=(const Problem &source)=delete
void run(int, char *[])
Definition: Problem.cpp:112
Core::Logger _log
Definition: Problem.hpp:110
std::map< const std::string, std::string > _all_stored_file
Definition: Problem.hpp:119
std::vector< boost::filesystem::path > _all_sample_file
Definition: Problem.hpp:114
ThreadManager _thr
Definition: Problem.hpp:108
const boost::filesystem::path & get_output_directory() const
Definition: Problem.cpp:349
unsigned int _status_UID
Definition: Problem.hpp:118
void init_math()
Definition: Problem.cpp:299
Definition: Singleton.hpp:75
Definition: Status.hpp:43
Definition: ThreadManager.hpp:41
Definition: TimeManager.hpp:46
Definition: XmlReader.hpp:49
static const char * desc
Definition: Between2SetOf.cpp:37
Definition: Common.hpp:198