-
Notifications
You must be signed in to change notification settings - Fork 31
/
Types.cc
115 lines (106 loc) · 3.37 KB
/
Types.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
//----------------------------------*-C++-*----------------------------------//
// Copyright 2022-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/Types.cc
//---------------------------------------------------------------------------//
#include "Types.hh"
#include "corecel/io/EnumStringMapper.hh"
#include "UnitTypes.hh"
namespace celeritas
{
//---------------------------------------------------------------------------//
/*!
* Get a string corresponding to an interpolation.
*/
char const* to_cstring(Interp value)
{
static EnumStringMapper<Interp> const to_cstring_impl{"linear", "log"};
return to_cstring_impl(value);
}
//---------------------------------------------------------------------------//
/*!
* Get a string corresponding to a state of matter.
*/
char const* to_cstring(MatterState value)
{
static EnumStringMapper<MatterState> const to_cstring_impl{
"unspecified",
"solid",
"liquid",
"gas",
};
return to_cstring_impl(value);
}
//---------------------------------------------------------------------------//
/*!
* Get a string corresponding to an action order.
*/
char const* to_cstring(ActionOrder value)
{
static EnumStringMapper<ActionOrder> const to_cstring_impl{
"start",
"sort_start",
"pre",
"sort_pre",
"along",
"sort_along",
"pre_post",
"sort_pre_post",
"post",
"post_post",
"end",
};
return to_cstring_impl(value);
}
//---------------------------------------------------------------------------//
/*!
* Get a string corresponding to a track ordering policy.
*/
char const* to_cstring(TrackOrder value)
{
static EnumStringMapper<TrackOrder> const to_cstring_impl{
"unsorted",
"shuffled",
"partition_status",
"sort_along_step_action",
"sort_step_limit_action",
"sort_action",
"sort_particle_type",
};
return to_cstring_impl(value);
}
//---------------------------------------------------------------------------//
/*!
* Get a string corresponding to the MSC step limit algorithm.
*/
char const* to_cstring(MscStepLimitAlgorithm value)
{
static EnumStringMapper<MscStepLimitAlgorithm> const to_cstring_impl{
"minimal",
"safety",
"safety_plus",
"distance_to_boundary",
};
return to_cstring_impl(value);
}
//---------------------------------------------------------------------------//
/*!
* Checks that the TrackOrder will sort tracks by actions applied at the given
* ActionOrder. This should match the mapping in the \c SortTracksAction
* constructor.
*
* TODO: Have a single source of truth for mapping TrackOrder to ActionOrder
*/
bool is_action_sorted(ActionOrder action, TrackOrder track)
{
return (action == ActionOrder::post
&& track == TrackOrder::sort_step_limit_action)
|| (action == ActionOrder::along
&& track == TrackOrder::sort_along_step_action)
|| (track == TrackOrder::sort_action
&& (action == ActionOrder::post || action == ActionOrder::along));
}
//---------------------------------------------------------------------------//
} // namespace celeritas