https://mooseframework.inl.gov
DebugRay.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 // The following can be uncommented for detailed output for
11 // the trace of a Ray or multiple Rays
12 // #define DEBUG_RAY_IF (*_current_ray)->id() == 0
13 // #define DEBUG_RAY_MESH_IF (*_current_ray)->id() == 0
14 // #define DEBUG_RAY_INTERSECTIONS
15 
16 #include "MooseError.h"
17 
18 #ifndef DEBUG_RAY_IF
19 #define debugRay(...) ((void)0)
20 #else
21 #define debugRay(...) \
22  if (DEBUG_RAY_IF) \
23  { \
24  std::ostringstream ss; \
25  moose::internal::mooseStreamAll(ss, __VA_ARGS__); \
26  libMesh::err << "[pid/tid/id/line:" << _pid << "/" << _tid << "/" << (*_current_ray)->id() \
27  << "/" << std::setw(4) << std::left << __LINE__ << "]: " << ss.str() << std::endl \
28  << std::flush; \
29  }
30 #endif
31 
32 #ifndef DEBUG_RAY_INTERSECTIONS
33 #define debugRaySimple(...) ((void)0)
34 #else
35 #define debugRaySimple(...) \
36  if (debug) \
37  { \
38  std::ostringstream ss; \
39  moose::internal::mooseStreamAll(ss, __VA_ARGS__); \
40  libMesh::err << ss.str() << std::endl << std::flush; \
41  }
42 #endif
43 
44 #ifndef DEBUG_RAY_MESH_IF
45 #define possiblySaveDebugRayMesh() ((void)0)
46 #else
47 #define possiblySaveDebugRayMesh() \
48  if (DEBUG_RAY_MESH_IF && _debug_mesh) \
49  { \
50  _debug_mesh->prepare_for_use(); \
51  _debug_mesh->write("debug_ray" + std::to_string((*_current_ray)->id()) + "_pc" + \
52  std::to_string((*_current_ray)->processorCrossings()) + "_pid" + \
53  std::to_string(_pid) + ".e"); \
54  delete _debug_mesh; \
55  }
56 #endif
57 
58 #ifndef DEBUG_RAY_MESH_IF
59 #define possiblyAddDebugRayMeshPoint(start, end) ((void)0)
60 #else
61 #define possiblyAddDebugRayMeshPoint(start, end) \
62  if (_debug_mesh && DEBUG_RAY_MESH_IF) \
63  { \
64  _debug_mesh->add_point(start); \
65  _debug_node_count++; \
66  _debug_mesh->add_point(end); \
67  _debug_node_count++; \
68  \
69  Elem * elem = Elem::build(EDGE2).release(); \
70  elem->subdomain_id() = 0; \
71  \
72  elem = _debug_mesh->add_elem(elem); \
73  \
74  elem->set_node(0, _debug_mesh->node_ptr((_debug_node_count - 2))); \
75  elem->set_node(1, _debug_mesh->node_ptr((_debug_node_count - 2) + 1)); \
76  }
77 #endif