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.
debug_helpers.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: Suneth Warnakulasuriya
11 //
12 
13 #if !defined(KRATOS_DEBUG_HELPERS_H_INCLUDED)
14 #define KRATOS_DEBUG_HELPERS_H_INCLUDED
15 
16 /* System includes */
17 #include <sstream>
18 #include <iomanip>
19 
20 /* External includes */
21 
22 /* Project includes */
23 
24 // Print vector values with precision
25 #define KRATOS_WATCH_VECTOR_WITH_PRECISION(variable, precision) \
26  { \
27  std::stringstream values; \
28  values << std::scientific << std::setprecision(precision); \
29  for (std::size_t i = 0; i < variable.size(); i++) \
30  { \
31  values << #variable << "[" << i << "] = " << variable[i] << ";" << std::endl; \
32  } \
33  std::cout << #variable << " : " << std::endl \
34  << values.str() << std::endl; \
35  }
36 
37 // Print matrix values with precision
38 #define KRATOS_WATCH_MATRIX_WITH_PRECISION(variable, precision) \
39  { \
40  std::stringstream values; \
41  values << std::scientific << std::setprecision(precision); \
42  for (std::size_t i = 0; i < variable.size1(); i++) \
43  { \
44  for (std::size_t j = 0; j < variable.size2(); j++) \
45  { \
46  values << #variable << "(" << i << ", " << j \
47  << ") = " << variable(i, j) << ";" << std::endl; \
48  } \
49  } \
50  std::cout << #variable << " : " << std::endl \
51  << values.str() << std::endl; \
52  }
53 
54 // Cout a message with appended line and function information.
55 #define KRATOS_WATCH_LINE(...) std::cout << __VA_ARGS__ << KRATOS_CODE_LOCATION << std::endl
56 
57 #endif /* KRATOS_DEBUG_HELPERS_H_INCLUDED defined */