forked from celeritas-project/celeritas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImportedDataTestBase.cc
146 lines (127 loc) · 5.25 KB
/
ImportedDataTestBase.cc
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//----------------------------------*-C++-*----------------------------------//
// Copyright 2023-2024 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file celeritas/ImportedDataTestBase.cc
//---------------------------------------------------------------------------//
#include "ImportedDataTestBase.hh"
#include "celeritas/geo/GeoMaterialParams.hh"
#include "celeritas/io/ImportData.hh"
#include "celeritas/mat/MaterialParams.hh"
#include "celeritas/optical/CerenkovParams.hh"
#include "celeritas/optical/OpticalPropertyParams.hh"
#include "celeritas/optical/ScintillationParams.hh"
#include "celeritas/phys/CutoffParams.hh"
#include "celeritas/phys/ParticleParams.hh"
#include "celeritas/phys/PhysicsParams.hh"
#include "celeritas/phys/ProcessBuilder.hh"
#include "celeritas/track/SimParams.hh"
namespace celeritas
{
namespace test
{
//---------------------------------------------------------------------------//
auto ImportedDataTestBase::build_process_options() const
-> ProcessBuilderOptions
{
return {};
}
//---------------------------------------------------------------------------//
auto ImportedDataTestBase::build_physics_options() const -> PhysicsOptions
{
PhysicsOptions options;
options.secondary_stack_factor = 3.0;
return options;
}
//---------------------------------------------------------------------------//
auto ImportedDataTestBase::build_material() -> SPConstMaterial
{
return MaterialParams::from_import(this->imported_data());
}
//---------------------------------------------------------------------------//
auto ImportedDataTestBase::build_geomaterial() -> SPConstGeoMaterial
{
return GeoMaterialParams::from_import(
this->imported_data(), this->geometry(), this->material());
}
//---------------------------------------------------------------------------//
auto ImportedDataTestBase::build_particle() -> SPConstParticle
{
return ParticleParams::from_import(this->imported_data());
}
//---------------------------------------------------------------------------//
auto ImportedDataTestBase::build_cutoff() -> SPConstCutoff
{
return CutoffParams::from_import(
this->imported_data(), this->particle(), this->material());
}
//---------------------------------------------------------------------------//
auto ImportedDataTestBase::build_sim() -> SPConstSim
{
return SimParams::from_import(this->imported_data(), this->particle());
}
//---------------------------------------------------------------------------//
auto ImportedDataTestBase::build_physics() -> SPConstPhysics
{
using IPC = celeritas::ImportProcessClass;
PhysicsParams::Input input;
input.materials = this->material();
input.particles = this->particle();
input.options = this->build_physics_options();
input.action_registry = this->action_reg().get();
// Build proceses
auto const& imported = this->imported_data();
ProcessBuilder build_process(imported,
input.particles,
input.materials,
this->build_process_options());
// Start with the ordering of processes from the original test harness
std::vector<IPC> ipc{
IPC::compton,
IPC::photoelectric,
IPC::conversion,
IPC::annihilation,
IPC::e_ioni,
IPC::e_brems,
};
auto all_ipc = ProcessBuilder::get_all_process_classes(imported.processes);
// Remove missing processes from `ipc` and found processes from `all_ipc`
ipc.erase(std::remove_if(ipc.begin(),
ipc.end(),
[&all_ipc](ImportProcessClass i) {
auto iter = all_ipc.find(i);
if (iter == all_ipc.end())
return true;
all_ipc.erase(iter);
return false;
}),
ipc.end());
// Add processes not in the original list to the end of the vector
ipc.insert(ipc.end(), all_ipc.begin(), all_ipc.end());
for (auto p : ipc)
{
input.processes.push_back(build_process(p));
CELER_ASSERT(input.processes.back());
}
return std::make_shared<PhysicsParams>(std::move(input));
}
//---------------------------------------------------------------------------//
auto ImportedDataTestBase::build_cerenkov() -> SPConstCerenkov
{
return std::make_shared<CerenkovParams>(this->properties());
}
//---------------------------------------------------------------------------//
auto ImportedDataTestBase::build_properties() -> SPConstProperties
{
return OpticalPropertyParams::from_import(this->imported_data());
}
//---------------------------------------------------------------------------//
auto ImportedDataTestBase::build_scintillation() -> SPConstScintillation
{
return ScintillationParams::from_import(this->imported_data(),
this->particle());
}
//---------------------------------------------------------------------------//
} // namespace test
} // namespace celeritas