forked from celeritas-project/celeritas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OpticalTrackData.hh
162 lines (142 loc) · 4.78 KB
/
OpticalTrackData.hh
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
//----------------------------------*-C++-*----------------------------------//
// Copyright 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/optical/OpticalTrackData.hh
//---------------------------------------------------------------------------//
#pragma once
#include "corecel/Assert.hh"
#include "corecel/data/Collection.hh"
#include "celeritas/Types.hh"
#include "celeritas/geo/GeoData.hh"
#include "celeritas/random/RngData.hh"
#include "celeritas/track/SimData.hh"
#include "celeritas/track/TrackInitData.hh"
#include "Types.hh"
namespace celeritas
{
//---------------------------------------------------------------------------//
// XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
// IMPLEMENT ME!
template<Ownership W, MemSpace M>
struct OpticalPhysicsParamsData
{
explicit CELER_FUNCTION operator bool() const { return false; }
};
template<Ownership W, MemSpace M>
struct OpticalPhysicsStateData
{
};
template<MemSpace M>
void resize(OpticalPhysicsStateData<Ownership::value, M>*,
HostCRef<OpticalPhysicsParamsData> const&,
size_type)
{
CELER_NOT_IMPLEMENTED("optical physics state");
}
// XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
//---------------------------------------------------------------------------//
/*!
* Memspace-independent core variables.
*/
struct OpticalScalars
{
ActionId boundary_action;
StreamId::size_type max_streams{0};
OpticalMaterialId::size_type num_materials{0};
//! True if assigned and valid
explicit CELER_FUNCTION operator bool() const
{
return boundary_action && max_streams > 0 && num_materials > 0;
}
};
//---------------------------------------------------------------------------//
/*!
* Immutable problem data.
*/
template<Ownership W, MemSpace M>
struct OpticalParamsData
{
template<class T>
using VolumeItems = celeritas::Collection<T, W, M, VolumeId>;
GeoParamsData<W, M> geometry;
VolumeItems<OpticalMaterialId> materials;
OpticalPhysicsParamsData<W, M> physics;
RngParamsData<W, M> rng;
TrackInitParamsData<W, M> init; // TODO: don't need max events
OpticalScalars scalars;
//! True if all params are assigned
explicit CELER_FUNCTION operator bool() const
{
return geometry && !materials.empty() && physics && rng && init
&& scalars;
}
//! Assign from another set of data
template<Ownership W2, MemSpace M2>
OpticalParamsData& operator=(OpticalParamsData<W2, M2> const& other)
{
CELER_EXPECT(other);
geometry = other.geometry;
materials = other.materials;
physics = other.physics;
rng = other.rng;
init = other.init;
scalars = other.scalars;
return *this;
}
};
//---------------------------------------------------------------------------//
/*!
* Thread-local state data.
*/
template<Ownership W, MemSpace M>
struct OpticalStateData
{
template<class T>
using Items = StateCollection<T, W, M>;
GeoStateData<W, M> geometry;
Items<OpticalMaterialId> materials;
OpticalPhysicsStateData<W, M> physics;
RngStateData<W, M> rng;
SimStateData<W, M> sim; // TODO: has a few things we don't need
TrackInitStateData<W, M> init; // Still need to track vacancies
//! Unique identifier for "thread-local" data.
StreamId stream_id;
//! Number of state elements
CELER_FUNCTION size_type size() const { return geometry.size(); }
//! Whether the data are assigned
explicit CELER_FUNCTION operator bool() const
{
return geometry && materials && physics && rng && sim && init
&& stream_id;
}
//! Assign from another set of data
template<Ownership W2, MemSpace M2>
OpticalStateData& operator=(OpticalStateData<W2, M2>& other)
{
CELER_EXPECT(other);
geometry = other.geometry;
materials = other.materials;
physics = other.physics;
rng = other.rng;
sim = other.sim;
init = other.init;
stream_id = other.stream_id;
return *this;
}
};
//---------------------------------------------------------------------------//
/*!
* Resize states in host code.
*
* Initialize threads to track slots mapping.
* Resize core states using parameter data, stream ID, and track slots.
*/
template<MemSpace M>
void resize(OpticalStateData<Ownership::value, M>* state,
HostCRef<OpticalParamsData> const& params,
StreamId stream_id,
size_type size);
//---------------------------------------------------------------------------//
} // namespace celeritas