flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
fields.hpp
Go to the documentation of this file.
1// ====================================================================
2// This file is part of FlexibleSUSY.
3//
4// FlexibleSUSY is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published
6// by the Free Software Foundation, either version 3 of the License,
7// or (at your option) any later version.
8//
9// FlexibleSUSY is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with FlexibleSUSY. If not, see
16// <http://www.gnu.org/licenses/>.
17// ====================================================================
18
19#ifndef CXXQFT_FIELDS_H
20#define CXXQFT_FIELDS_H
21
22#include <array>
24#include <boost/array.hpp>
25#include <boost/version.hpp>
26
27#include <boost/mpl/erase.hpp>
28#include <boost/mpl/joint_view.hpp>
29#include <boost/mpl/pair.hpp>
30#include <boost/mpl/vector.hpp>
31#include <boost/mpl/vector_c.hpp>
32
33#include <boost/fusion/adapted/boost_array.hpp>
34#include <boost/fusion/adapted/mpl.hpp>
35
36#if BOOST_VERSION >= 105800
37#include <boost/fusion/include/move.hpp>
38#else
39#include <boost/fusion/include/copy.hpp>
40#endif
41
47 template <class Field>
55 using type = std::array<int, Field::numberOfFieldIndices>;
56 };
57
58 namespace detail {
64 template <class Field>
66 static constexpr int value =
67 std::tuple_size<typename field_indices<Field>::type>::value;
68 using type = boost::mpl::int_<value>;
69 };
70 /*
71 * @param FieldSequence a Forward Sequence, e.g vector<type1,typ2,...>
72 * (see https://www.boost.org/doc/libs/1_69_0/libs/mpl/doc/refmanual/forward-sequence.html).
73 * @returns `::type` which accomodates `mpl::int_<N>` with `int N` being the
74 * sum of @b number of indices of fields inside FieldSequence.
75 * @returns `::value` which represents `N` where `N` being the `int`
76 * sum of @b number of indices of fields inside FieldSequence
77 */
78 template <class FieldSequence>
80 using type = typename boost::mpl::fold<
81 FieldSequence,
82 boost::mpl::int_<0>,
83 boost::mpl::plus<boost::mpl::_1,
85 >
86 >::type;
87 static constexpr int value = type::value;
88 };
89 } // namespace detail
90
91 /* @note Is defined by compiler only if the number of generation for a field
92 * is not 1.
93 */
94 template <class Field>
95 std::enable_if_t<Field::numberOfGenerations != 1, bool>
96 isSMField(const typename field_indices<Field>::type& indices) {
97 boost::array<bool, Field::numberOfGenerations> sm_flags;
98
99 #if BOOST_VERSION >= 105800
100 boost::fusion::move(typename Field::sm_flags(), sm_flags);
101 #else
102 boost::fusion::copy(typename Field::sm_flags(), sm_flags);
103 #endif
104
105 return sm_flags[indices.front()];
106 }
107
108 template <class Field>
109 std::enable_if_t<Field::numberOfGenerations == 1, bool>
111 return boost::mpl::at_c<typename Field::sm_flags, 0>::type::value;
112 }
113
114 namespace fields
115 {
116 enum class ParticleType {
117 scalar,
118 fermion,
119 vector,
120 ghost
121 };
122
123 template<typename Field>
124 struct is_massless {
125 static constexpr bool value = Field::massless;
126 };
127 template<typename Field>
129
130 enum class ParticleColorRep {
131 singlet,
132 triplet,
134 sextet,
135 octet
136 };
137
138 template<typename Field>
139 struct is_singlet {
140 static constexpr bool value =
141 Field::colorRep == ParticleColorRep::singlet;
142 };
143 template<typename Field>
145
146 template<typename Field>
147 struct is_triplet {
148 static constexpr bool value = Field::colorRep == ParticleColorRep::triplet;
149 };
150 template<typename Field>
152
153 template<typename Field>
155 static constexpr bool value =
156 Field::colorRep == ParticleColorRep::anti_triplet;
157 };
158 template<typename Field>
160
161 template<typename Field>
162 struct is_octet {
163 static constexpr bool value = Field::colorRep == ParticleColorRep::octet;
164 };
165 template<typename Field>
167
168 template<typename Field>
169 constexpr std::enable_if_t<
171 >
174 }
175 template<typename Field>
176 constexpr std::enable_if_t<
178 >
181 }
182 template<typename Field>
183 constexpr std::enable_if_t<
185 >
187 return Field::colorRep;
188 }
189
190 template<class Field>
191 struct bar {
192 using index_bounds = typename Field::index_bounds;
193 using sm_flags = typename Field::sm_flags;
194 using lorentz_conjugate = Field;
196
197 static constexpr int numberOfGenerations = Field::numberOfGenerations;
198 static constexpr int numberOfFieldIndices = Field::numberOfFieldIndices;
199 static constexpr double electricCharge = -Field::electricCharge;
200 static constexpr auto particleType = Field::particleType;
201 static constexpr auto colorRep = color_conj<Field>();
202 static constexpr auto massless = Field::massless;
203 };
204
205 template<class Field>
206 struct conj {
207 using index_bounds = typename Field::index_bounds;
208 using sm_flags = typename Field::sm_flags;
209 using lorentz_conjugate = Field;
211
212 static constexpr int numberOfGenerations = Field::numberOfGenerations;
213 static constexpr int numberOfFieldIndices = Field::numberOfFieldIndices;
214 static constexpr double electricCharge = -Field::electricCharge;
215 static constexpr auto particleType = Field::particleType;
216 static constexpr auto colorRep = color_conj<Field>();
217 static constexpr auto massless = Field::massless;
218 };
219
220 // Double Lorentz conjugation
221 template <class Field>
222 struct bar<bar<Field>> {
223 using type = Field;
224 };
225 template <class Field>
226 struct conj<conj<Field>> {
227 using type = Field;
228 };
229
230 // Remove Lorentz conjugation
231 template <class Field>
233 using type = Field;
234 };
235
236 template <class Field>
238 using type = Field;
239 };
240
241 template <class Field>
243 using type = Field;
244 };
245
246 template <class Field>
247 struct is_scalar : public std::false_type {};
248
249 template <class Field>
250 struct is_scalar<bar<Field> > : public is_scalar<Field> {};
251
252 template <class Field>
253 struct is_scalar<conj<Field> > : public is_scalar<Field> {};
254
255 template <class Field>
256 struct is_fermion : public std::false_type {};
257
258 template <class Field>
259 struct is_fermion<bar<Field> > : public is_fermion<Field> {};
260
261 template <class Field>
262 struct is_fermion<conj<Field> > : public is_fermion<Field> {};
263
264 template <class Field>
265 struct is_vector : public std::false_type {};
266
267 template <class Field>
268 struct is_vector<bar<Field> > : public is_vector<Field> {};
269
270 template <class Field>
271 struct is_vector<conj<Field> > : public is_vector<Field> {};
272
273 template <class Field>
274 struct is_ghost : public std::false_type {};
275
276 template <class Field>
277 struct is_ghost<bar<Field> > : public is_ghost<Field> {};
278
279 template <class Field>
280 struct is_ghost<conj<Field> > : public is_ghost<Field> {};
281
282 } // namespace generic_fields
283
284 using fields::bar;
285 using fields::conj;
287
288} // namespace flexiblesusy::cxx_diagrams
289
290#endif
constexpr std::enable_if_t< is_triplet< Field >::value, ParticleColorRep > color_conj()
Definition: fields.hpp:172
std::enable_if_t< Field::numberOfGenerations !=1, bool > isSMField(const typename field_indices< Field >::type &indices)
Definition: fields.hpp:96
typename std::enable_if< B, T >::type enable_if_t
Definition: json.hpp:3095
Declare a metafunction that gives the int value for Field during compilation time or int_<int N> type...
Definition: fields.hpp:65
typename boost::mpl::fold< FieldSequence, boost::mpl::int_< 0 >, boost::mpl::plus< boost::mpl::_1, number_of_field_indices< boost::mpl::_2 > > >::type type
Definition: fields.hpp:86
Declare a type that can hold the field indices for any given field.
Definition: fields.hpp:48
std::array< int, Field::numberOfFieldIndices > type
Definition: fields.hpp:55
static constexpr int numberOfGenerations
Definition: fields.hpp:197
typename Field::index_bounds index_bounds
Definition: fields.hpp:192
static constexpr double electricCharge
Definition: fields.hpp:199
static constexpr auto massless
Definition: fields.hpp:202
static constexpr auto colorRep
Definition: fields.hpp:201
typename Field::sm_flags sm_flags
Definition: fields.hpp:193
static constexpr auto particleType
Definition: fields.hpp:200
static constexpr int numberOfFieldIndices
Definition: fields.hpp:198
static constexpr double electricCharge
Definition: fields.hpp:214
static constexpr int numberOfGenerations
Definition: fields.hpp:212
static constexpr auto particleType
Definition: fields.hpp:215
typename Field::index_bounds index_bounds
Definition: fields.hpp:207
typename Field::sm_flags sm_flags
Definition: fields.hpp:208
static constexpr int numberOfFieldIndices
Definition: fields.hpp:213