GranOO  3.0
A robust and versatile workbench to build 3D dynamic simulations based on the Discrete Element Method
Time.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 _LibPhysic_Time_H
31 #define _LibPhysic_Time_H
32 
33 #include <map>
34 #include <string>
35 
36 #include "GranOO3/Core/Macro.hpp"
37 
38 
39 namespace GranOO3
40 {
41  namespace Physic
42  {
43 
44  class Time
45  {
46 
47  public:
48  static Time& get();
49  static Time& get(const std::string& id);
50  static Time& glob(const std::string& id);
51  static void increment_all();
52  static std::string class_ID() {
53  return "Physic::Time";
54  }
55 
56  public:
57  Time(const std::string id);
58  ~Time();
59 
60  unsigned int iteration() const;
61  unsigned int get_iteration() const;
62  void set_iteration(unsigned int);
63  std::string iteration_to_string(unsigned int stringSize = 12) const;
64 
65  double& iteration_double();
66 
67  GRANOO_ACCESS(time_step, double, _time_step);
68  GRANOO_ACCESS(elapsed_time, double, _elapsed_time);
69 
70  void increment();
71  void decrement();
72 
73  private:
74  Time(const Time&) = delete;
75  Time & operator=(const Time &) = delete;
76 
77  protected:
78  static Time* _main;
79  static std::map<std::string, Time*> _all;
80 
81  private:
82  const std::string _ID;
83  double _iteration;
84  double _time_step;
85  double _elapsed_time;
86  };
87 
88 #ifndef DOXYGEN_SHOULD_SKIP_THIS
89 
90 
91 #endif
92  }
93 }
94 
95 
96 #endif
97 
Definition: Time.hpp:45
void increment()
Definition: Time.cpp:79
double _time_step
Definition: Time.hpp:84
double & iteration_double()
Definition: Time.cpp:117
static Time & get()
Definition: Time.cpp:42
static std::string class_ID()
Definition: Time.hpp:52
~Time()
Definition: Time.cpp:73
Time(const std::string id)
Definition: Time.cpp:63
static Time * _main
Definition: Time.hpp:78
double _elapsed_time
Definition: Time.hpp:85
unsigned int iteration() const
Definition: Time.cpp:97
static void increment_all()
Definition: Time.cpp:91
void decrement()
Definition: Time.cpp:85
static std::map< std::string, Time * > _all
Definition: Time.hpp:79
double _iteration
Definition: Time.hpp:83
std::string iteration_to_string(unsigned int stringSize=12) const
Definition: Time.cpp:107
Time(const Time &)=delete
unsigned int get_iteration() const
Definition: Time.cpp:102
Time & operator=(const Time &)=delete
void set_iteration(unsigned int)
Definition: Time.cpp:112
const std::string _ID
Definition: Time.hpp:82
static Time & glob(const std::string &id)
Definition: Time.cpp:59
Definition: Common.hpp:198