KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
builtin_timer.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Michael Andre
11 //
12 //
13 
14 #pragma once
15 
16 // System includes
17 #include <chrono>
18 
19 namespace Kratos
20 {
21 
24 
26 {
27 public:
30 
32  BuiltinTimer() : mStartTime{std::chrono::steady_clock::now()}
33  {
34  }
35 
39 
40  inline double ElapsedSeconds() const
41  {
42  using namespace std::chrono;
43  const auto current_time = steady_clock::now();
44  return duration_cast<duration<double>>(current_time - mStartTime).count();
45  }
46 
48 
49 private:
52 
53  const std::chrono::steady_clock::time_point mStartTime;
54 
56 };
57 
59 
61 inline std::ostream& operator << (std::ostream& rOStream, const BuiltinTimer& rThis)
62 {
63  const double elapsed_secs = rThis.ElapsedSeconds();
64 
65  int minutes = elapsed_secs / 60;
66  int hours = minutes / 60;
67  minutes = minutes % 60;
68  double seconds = elapsed_secs - hours*3600.0 - minutes*60.0;
69 
70  if (hours > 0) {
71  rOStream << hours << " [h] ";
72  }
73  if (minutes > 0) {
74  rOStream << minutes << " [m] ";
75  // remove decimals if over a minute
76  seconds = int(seconds);
77  }
78  rOStream << seconds << " [s]";
79  return rOStream;
80 
81 }
82 
83 } // namespace Kratos.
Definition: builtin_timer.h:26
BuiltinTimer()
Default constructor.
Definition: builtin_timer.h:32
double ElapsedSeconds() const
Definition: builtin_timer.h:40
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
int count
Definition: generate_frictional_mortar_condition.py:212
namespace
Definition: array_1d.h:793