Intrepid2
Intrepid2_ArrayToolsDefContractions.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Intrepid2 Package
4 //
5 // Copyright 2007 NTESS and the Intrepid2 contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
16 #ifndef __INTREPID2_ARRAYTOOLS_DEF_CONTRACTIONS_HPP__
17 #define __INTREPID2_ARRAYTOOLS_DEF_CONTRACTIONS_HPP__
18 
19 namespace Intrepid2 {
20 
21 
22  namespace FunctorArrayTools {
26  template < typename outFieldViewType , typename leftFieldViewType , typename rightFieldViewType >
28  outFieldViewType _outputFields;
29  leftFieldViewType _leftFields;
30  rightFieldViewType _rightFields;
31  const bool _sumInto;
32  typedef typename outFieldViewType::value_type value_type;
33 
34  KOKKOS_INLINE_FUNCTION
35  F_contractFieldField(outFieldViewType outputFields_,
36  leftFieldViewType leftFields_,
37  rightFieldViewType rightFields_,
38  const bool sumInto_)
39  : _outputFields(outputFields_), _leftFields(leftFields_), _rightFields(rightFields_), _sumInto(sumInto_) {}
40 
41  KOKKOS_INLINE_FUNCTION
42  void operator()(const size_type iter) const {
43  size_type cl, lbf, rbf;
44  unrollIndex( cl, lbf, rbf,
45  _outputFields.extent(0),
46  _outputFields.extent(1),
47  _outputFields.extent(2),
48  iter );
49 
50  const size_type npts = _leftFields.extent(2);
51  const ordinal_type iend = _leftFields.extent(3);
52  const ordinal_type jend = _leftFields.extent(4);
53 
54  _outputFields( cl, lbf, rbf ) *= (_sumInto ? 1 : 0);
55  for (size_type qp = 0; qp < npts; ++qp)
56  for (ordinal_type i = 0; i < iend; ++i)
57  for (ordinal_type j = 0; j < jend; ++j)
58  _outputFields( cl, lbf, rbf ) += _leftFields(cl, lbf, qp, i, j)*_rightFields(cl, rbf, qp, i, j);
59  }
60  };
61  } //end namespace
62 
63  template<typename DeviceType>
64  template<typename outputFieldValueType, class ...outputFieldProperties,
65  typename leftFieldValueType, class ...leftFieldProperties,
66  typename rightFieldValueType, class ...rightFieldProperties>
67  void
69  contractFieldField( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
70  const Kokkos::DynRankView<leftFieldValueType, leftFieldProperties...> leftFields,
71  const Kokkos::DynRankView<rightFieldValueType, rightFieldProperties...> rightFields,
72  const bool sumInto ) {
73 
74  typedef Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outFieldViewType;
75  typedef Kokkos::DynRankView<leftFieldValueType,leftFieldProperties...> leftFieldViewType;
76  typedef Kokkos::DynRankView<rightFieldValueType,rightFieldProperties...> rightFieldViewType;
78 
79  const size_type loopSize = leftFields.extent(0)*leftFields.extent(1)*rightFields.extent(1);
80  Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
81  Kokkos::parallel_for( policy, FunctorType(outputFields, leftFields, rightFields, sumInto) );
82  }
83 
84 
85  namespace FunctorArrayTools {
89  template < typename outputFieldsViewType , typename inputDataViewType , typename inputFieldsViewType >
91  outputFieldsViewType _outputFields;
92  inputDataViewType _inputData;
93  inputFieldsViewType _inputFields;
94  const bool _sumInto;
95  typedef typename outputFieldsViewType::value_type value_type;
96 
97  KOKKOS_INLINE_FUNCTION
98  F_contractDataField(outputFieldsViewType outputFields_,
99  inputDataViewType inputData_,
100  inputFieldsViewType inputFields_,
101  const bool sumInto_)
102  : _outputFields(outputFields_), _inputData(inputData_), _inputFields(inputFields_), _sumInto(sumInto_) {}
103 
104  KOKKOS_DEFAULTED_FUNCTION
105  ~F_contractDataField() = default;
106 
107  KOKKOS_INLINE_FUNCTION
108  void operator()(const size_type iter) const {
109  size_type cl, bf;
110  unrollIndex( cl, bf,
111  _inputFields.extent(0),
112  _inputFields.extent(1),
113  iter );
114 
115  auto result = Kokkos::subview( _outputFields, cl, bf );
116 
117  const auto field = Kokkos::subview( _inputFields, cl, bf, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL() );
118  const auto data = Kokkos::subview( _inputData, cl, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL() );
119 
120  const size_type npts = field.extent(0);
121  const ordinal_type iend = field.extent(1);
122  const ordinal_type jend = field.extent(2);
123 
124  result() *= (_sumInto ? 1 : 0);
125 
126  if(_inputData.extent(1) != 1)
127  for (size_type qp = 0; qp < npts; ++qp)
128  for (ordinal_type i = 0; i < iend; ++i)
129  for (ordinal_type j = 0; j < jend; ++j)
130  result() += field(qp, i, j) * data(qp, i, j);
131  else
132  for (size_type qp = 0; qp < npts; ++qp)
133  for (ordinal_type i = 0; i < iend; ++i)
134  for (ordinal_type j = 0; j < jend; ++j)
135  result() += field(qp, i, j) * data(0, i, j);
136  }
137  };
138  } //namespace
139 
140  template<typename DeviceType>
141  template<typename outputFieldValueType, class ...outputFieldProperties,
142  typename inputDataValueType, class ...inputDataProperties,
143  typename inputFieldValueType, class ...inputFieldProperties>
144  void
146  contractDataField( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
147  const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
148  const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields,
149  const bool sumInto ) {
150 
151  typedef Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFieldsViewType;
152  typedef Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputDataViewType;
153  typedef Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFieldsViewType;
155 
156  const size_type loopSize = inputFields.extent(0)*inputFields.extent(1);
157  Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
158  Kokkos::parallel_for( policy, FunctorType(outputFields, inputData, inputFields, sumInto) );
159  }
160 
161 
162  namespace FunctorArrayTools {
166  template < typename outputDataViewType , typename inputDataLeftViewType , typename inputDataRightViewType >
168  outputDataViewType _outputData;
169  inputDataLeftViewType _inputDataLeft;
170  inputDataRightViewType _inputDataRight;
171  const bool _sumInto;
172  typedef typename outputDataViewType::value_type value_type;
173 
174  KOKKOS_INLINE_FUNCTION
175  F_contractDataData(outputDataViewType outputData_,
176  inputDataLeftViewType inputDataLeft_,
177  inputDataRightViewType inputDataRight_,
178  const bool sumInto_)
179  : _outputData(outputData_), _inputDataLeft(inputDataLeft_), _inputDataRight(inputDataRight_), _sumInto(sumInto_) {}
180 
181  KOKKOS_DEFAULTED_FUNCTION
182  ~F_contractDataData() = default;
183 
184  KOKKOS_INLINE_FUNCTION
185  void operator()(const size_type iter) const {
186  const size_type cl = iter;
187 
188  auto result = Kokkos::subview( _outputData, cl );
189  const auto left = Kokkos::subview( _inputDataLeft, cl, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL() );
190  const auto right = Kokkos::subview( _inputDataRight, cl, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL() );
191 
192  size_type npts = left.extent(0);
193  ordinal_type iend = left.extent(1);
194  ordinal_type jend = left.extent(2);
195 
196  result() *= (_sumInto ? 1 : 0);
197  for (size_type qp = 0; qp < npts; ++qp)
198  for (ordinal_type i = 0; i < iend; ++i)
199  for (ordinal_type j = 0; j < jend; ++j)
200  result() += left(qp, i, j)*right(qp, i, j);
201  }
202  };
203  } //namespace
204 
205  template<typename DeviceType>
206  template<typename outputDataValueType, class ...outputDataProperties,
207  typename inputDataLeftValueType, class ...inputDataLeftProperties,
208  typename inputDataRightValueType, class ...inputDataRightProperties>
209  void
211  contractDataData( Kokkos::DynRankView<outputDataValueType, outputDataProperties...> outputData,
212  const Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft,
213  const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight,
214  const bool sumInto ) {
215  typedef Kokkos::DynRankView<outputDataValueType, outputDataProperties...> outputDataViewType;
216  typedef Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeftViewType;
217  typedef Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRightViewType;
219 
220  const size_type loopSize = inputDataLeft.extent(0);
221  Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
222  Kokkos::parallel_for( policy, FunctorType(outputData, inputDataLeft, inputDataRight, sumInto) );
223  }
224 
225 
226 
227  template<typename DeviceType>
228  template<typename outputFieldValueType, class ...outputFieldProperties,
229  typename leftFieldValueType, class ...leftFieldProperties,
230  typename rightFieldValueType, class ...rightFieldProperties>
231  void
233  contractFieldFieldScalar( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
234  const Kokkos::DynRankView<leftFieldValueType, leftFieldProperties...> leftFields,
235  const Kokkos::DynRankView<rightFieldValueType, rightFieldProperties...> rightFields,
236  const bool sumInto ) {
237 
238 #ifdef HAVE_INTREPID2_DEBUG
239  {
240  INTREPID2_TEST_FOR_EXCEPTION( leftFields.rank() != 3, std::invalid_argument,
241  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Rank of the left input argument must equal 3!");
242  INTREPID2_TEST_FOR_EXCEPTION( rightFields.rank() != 3, std::invalid_argument,
243  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Rank of right input argument must equal 3!");
244  INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 3, std::invalid_argument,
245  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Rank of output argument must equal 3!");
246  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(0) != rightFields.extent(0), std::invalid_argument,
247  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Zeroth dimensions (number of integration domains) of the left and right input containers must agree!");
248  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(2) != rightFields.extent(2), std::invalid_argument,
249  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Second dimensions (numbers of integration points) of the left and right input containers must agree!");
250  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != rightFields.extent(0), std::invalid_argument,
251  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Zeroth dimensions (numbers of integration domains) of the input and output containers must agree!");
252  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(1) != leftFields.extent(1), std::invalid_argument,
253  ">>> ERROR (ArrayTools::contractFieldFieldScalar): First dimension of output container and first dimension of left input container must agree!");
254  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(2) != rightFields.extent(1), std::invalid_argument,
255  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Second dimension of output container and first dimension of right input container must agree!");
256 
257  }
258 #endif
259 
261  leftFields,
262  rightFields,
263  sumInto );
264  }
265 
266 
267  template<typename DeviceType>
268  template<typename outputFieldValueType, class ...outputFieldProperties,
269  typename leftFieldValueType, class ...leftFieldProperties,
270  typename rightFieldValueType, class ...rightFieldProperties>
271  void
273  contractFieldFieldVector( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
274  const Kokkos::DynRankView<leftFieldValueType, leftFieldProperties...> leftFields,
275  const Kokkos::DynRankView<rightFieldValueType, rightFieldProperties...> rightFields,
276  const bool sumInto ) {
277 
278 #ifdef HAVE_INTREPID2_DEBUG
279  {
280  INTREPID2_TEST_FOR_EXCEPTION( leftFields.rank() != 4, std::invalid_argument,
281  ">>> ERROR (ArrayTools::contractFieldFieldVector): Rank of the left input argument must equal 4!");
282  INTREPID2_TEST_FOR_EXCEPTION( rightFields.rank() != 4, std::invalid_argument,
283  ">>> ERROR (ArrayTools::contractFieldFieldVector): Rank of right input argument must equal 4!");
284  INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 3, std::invalid_argument,
285  ">>> ERROR (ArrayTools::contractFieldFieldVector): Rank of output argument must equal 3!");
286  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(0) != rightFields.extent(0), std::invalid_argument,
287  ">>> ERROR (ArrayTools::contractFieldFieldVector): Zeroth dimensions (number of integration domains) of the left and right input containers must agree!");
288  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(2) != rightFields.extent(2), std::invalid_argument,
289  ">>> ERROR (ArrayTools::contractFieldFieldVector): Second dimensions (numbers of integration points) of the left and right input containers must agree!");
290  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(3) != rightFields.extent(3), std::invalid_argument,
291  ">>> ERROR (ArrayTools::contractFieldFieldVector): Third dimensions (numbers of vector components) of the left and right input containers must agree!");
292  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != rightFields.extent(0), std::invalid_argument,
293  ">>> ERROR (ArrayTools::contractFieldFieldVector): Zeroth dimensions (numbers of integration domains) of the input and output containers must agree!");
294  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(1) != leftFields.extent(1), std::invalid_argument,
295  ">>> ERROR (ArrayTools::contractFieldFieldVector): First dimension of output container and first dimension of left input container must agree!");
296  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(2) != rightFields.extent(1), std::invalid_argument,
297  ">>> ERROR (ArrayTools::contractFieldFieldVector): Second dimension of output container and first dimension of right input container must agree!");
298  }
299 #endif
300 
302  leftFields,
303  rightFields,
304  sumInto );
305  }
306 
307 
308  template<typename DeviceType>
309  template<typename outputFieldValueType, class ...outputFieldProperties,
310  typename leftFieldValueType, class ...leftFieldProperties,
311  typename rightFieldValueType, class ...rightFieldProperties>
312  void
314  contractFieldFieldTensor( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
315  const Kokkos::DynRankView<leftFieldValueType, leftFieldProperties...> leftFields,
316  const Kokkos::DynRankView<rightFieldValueType, rightFieldProperties...> rightFields,
317  const bool sumInto ) {
318 
319 #ifdef HAVE_INTREPID2_DEBUG
320  {
321  INTREPID2_TEST_FOR_EXCEPTION( leftFields.rank() != 5, std::invalid_argument,
322  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Rank of the left input argument must equal 5!");
323  INTREPID2_TEST_FOR_EXCEPTION( rightFields.rank() != 5, std::invalid_argument,
324  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Rank of right input argument must equal 5!");
325  INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 3, std::invalid_argument,
326  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Rank of output argument must equal 3!");
327  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(0) != rightFields.extent(0), std::invalid_argument,
328  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Zeroth dimensions (number of integration domains) of the left and right input containers must agree!");
329  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(2) != rightFields.extent(2), std::invalid_argument,
330  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Second dimensions (numbers of integration points) of the left and right input containers must agree!");
331  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(3) != rightFields.extent(3), std::invalid_argument,
332  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Third dimensions (first tensor dimensions) of the left and right input containers must agree!");
333  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(4) != rightFields.extent(4), std::invalid_argument,
334  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Fourth dimensions (second tensor dimensions) of the left and right input containers must agree!");
335  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != rightFields.extent(0), std::invalid_argument,
336  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Zeroth dimensions (numbers of integration domains) of the input and output containers must agree!");
337  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(1) != leftFields.extent(1), std::invalid_argument,
338  ">>> ERROR (ArrayTools::contractFieldFieldTensor): First dimension of output container and first dimension of left input container must agree!");
339  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(2) != rightFields.extent(1), std::invalid_argument,
340  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Second dimension of output container and first dimension of right input container must agree!");
341  }
342 #endif
343 
345  leftFields,
346  rightFields,
347  sumInto );
348  }
349 
350 
351  template<typename DeviceType>
352  template<typename outputFieldValueType, class ...outputFieldProperties,
353  typename inputDataValueType, class ...inputDataProperties,
354  typename inputFieldValueType, class ...inputFieldProperties>
355  void
357  contractDataFieldScalar( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
358  const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
359  const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields,
360  const bool sumInto ) {
361 
362 #ifdef HAVE_INTREPID2_DEBUG
363  {
364  INTREPID2_TEST_FOR_EXCEPTION( inputFields.rank() != 3, std::invalid_argument,
365  ">>> ERROR (ArrayTools::contractDataFieldScalar): Rank of the fields input argument must equal 3!");
366  INTREPID2_TEST_FOR_EXCEPTION( inputData.rank() != 2, std::invalid_argument,
367  ">>> ERROR (ArrayTools::contractDataFieldScalar): Rank of the data input argument must equal 2!");
368  INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 2, std::invalid_argument,
369  ">>> ERROR (ArrayTools::contractDataFieldScalar): Rank of output argument must equal 2!");
370  INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(0) != inputData.extent(0), std::invalid_argument,
371  ">>> ERROR (ArrayTools::contractDataFieldScalar): Zeroth dimensions (number of integration domains) of the fields and data input containers must agree!");
372 
373  INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(1) != inputFields.extent(2) &&
374  inputData.extent(1) != 1, std::invalid_argument,
375  ">>> ERROR (ArrayTools::contractDataFieldScalar): Second dimension of fields input container and first dimension of data input container (number of integration points) must agree or first data dimension must be 1!");
376  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != inputFields.extent(0), std::invalid_argument,
377  ">>> ERROR (ArrayTools::contractDataFieldScalar): Zeroth dimensions (numbers of integration domains) of the fields input and output containers must agree!");
378  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(1) != inputFields.extent(1), std::invalid_argument,
379  ">>> ERROR (ArrayTools::contractDataFieldScalar): First dimensions (number of fields) of the fields input and output containers must agree!");
380  }
381 #endif
382 
384  inputData,
385  inputFields,
386  sumInto );
387  }
388 
389 
390  template<typename DeviceType>
391  template<typename outputFieldValueType, class ...outputFieldProperties,
392  typename inputDataValueType, class ...inputDataProperties,
393  typename inputFieldValueType, class ...inputFieldProperties>
394  void
396  contractDataFieldVector( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
397  const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
398  const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields,
399  const bool sumInto ) {
400 
401 #ifdef HAVE_INTREPID2_DEBUG
402  {
403  INTREPID2_TEST_FOR_EXCEPTION( inputFields.rank() != 4, std::invalid_argument,
404  ">>> ERROR (ArrayTools::contractDataFieldVector): Rank of the fields input argument must equal 4!");
405  INTREPID2_TEST_FOR_EXCEPTION( inputData.rank() != 3, std::invalid_argument,
406  ">>> ERROR (ArrayTools::contractDataFieldVector): Rank of the data input argument must equal 3!");
407  INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 2, std::invalid_argument,
408  ">>> ERROR (ArrayTools::contractDataFieldVector): Rank of output argument must equal 2!");
409  INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(0) != inputData.extent(0), std::invalid_argument,
410  ">>> ERROR (ArrayTools::contractDataFieldVector): Zeroth dimensions (number of integration domains) of the fields and data input containers must agree!");
411  INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(1) != inputFields.extent(2) &&
412  inputData.extent(1) != 1, std::invalid_argument,
413  ">>> ERROR (ArrayTools::contractDataFieldVector): Second dimension of the fields input container and first dimension of data input container (number of integration points) must agree or first data dimension must be 1!");
414  INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(3) != inputData.extent(2), std::invalid_argument,
415  ">>> ERROR (ArrayTools::contractDataFieldVector): Third dimension of the fields input container and second dimension of data input container (vector index) must agree!");
416  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != inputFields.extent(0), std::invalid_argument,
417  ">>> ERROR (ArrayTools::contractDataFieldVector): Zeroth dimensions (numbers of integration domains) of the fields input and output containers must agree!");
418  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(1) != inputFields.extent(1), std::invalid_argument,
419  ">>> ERROR (ArrayTools::contractDataFieldVector): First dimensions of output container and fields input container (number of fields) must agree!");
420  }
421 #endif
422 
424  inputData,
425  inputFields,
426  sumInto );
427  }
428 
429 
430 
431  template<typename DeviceType>
432  template<typename outputFieldValueType, class ...outputFieldProperties,
433  typename inputDataValueType, class ...inputDataProperties,
434  typename inputFieldValueType, class ...inputFieldProperties>
435  void
437  contractDataFieldTensor( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
438  const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
439  const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields,
440  const bool sumInto ) {
441 
442 #ifdef HAVE_INTREPID2_DEBUG
443  {
444  INTREPID2_TEST_FOR_EXCEPTION( inputFields.rank() != 5, std::invalid_argument,
445  ">>> ERROR (ArrayTools::contractDataFieldTensor): Rank of the fields input argument must equal 5!");
446  INTREPID2_TEST_FOR_EXCEPTION( inputData.rank() != 4, std::invalid_argument,
447  ">>> ERROR (ArrayTools::contractDataFieldTensor): Rank of the data input argument must equal 4!");
448  INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 2, std::invalid_argument,
449  ">>> ERROR (ArrayTools::contractDataFieldTensor): Rank of output argument must equal 2!");
450  INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(0) != inputData.extent(0), std::invalid_argument,
451  ">>> ERROR (ArrayTools::contractDataFieldTensor): Zeroth dimensions (number of integration domains) of the fields and data input containers must agree!");
452  INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(1) != inputFields.extent(2) && inputData.extent(1) != 1, std::invalid_argument,
453  ">>> ERROR (ArrayTools::contractDataFieldTensor): Second dimension of the fields input container and first dimension of data input container (number of integration points) must agree or first data dimension must be 1!");
454  INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(3) != inputData.extent(2), std::invalid_argument,
455  ">>> ERROR (ArrayTools::contractDataFieldTensor): Third dimension of the fields input container and second dimension of data input container (first tensor dimension) must agree!");
456  INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(4) != inputData.extent(3), std::invalid_argument,
457  ">>> ERROR (ArrayTools::contractDataFieldTensor): Fourth dimension of the fields input container and third dimension of data input container (second tensor dimension) must agree!");
458  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != inputFields.extent(0), std::invalid_argument,
459  ">>> ERROR (ArrayTools::contractDataFieldTensor): Zeroth dimensions (numbers of integration domains) of the fields input and output containers must agree!");
460  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(1) != inputFields.extent(1), std::invalid_argument,
461  ">>> ERROR (ArrayTools::contractDataFieldTensor): First dimensions (number of fields) of output container and fields input container must agree!");
462  }
463 #endif
464 
466  inputData,
467  inputFields,
468  sumInto );
469  }
470 
471 
472 
473  template<typename DeviceType>
474  template<typename outputDataValueType, class ...outputDataProperties,
475  typename inputDataLeftValueType, class ...inputDataLeftProperties,
476  typename inputDataRightValueType, class ...inputDataRightProperties>
477  void
479  contractDataDataScalar( Kokkos::DynRankView<outputDataValueType, outputDataProperties...> outputData,
480  const Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft,
481  const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight,
482  const bool sumInto ) {
483 
484 #ifdef HAVE_INTREPID2_DEBUG
485  {
486  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.rank() != 2, std::invalid_argument,
487  ">>> ERROR (ArrayTools::contractDataDataScalar): Rank of the left input argument must equal 2!");
488  INTREPID2_TEST_FOR_EXCEPTION( inputDataRight.rank() != 2, std::invalid_argument,
489  ">>> ERROR (ArrayTools::contractDataDataScalar): Rank of right input argument must equal 2!");
490  INTREPID2_TEST_FOR_EXCEPTION( outputData.rank() != 1, std::invalid_argument,
491  ">>> ERROR (ArrayTools::contractDataDataScalar): Rank of output argument must equal 1!");
492  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(0) != inputDataRight.extent(0), std::invalid_argument,
493  ">>> ERROR (ArrayTools::contractDataDataScalar): Zeroth dimensions (number of integration domains) of the left and right input containers must agree!");
494  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(1) != inputDataRight.extent(1), std::invalid_argument,
495  ">>> ERROR (ArrayTools::contractDataDataScalar): First dimensions (numbers of integration points) of the left and right input containers must agree!");
496  INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(0) != inputDataRight.extent(0), std::invalid_argument,
497  ">>> ERROR (ArrayTools::contractDataDataScalar): Zeroth dimensions (numbers of integration domains) of the input and output containers must agree!");
498  }
499 #endif
500 
502  inputDataLeft,
503  inputDataRight,
504  sumInto );
505  }
506 
507 
508  template<typename DeviceType>
509  template<typename outputDataValueType, class ...outputDataProperties,
510  typename inputDataLeftValueType, class ...inputDataLeftProperties,
511  typename inputDataRightValueType, class ...inputDataRightProperties>
512  void
514  contractDataDataVector( Kokkos::DynRankView<outputDataValueType, outputDataProperties...> outputData,
515  const Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft,
516  const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight,
517  const bool sumInto ) {
518 
519 #ifdef HAVE_INTREPID2_DEBUG
520  {
521  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.rank() != 3, std::invalid_argument,
522  ">>> ERROR (ArrayTools::contractDataDataVector): Rank of the left input argument must equal 3!");
523  INTREPID2_TEST_FOR_EXCEPTION( inputDataRight.rank() != 3, std::invalid_argument,
524  ">>> ERROR (ArrayTools::contractDataDataVector): Rank of right input argument must equal 3!");
525  INTREPID2_TEST_FOR_EXCEPTION( outputData.rank() != 1, std::invalid_argument,
526  ">>> ERROR (ArrayTools::contractDataDataVector): Rank of output argument must equal 1!");
527  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(0) != inputDataRight.extent(0), std::invalid_argument,
528  ">>> ERROR (ArrayTools::contractDataDataVector): Zeroth dimensions (number of integration domains) of the left and right input containers must agree!");
529  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(1) != inputDataRight.extent(1), std::invalid_argument,
530  ">>> ERROR (ArrayTools::contractDataDataVector): First dimensions (numbers of integration points) of the left and right input containers must agree!");
531  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(2) != inputDataRight.extent(2), std::invalid_argument,
532  ">>> ERROR (ArrayTools::contractDataDataVector): Second dimensions (numbers of vector components) of the left and right input containers must agree!");
533  INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(0) != inputDataRight.extent(0), std::invalid_argument,
534  ">>> ERROR (ArrayTools::contractDataDataVector): Zeroth dimensions (numbers of integration domains) of the input and output containers must agree!");
535  }
536 #endif
537 
539  inputDataLeft,
540  inputDataRight,
541  sumInto );
542  }
543 
544 
545  template<typename DeviceType>
546  template<typename outputDataValueType, class ...outputDataProperties,
547  typename inputDataLeftValueType, class ...inputDataLeftProperties,
548  typename inputDataRightValueType, class ...inputDataRightProperties>
549  void
551  contractDataDataTensor( Kokkos::DynRankView<outputDataValueType, outputDataProperties...> outputData,
552  const Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft,
553  const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight,
554  const bool sumInto ) {
555 
556 #ifdef HAVE_INTREPID2_DEBUG
557  {
558  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.rank() != 4, std::invalid_argument,
559  ">>> ERROR (ArrayTools::contractDataDataTensor): Rank of the left input argument must equal 4");
560  INTREPID2_TEST_FOR_EXCEPTION( inputDataRight.rank() != 4, std::invalid_argument,
561  ">>> ERROR (ArrayTools::contractDataDataTensor): Rank of right input argument must equal 4!");
562  INTREPID2_TEST_FOR_EXCEPTION( outputData.rank() != 1, std::invalid_argument,
563  ">>> ERROR (ArrayTools::contractDataDataTensor): Rank of output argument must equal 1!");
564  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(0) != inputDataRight.extent(0), std::invalid_argument,
565  ">>> ERROR (ArrayTools::contractDataDataTensor): Zeroth dimensions (number of integration domains) of the left and right input containers must agree!");
566  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(1) != inputDataRight.extent(1), std::invalid_argument,
567  ">>> ERROR (ArrayTools::contractDataDataTensor): First dimensions (numbers of integration points) of the left and right input containers must agree!");
568  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(2) != inputDataRight.extent(2), std::invalid_argument,
569  ">>> ERROR (ArrayTools::contractDataDataTensor): Second dimensions (first tensor dimensions) of the left and right input containers must agree!");
570  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(3) != inputDataRight.extent(3), std::invalid_argument,
571  ">>> ERROR (ArrayTools::contractDataDataTensor): Third dimensions (second tensor dimensions) of the left and right input containers must agree!");
572  INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(0) != inputDataRight.extent(0), std::invalid_argument,
573  ">>> ERROR (ArrayTools::contractDataDataTensor): Zeroth dimensions (numbers of integration domains) of the input and output containers must agree!");
574  }
575 #endif
576 
578  inputDataLeft,
579  inputDataRight,
580  sumInto );
581  }
582 
583 }
584 #endif
static void contractFieldFieldTensor(Kokkos::DynRankView< outputFieldValueType, outputFieldProperties...> outputFields, const Kokkos::DynRankView< leftFieldValueType, leftFieldProperties...> leftFields, const Kokkos::DynRankView< rightFieldValueType, rightFieldProperties...> rightFields, const bool sumInto=false)
Contracts the &quot;point&quot; and &quot;space&quot; dimensions P, D1, and D2 of two rank-5 containers with dimensions (...
static void contractFieldFieldScalar(Kokkos::DynRankView< outputFieldValueType, outputFieldProperties...> outputFields, const Kokkos::DynRankView< leftFieldValueType, leftFieldProperties...> leftFields, const Kokkos::DynRankView< rightFieldValueType, rightFieldProperties...> rightFields, const bool sumInto=false)
Contracts the &quot;point&quot; dimension P of two rank-3 containers with dimensions (C,L,P) and (C...
static void contractDataFieldTensor(Kokkos::DynRankView< outputFieldValueType, outputFieldProperties...> outputFields, const Kokkos::DynRankView< inputDataValueType, inputDataProperties...> inputData, const Kokkos::DynRankView< inputFieldValueType, inputFieldProperties...> inputFields, const bool sumInto=false)
Contracts the &quot;point&quot; and &quot;space&quot; dimensions P, D1 and D2 of a rank-5 container and a rank-4 containe...
static void contractDataDataScalar(Kokkos::DynRankView< outputDataValueType, outputDataProperties...> outputData, const Kokkos::DynRankView< inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft, const Kokkos::DynRankView< inputDataRightValueType, inputDataRightProperties...> inputDataRight, const bool sumInto=false)
Contracts the &quot;point&quot; dimensions P of rank-2 containers with dimensions (C,P), and returns the result...
static void contractDataFieldVector(Kokkos::DynRankView< outputFieldValueType, outputFieldProperties...> outputFields, const Kokkos::DynRankView< inputDataValueType, inputDataProperties...> inputData, const Kokkos::DynRankView< inputFieldValueType, inputFieldProperties...> inputFields, const bool sumInto=false)
Contracts the &quot;point&quot; and &quot;space&quot; dimensions P and D of a rank-4 container and a rank-3 container wit...
Functor to contractDataField see Intrepid2::ArrayTools for more.
static void contractDataFieldScalar(Kokkos::DynRankView< outputFieldValueType, outputFieldProperties...> outputFields, const Kokkos::DynRankView< inputDataValueType, inputDataProperties...> inputData, const Kokkos::DynRankView< inputFieldValueType, inputFieldProperties...> inputFields, const bool sumInto=false)
Contracts the &quot;point&quot; dimensions P of a rank-3 containers and a rank-2 container with dimensions (C...
static void contractDataDataVector(Kokkos::DynRankView< outputDataValueType, outputDataProperties...> outputData, const Kokkos::DynRankView< inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft, const Kokkos::DynRankView< inputDataRightValueType, inputDataRightProperties...> inputDataRight, const bool sumInto=false)
Contracts the &quot;point&quot; and &quot;space&quot; dimensions P and D of rank-3 containers with dimensions (C...
Functor to contractDataData see Intrepid2::ArrayTools for more.
static void contractDataDataTensor(Kokkos::DynRankView< outputDataValueType, outputDataProperties...> outputData, const Kokkos::DynRankView< inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft, const Kokkos::DynRankView< inputDataRightValueType, inputDataRightProperties...> inputDataRight, const bool sumInto=false)
Contracts the &quot;point&quot; and &quot;space&quot; dimensions P, D1 and D2 of rank-4 containers with dimensions (C...
Functor to contractFieldField see Intrepid2::ArrayTools for more.
Utility class that provides methods for higher-order algebraic manipulation of user-defined arrays...
static void contractFieldFieldVector(Kokkos::DynRankView< outputFieldValueType, outputFieldProperties...> outputFields, const Kokkos::DynRankView< leftFieldValueType, leftFieldProperties...> leftFields, const Kokkos::DynRankView< rightFieldValueType, rightFieldProperties...> rightFields, const bool sumInto=false)
Contracts the &quot;point&quot; and &quot;space&quot; dimensions P and D1 of two rank-4 containers with dimensions (C...