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.
memory_info.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license:
9 // kratos/license.txt
10 //
11 // Main authors: Pooyan Dadvand
12 //
13 
14 #if !defined(KRATOS_MEMORY_INFO_H_INCLUDED)
15 #define KRATOS_MEMORY_INFO_H_INCLUDED
16 
17 // System includes
18 
19 // External includes
20 
21 // Project includes
22 #include "includes/define.h"
23 
24 namespace Kratos {
27 
30 
32 
37 class KRATOS_API(KRATOS_CORE) MemoryInfo {
38 public:
41 
44 
48 
50  MemoryInfo() = default;
51 
53  virtual ~MemoryInfo() = default;
54 
58 
67  static std::size_t GetPeakMemoryUsage();
68 
76  static std::size_t GetCurrentMemoryUsage();
77 
78  static std::string HumanReadableSize(std::size_t InBytes);
79 
83 
85  virtual std::string Info() const { return "MemoryInfo"; }
86 
88  virtual void PrintInfo(std::ostream &rOStream) const { rOStream << Info(); }
89 
91  virtual void PrintData(std::ostream &rOStream) const
92  {
93  rOStream << "Current Memory Usage : "
94  << HumanReadableSize(GetCurrentMemoryUsage()) << std::endl;
95  rOStream << "Peak Memory Usage : "
96  << HumanReadableSize(GetPeakMemoryUsage()) << std::endl;
97  }
98 
100 
101 private:
104 
106  MemoryInfo &operator=(MemoryInfo const &rOther);
107 
109  MemoryInfo(MemoryInfo const &rOther);
110 
112 
113 }; // Class MemoryInfo
114 
116 
119 
123 
125 inline std::istream &operator>>(std::istream &rIStream, MemoryInfo &rThis);
126 
128 inline std::ostream &operator<<(std::ostream &rOStream,
129  const MemoryInfo &rThis) {
130  rThis.PrintInfo(rOStream);
131  rOStream << std::endl;
132  rThis.PrintData(rOStream);
133 
134  return rOStream;
135 }
137 
139 
140 } // namespace Kratos.
141 
142 #endif // KRATOS_MEMORY_INFO_H_INCLUDED defined
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
MemoryInfo gives the OS information about the memory usage by Kratos.
Definition: memory_info.h:37
MemoryInfo()=default
Default constructor.
virtual ~MemoryInfo()=default
Destructor.
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: memory_info.h:88
virtual std::string Info() const
Turn back information as a string.
Definition: memory_info.h:85
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: memory_info.h:91
KRATOS_CLASS_POINTER_DEFINITION(MemoryInfo)
Pointer definition of MemoryInfo.
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432