SpatialOps
NeboAssignment.h
1 /* This file was generated by fulmar version 0.9.2. */
2 
3 /*
4  * Copyright (c) 2014 The University of Utah
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22  * IN THE SOFTWARE.
23  */
24 
25 #ifndef NEBO_ASSIGNMENT_H
26  #define NEBO_ASSIGNMENT_H
27 
28  namespace SpatialOps {
29  template<typename FieldType>
30  inline FieldType const & operator <<=(FieldType & lhs,
31  typename FieldType::value_type
32  const & rhs) {
33  NeboScalar<Initial, typename FieldType::value_type> typedef RhsType;
34 
35  NeboField<Initial, FieldType>(lhs).template assign<RhsType>(true,
36  RhsType(rhs));
37 
38  return lhs;
39  };
40 
41  template<typename FieldType>
42  inline FieldType const & operator <<=(FieldType & lhs,
43  FieldType const & rhs) {
44  NeboConstField<Initial, FieldType> typedef RhsType;
45 
46  NeboField<Initial, FieldType>(lhs).template assign<RhsType>(true,
47  RhsType(rhs));
48 
49  return lhs;
50  };
51 
52  template<typename RhsType, typename FieldType>
53  inline FieldType const & operator <<=(FieldType & lhs,
54  NeboExpression<RhsType, FieldType>
55  const & rhs) {
56  NeboField<Initial, FieldType>(lhs).template assign<RhsType>(true, rhs.expr());
57 
58  return lhs;
59  };
60 
61  template<typename FieldType>
62  inline FieldType const & operator <<=(FieldType & lhs,
64  SingleValue,
65  typename
66  FieldType::
67  value_type>
68  const & rhs) {
69  NeboConstSingleValueField<Initial, typename FieldType::value_type>
70  typedef RhsType;
71 
72  NeboField<Initial, FieldType>(lhs).template assign<RhsType>(true,
73  RhsType(rhs));
74 
75  return lhs;
76  };
77 
78  template<typename RhsType, typename FieldType>
79  inline FieldType const & operator <<=(FieldType & lhs,
80  NeboSingleValueExpression<RhsType,
81  typename
82  FieldType::
83  value_type>
84  const & rhs) {
85  NeboField<Initial, FieldType>(lhs).template assign<RhsType>(true, rhs.expr());
86 
87  return lhs;
88  };
89 
90  template<typename T>
92  operator <<=(SpatialOps::SpatialField<SpatialOps::SingleValue, T> & lhs,
94  value_type const & rhs) {
95  NeboScalar<Initial,
97  T>::value_type> typedef
98  RhsType;
99 
100  NeboField<Initial,
102  assign<RhsType>(true,
103  RhsType(rhs));
104 
105  return lhs;
106  };
107 
108  template<typename T>
110  operator <<=(SpatialOps::SpatialField<SpatialOps::SingleValue, T> & lhs,
112  rhs) {
113  NeboConstSingleValueField<Initial, T> typedef RhsType;
114 
115  NeboField<Initial,
117  assign<RhsType>(true,
118  RhsType(rhs));
119 
120  return lhs;
121  };
122 
123  template<typename RhsType, typename T>
125  operator <<=(SpatialOps::SpatialField<SpatialOps::SingleValue, T> & lhs,
126  NeboSingleValueExpression<RhsType, T> const & rhs) {
127  NeboField<Initial,
129  assign<RhsType>(true,
130  rhs.expr());
131 
132  return lhs;
133  };
134 
135  template<typename FieldType>
136  inline FieldType const & interior_assign(FieldType & lhs,
137  typename FieldType::value_type
138  const & rhs) {
139  NeboScalar<Initial, typename FieldType::value_type> typedef RhsType;
140 
141  NeboField<Initial, FieldType>(lhs).template assign<RhsType>(false,
142  RhsType(rhs));
143 
144  return lhs;
145  };
146 
147  template<typename FieldType>
148  inline FieldType const & interior_assign(FieldType & lhs,
149  FieldType const & rhs) {
150  NeboConstField<Initial, FieldType> typedef RhsType;
151 
152  NeboField<Initial, FieldType>(lhs).template assign<RhsType>(false,
153  RhsType(rhs));
154 
155  return lhs;
156  };
157 
158  template<typename RhsType, typename FieldType>
159  inline FieldType const & interior_assign(FieldType & lhs,
160  NeboExpression<RhsType,
161  FieldType> const
162  & rhs) {
163  NeboField<Initial, FieldType>(lhs).template assign<RhsType>(false, rhs.expr());
164 
165  return lhs;
166  };
167 
168  template<typename FieldType>
169  inline FieldType const & interior_assign(FieldType & lhs,
171  SingleValue,
172  typename
173  FieldType::
174  value_type>
175  const & rhs) {
176  NeboConstSingleValueField<Initial, typename FieldType::value_type>
177  typedef RhsType;
178 
179  NeboField<Initial, FieldType>(lhs).template assign<RhsType>(false,
180  RhsType(rhs));
181 
182  return lhs;
183  };
184 
185  template<typename RhsType, typename FieldType>
186  inline FieldType const & interior_assign(FieldType & lhs,
187  NeboSingleValueExpression<RhsType,
188  typename
189  FieldType::
190  value_type>
191  const & rhs) {
192  NeboField<Initial, FieldType>(lhs).template assign<RhsType>(false, rhs.expr());
193 
194  return lhs;
195  };
196 
197  template<typename T>
200  lhs,
201  typename SpatialOps::SpatialField<SpatialOps::SingleValue,
202  T>::value_type const &
203  rhs) {
204  NeboScalar<Initial,
205  typename SpatialOps::SpatialField<SpatialOps::SingleValue,
206  T>::value_type> typedef
207  RhsType;
208 
209  NeboField<Initial,
211  assign<RhsType>(false,
212  RhsType(rhs));
213 
214  return lhs;
215  };
216 
217  template<typename T>
220  lhs,
222  const & rhs) {
223  NeboConstSingleValueField<Initial, T> typedef RhsType;
224 
225  NeboField<Initial,
227  assign<RhsType>(false,
228  RhsType(rhs));
229 
230  return lhs;
231  };
232 
233  template<typename RhsType, typename T>
236  lhs,
237  NeboSingleValueExpression<RhsType, T> const & rhs) {
238  NeboField<Initial,
240  assign<RhsType>(false,
241  rhs.expr());
242 
243  return lhs;
244  };
245 
246  template<typename FieldType>
247  inline FieldType const & masked_assign(SpatialMask<FieldType> const &
248  mask,
249  FieldType & lhs,
250  typename FieldType::value_type
251  const & rhs) {
252  NeboScalar<Initial, typename FieldType::value_type> typedef RhsType;
253 
254  #ifdef __CUDACC__
255  if(lhs.active_device_index() == CPU_INDEX) {
256  NeboField<Initial, FieldType>(lhs).template masked_assign<RhsType>(mask,
257  RhsType(rhs));
258  }
259  else {
260  lhs <<= cond(mask, NeboExpression<RhsType, FieldType>(rhs))(lhs);
261  }
262  #else
263  NeboField<Initial, FieldType>(lhs).template masked_assign<RhsType>(mask,
264  RhsType(rhs))
265  #endif
266  /* __CUDACC__ */;
267 
268  return lhs;
269  };
270 
271  template<typename FieldType>
272  inline FieldType const & masked_assign(SpatialMask<FieldType> const &
273  mask,
274  FieldType & lhs,
275  FieldType const & rhs) {
276  NeboConstField<Initial, FieldType> typedef RhsType;
277 
278  #ifdef __CUDACC__
279  if(lhs.active_device_index() == CPU_INDEX) {
280  NeboField<Initial, FieldType>(lhs).template masked_assign<RhsType>(mask,
281  RhsType(rhs));
282  }
283  else {
284  lhs <<= cond(mask, NeboExpression<RhsType, FieldType>(rhs))(lhs);
285  }
286  #else
287  NeboField<Initial, FieldType>(lhs).template masked_assign<RhsType>(mask,
288  RhsType(rhs))
289  #endif
290  /* __CUDACC__ */;
291 
292  return lhs;
293  };
294 
295  template<typename RhsType, typename FieldType>
296  inline FieldType const & masked_assign(SpatialMask<FieldType> const &
297  mask,
298  FieldType & lhs,
299  NeboExpression<RhsType, FieldType>
300  const & rhs) {
301  #ifdef __CUDACC__
302  if(lhs.active_device_index() == CPU_INDEX) {
303  NeboField<Initial, FieldType>(lhs).template masked_assign<RhsType>(mask,
304  rhs.expr());
305  }
306  else {
307  lhs <<= cond(mask, NeboExpression<RhsType, FieldType>(rhs))(lhs);
308  }
309  #else
310  NeboField<Initial, FieldType>(lhs).template masked_assign<RhsType>(mask,
311  rhs.expr())
312  #endif
313  /* __CUDACC__ */;
314 
315  return lhs;
316  };
317  } /* SpatialOps */
318 
319 #endif
320 /* NEBO_ASSIGNMENT_H */
Type traits for a single value field.
Abstracts a field.
Definition: SpatialField.h:132