20#include "BDSException.hh"
21#include "BDSInterpolatorType.hh"
22#include "BDSUtilities.hh"
34 new std::map<BDSInterpolatorType, std::string> ({
35 {BDSInterpolatorType::nearestauto,
"nearestauto"},
36 {BDSInterpolatorType::nearest1d,
"nearest1d"},
37 {BDSInterpolatorType::nearest2d,
"nearest2d"},
38 {BDSInterpolatorType::nearest3d,
"nearest3d"},
39 {BDSInterpolatorType::nearest4d,
"nearest4d"},
40 {BDSInterpolatorType::linearauto,
"linearauto"},
41 {BDSInterpolatorType::linear1d,
"linear1d"},
42 {BDSInterpolatorType::linear2d,
"linear2d"},
43 {BDSInterpolatorType::linear3d,
"linear3d"},
44 {BDSInterpolatorType::linear4d,
"linear4d"},
45 {BDSInterpolatorType::linearauto,
"linearmagauto"},
46 {BDSInterpolatorType::linear1d,
"linearmag1d"},
47 {BDSInterpolatorType::linear2d,
"linearmag2d"},
48 {BDSInterpolatorType::linear3d,
"linearmag3d"},
49 {BDSInterpolatorType::linear4d,
"linearmag4d"},
50 {BDSInterpolatorType::cubicauto,
"cubicauto"},
51 {BDSInterpolatorType::cubic1d,
"cubic1d"},
52 {BDSInterpolatorType::cubic2d,
"cubic2d"},
53 {BDSInterpolatorType::cubic3d,
"cubic3d"},
54 {BDSInterpolatorType::cubic4d,
"cubic4d"}
59 std::map<G4String, BDSInterpolatorType> types;
60 types[
"nearest"] = BDSInterpolatorType::nearestauto;
61 types[
"nearest1d"] = BDSInterpolatorType::nearest1d;
62 types[
"nearest2d"] = BDSInterpolatorType::nearest2d;
63 types[
"nearest3d"] = BDSInterpolatorType::nearest3d;
64 types[
"nearest4d"] = BDSInterpolatorType::nearest4d;
65 types[
"linear"] = BDSInterpolatorType::linearauto;
66 types[
"linear1d"] = BDSInterpolatorType::linear1d;
67 types[
"linear2d"] = BDSInterpolatorType::linear2d;
68 types[
"linear3d"] = BDSInterpolatorType::linear3d;
69 types[
"linear4d"] = BDSInterpolatorType::linear4d;
70 types[
"linearmag"] = BDSInterpolatorType::linearmagauto;
71 types[
"linearmag1d"] = BDSInterpolatorType::linearmag1d;
72 types[
"linearmag2d"] = BDSInterpolatorType::linearmag2d;
73 types[
"linearmag3d"] = BDSInterpolatorType::linearmag3d;
74 types[
"linearmag4d"] = BDSInterpolatorType::linearmag4d;
75 types[
"cubic"] = BDSInterpolatorType::cubicauto;
76 types[
"cubic1d"] = BDSInterpolatorType::cubic1d;
77 types[
"cubic2d"] = BDSInterpolatorType::cubic2d;
78 types[
"cubic3d"] = BDSInterpolatorType::cubic3d;
79 types[
"cubic4d"] = BDSInterpolatorType::cubic4d;
83 auto result = types.find(interpolatorType);
84 if (result == types.end())
86 G4String msg =
"\"" + interpolatorType +
"\" is not a valid field type\n";
87 msg +=
"Available interpolator types are:\n";
88 for (
const auto& it : types)
89 {msg +=
"\"" + it.first +
"\"\n";}
94 G4cout << __METHOD_NAME__ <<
"determined interpolator type to be " << result->second << G4endl;
96 return result->second;
104 case BDSInterpolatorType::nearest1d:
105 case BDSInterpolatorType::linear1d:
106 case BDSInterpolatorType::linearmag1d:
107 case BDSInterpolatorType::cubic1d:
109 case BDSInterpolatorType::nearest2d:
110 case BDSInterpolatorType::linear2d:
111 case BDSInterpolatorType::linearmag2d:
112 case BDSInterpolatorType::cubic2d:
114 case BDSInterpolatorType::nearest3d:
115 case BDSInterpolatorType::linear3d:
116 case BDSInterpolatorType::linearmag3d:
117 case BDSInterpolatorType::cubic3d:
119 case BDSInterpolatorType::nearest4d:
120 case BDSInterpolatorType::linear4d:
121 case BDSInterpolatorType::linearmag4d:
122 case BDSInterpolatorType::cubic4d:
132 G4bool result =
false;
135 case BDSInterpolatorType::nearestauto:
136 case BDSInterpolatorType::linearauto:
137 case BDSInterpolatorType::linearmagauto:
138 case BDSInterpolatorType::cubicauto:
139 {result =
true;
break;}
150 {std::make_pair(1, BDSInterpolatorType::nearestauto), BDSInterpolatorType::nearest1d},
151 {std::make_pair(2, BDSInterpolatorType::nearestauto), BDSInterpolatorType::nearest2d},
152 {std::make_pair(3, BDSInterpolatorType::nearestauto), BDSInterpolatorType::nearest3d},
153 {std::make_pair(4, BDSInterpolatorType::nearestauto), BDSInterpolatorType::nearest4d},
154 {std::make_pair(1, BDSInterpolatorType::linearauto), BDSInterpolatorType::linear1d},
155 {std::make_pair(2, BDSInterpolatorType::linearauto), BDSInterpolatorType::linear2d},
156 {std::make_pair(3, BDSInterpolatorType::linearauto), BDSInterpolatorType::linear3d},
157 {std::make_pair(4, BDSInterpolatorType::linearauto), BDSInterpolatorType::linear4d},
158 {std::make_pair(1, BDSInterpolatorType::linearmagauto), BDSInterpolatorType::linearmag1d},
159 {std::make_pair(2, BDSInterpolatorType::linearmagauto), BDSInterpolatorType::linearmag2d},
160 {std::make_pair(3, BDSInterpolatorType::linearmagauto), BDSInterpolatorType::linearmag3d},
161 {std::make_pair(4, BDSInterpolatorType::linearmagauto), BDSInterpolatorType::linearmag4d},
162 {std::make_pair(1, BDSInterpolatorType::cubicauto), BDSInterpolatorType::cubic1d},
163 {std::make_pair(2, BDSInterpolatorType::cubicauto), BDSInterpolatorType::cubic2d},
164 {std::make_pair(3, BDSInterpolatorType::cubicauto), BDSInterpolatorType::cubic3d},
165 {std::make_pair(4, BDSInterpolatorType::cubicauto), BDSInterpolatorType::cubic4d},
167 auto key = std::make_pair(nDimension, autoType);
168 auto search = mapping.find(key);
169 if (search != mapping.end())
170 {
return search->second;}
172 {
throw BDSException(__METHOD_NAME__,
"invalid number of dimensions in auto-mapping to interpolators.");}
General exception with possible name of object and message.
static std::map< BDSTypeSafeEnum< interpolatortypes_def, int >, std::string > * dictionary
type underlying() const
return underlying value (can be used in switch statement)
BDSInterpolatorType InterpolatorTypeSpecificFromAuto(G4int nDimension, BDSInterpolatorType autoType)
G4bool InterpolatorTypeIsAuto(BDSInterpolatorType typeIn)
Return true if the type is one containing 'auto'.
BDSInterpolatorType DetermineInterpolatorType(G4String interpolatorType)
Function that determines enum from string (case-insensitive).
G4String LowerCase(const G4String &str)
Utility function to simplify lots of syntax changes for pedantic g4 changes.
G4int NDimensionsOfInterpolatorType(const BDSInterpolatorType &it)
Report the number of dimensions for that interpolator type.