forked from openmc-dev/openmc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbank.cpp
72 lines (58 loc) · 1.8 KB
/
bank.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "openmc/bank.h"
#include "openmc/capi.h"
#include "openmc/error.h"
#include <cstdint>
// Explicit template instantiation definition
template class std::vector<openmc::Particle::Bank>;
namespace openmc {
//==============================================================================
// Global variables
//==============================================================================
namespace simulation {
std::vector<Particle::Bank> source_bank;
std::vector<Particle::Bank> fission_bank;
std::vector<Particle::Bank> secondary_bank;
#ifdef _OPENMP
std::vector<Particle::Bank> master_fission_bank;
#endif
} // namespace simulation
//==============================================================================
// Non-member functions
//==============================================================================
void free_memory_bank()
{
simulation::source_bank.clear();
#pragma omp parallel
{
simulation::fission_bank.clear();
}
#ifdef _OPENMP
simulation::master_fission_bank.clear();
#endif
}
//==============================================================================
// C API
//==============================================================================
extern "C" int openmc_source_bank(void** ptr, int64_t* n)
{
if (simulation::source_bank.size() == 0) {
set_errmsg("Source bank has not been allocated.");
return OPENMC_E_ALLOCATE;
} else {
*ptr = simulation::source_bank.data();
*n = simulation::source_bank.size();
return 0;
}
}
extern "C" int openmc_fission_bank(void** ptr, int64_t* n)
{
if (simulation::fission_bank.size() == 0) {
set_errmsg("Fission bank has not been allocated.");
return OPENMC_E_ALLOCATE;
} else {
*ptr = simulation::fission_bank.data();
*n = simulation::fission_bank.size();
return 0;
}
}
} // namespace openmc