Chi-Tech
devman_01_04_globalvars.h
Go to the documentation of this file.
1
/**\page DevManGlobalVars Global variables
2
3
\section devman2_sec0 Global variables available
4
5
All global entities for the ChiTech library are contained within the
6
static `chi` class. This class has the name `chi` and an instance of it
7
cannot be created. Within this class, all of its members are statically
8
declared. Several singleton objects are defined in `chi`, they are:
9
- chi::mpi A handler for parallel related items.
10
- chi::program_timer The primary program timer.
11
- chi::console The link to the lua scripting engine.
12
- chi::log A handler for parallel logging events and verbosity.
13
14
A number of stacks are also declared. They are basically arrays of
15
shared pointers (i.e., `std::shared_ptr`)
16
17
There are also a number of secondary global variables that assist developers
18
with coding. They are:
19
- ```chi::run_time::input_file_name``` Holds the input file name if supplied.
20
- ```chi::run_time::termination_posted``` A flag used during interactive mode.
21
- ```chi::run_time::sim_option_interactive``` A flag indicating whether the code is
22
run in interactive mode.
23
- ```chi::run_time::allow_petsc_error_handler``` A flag indicating whether the allow
24
the native PETSC error handler.
25
26
27
28
\subsection devman2_sec0_3 Connecting to the global data block
29
30
The stack items stored within `chi` can be accessed either by reference or as a
31
`std::shared_ptr`. The two functions that facilitate this are as follows:
32
33
\code
34
#include "chi_runtime.h"
35
#include "mesh/SurfaceMesh/chi_surfacemesh.h" //Just an example
36
37
void SomeFunction()
38
{
39
int handle = 2;
40
auto& chi::GetStackItem<chi_mesh::SurfaceMeshPtr>(chi::surface_mesh_stack,
41
handle);
42
//or
43
auto chi::GetStackItemPtr<chi_mesh::SurfaceMeshPtr>(chi::surface_mesh_stack,
44
handle);
45
}
46
\endcode
47
48
There are multiple stacks, currently (which might not be still accurate):
49
\code
50
chi::meshhandler_stack;
51
chi::surface_mesh_stack;
52
chi::logicvolume_stack;
53
chi::field_func_interpolation_stack;
54
chi::unpartitionedmesh_stack;
55
chi::solver_stack;
56
chi::material_stack;
57
chi::trnsprt_xs_stack;
58
chi::fieldfunc_stack;
59
chi::quadrature_stack;
60
chi::angular_quadrature_stack;
61
\endcode
62
63
\subsection devman2_sec0_4 Connecting to MPI
64
65
General MPI information like the current location id and the total amount
66
of parallel processes is contained in CHI_MPI:
67
- chi_objects::MPI_Info::location_id
68
- chi_objects::MPI_Info::process_count
69
70
Additionally, by including the headers for chi_mpi, developers have access to
71
all the classic mpi headers.
72
73
\code
74
#include "chi_runtime.h"
75
#include "chi_mpi.h"
76
77
if (chi::mpi.location_id == 1)
78
printf("This is process 1, Dab!");
79
\endcode
80
81
\subsection devman2_sec0_5 Connecting to the parallel logging utility
82
83
Printing information in a parallel environment can be a very involved
84
process. One can't simply use `std::cout <<` on every process otherwise
85
the output to the log will be chaotic. For this reason we employ a common
86
logging utility which returns an output string-stream using the function
87
call ChiLog::Log.
88
89
Connecting to chi::log is done as follows
90
\code
91
#include "chi_runtime.h"
92
#include "chi_log.h"
93
94
void Function()
95
{
96
chi::log.Log() << "Hello from location 0";
97
chi::log.LogAll() << "Hello from all locations";
98
}
99
\endcode
100
101
The logger has calls of differing verbosity:
102
- `chi_objects::ChiLog::Log0()`, Used only for location 0
103
- `chi_objects::ChiLog::Log0Warning()`, Warning only for location 0
104
- `chi_objects::ChiLog::Log0Error()`, Error only for location 0
105
- `chi_objects::ChiLog::Log0Verbose0()`, Default verbosity level
106
- `chi_objects::ChiLog::Log0Verbose1()`, Used only if verbosity level equals 1
107
- `chi_objects::ChiLog::Log0Verbose2()`, Used only if verbosity level equals 2
108
- `chi_objects::ChiLog::LogAll()`, Verbose level 0 all locations
109
- `chi_objects::ChiLog::LogAllWarning()`, Warning for any location
110
- `chi_objects::ChiLog::LogAllError()`, Error for any location
111
- `chi_objects::ChiLog::LogAllVerbose0()`, Default verbosity level
112
- `chi_objects::ChiLog::LogAllVerbose1()`, Used only if verbosity level equals 1
113
- `chi_objects::ChiLog::LogAllVerbose2()`, Used only if verbosity level equals 2
114
115
116
117
\todo Commandline parameter documentation
118
119
120
*/
doc
PAGES
ProgrammersManual
devman_01_04_globalvars.h
Generated by
1.9.3