Intrepid2
Intrepid2_ArrayToolsDefContractions.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Intrepid Package
5 // Copyright (2007) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Kyungjoo Kim (kyukim@sandia.gov), or
38 // Mauro Perego (mperego@sandia.gov)
39 //
40 // ************************************************************************
41 // @HEADER
42 
49 #ifndef __INTREPID2_ARRAYTOOLS_DEF_CONTRACTIONS_HPP__
50 #define __INTREPID2_ARRAYTOOLS_DEF_CONTRACTIONS_HPP__
51 
52 namespace Intrepid2 {
53 
54 
55  namespace FunctorArrayTools {
59  template < typename outFieldViewType , typename leftFieldViewType , typename rightFieldViewType >
61  outFieldViewType _outputFields;
62  leftFieldViewType _leftFields;
63  rightFieldViewType _rightFields;
64  const bool _sumInto;
65  typedef typename outFieldViewType::value_type value_type;
66 
67  KOKKOS_INLINE_FUNCTION
68  F_contractFieldField(outFieldViewType outputFields_,
69  leftFieldViewType leftFields_,
70  rightFieldViewType rightFields_,
71  const bool sumInto_)
72  : _outputFields(outputFields_), _leftFields(leftFields_), _rightFields(rightFields_), _sumInto(sumInto_) {}
73 
74  KOKKOS_INLINE_FUNCTION
75  void operator()(const size_type iter) const {
76  size_type cl, lbf, rbf;
77  unrollIndex( cl, lbf, rbf,
78  _outputFields.extent(0),
79  _outputFields.extent(1),
80  _outputFields.extent(2),
81  iter );
82 
83  const size_type npts = _leftFields.extent(2);
84  const ordinal_type iend = _leftFields.extent(3);
85  const ordinal_type jend = _leftFields.extent(4);
86 
87  value_type tmp(0);
88  for (size_type qp = 0; qp < npts; ++qp)
89  for (ordinal_type i = 0; i < iend; ++i)
90  for (ordinal_type j = 0; j < jend; ++j)
91  tmp += _leftFields(cl, lbf, qp, i, j)*_rightFields(cl, rbf, qp, i, j);
92  if (_sumInto)
93  _outputFields( cl, lbf, rbf ) = _outputFields( cl, lbf, rbf ) + tmp;
94  else
95  _outputFields( cl, lbf, rbf ) = tmp;
96  }
97  };
98  } //end namespace
99 
100  template<typename SpT>
101  template<typename outputFieldValueType, class ...outputFieldProperties,
102  typename leftFieldValueType, class ...leftFieldProperties,
103  typename rightFieldValueType, class ...rightFieldProperties>
104  void
106  contractFieldField( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
107  const Kokkos::DynRankView<leftFieldValueType, leftFieldProperties...> leftFields,
108  const Kokkos::DynRankView<rightFieldValueType, rightFieldProperties...> rightFields,
109  const bool sumInto ) {
110 
111  typedef Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outFieldViewType;
112  typedef Kokkos::DynRankView<leftFieldValueType,leftFieldProperties...> leftFieldViewType;
113  typedef Kokkos::DynRankView<rightFieldValueType,rightFieldProperties...> rightFieldViewType;
115  typedef typename ExecSpace< typename outFieldViewType::execution_space, SpT >::ExecSpaceType ExecSpaceType;
116 
117 
118  const size_type loopSize = leftFields.extent(0)*leftFields.extent(1)*rightFields.extent(1);
119  Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
120  Kokkos::parallel_for( policy, FunctorType(outputFields, leftFields, rightFields, sumInto) );
121  }
122 
123 
124  namespace FunctorArrayTools {
128  template < typename outputFieldsViewType , typename inputDataViewType , typename inputFieldsViewType >
130  outputFieldsViewType _outputFields;
131  inputDataViewType _inputData;
132  inputFieldsViewType _inputFields;
133  const bool _sumInto;
134  typedef typename outputFieldsViewType::value_type value_type;
135 
136  KOKKOS_INLINE_FUNCTION
137  F_contractDataField(outputFieldsViewType outputFields_,
138  inputDataViewType inputData_,
139  inputFieldsViewType inputFields_,
140  const bool sumInto_)
141  : _outputFields(outputFields_), _inputData(inputData_), _inputFields(inputFields_), _sumInto(sumInto_) {}
142 
143  KOKKOS_DEFAULTED_FUNCTION
144  ~F_contractDataField() = default;
145 
146  KOKKOS_INLINE_FUNCTION
147  void operator()(const size_type iter) const {
148  size_type cl, bf;
149  unrollIndex( cl, bf,
150  _inputFields.extent(0),
151  _inputFields.extent(1),
152  iter );
153 
154  auto result = Kokkos::subview( _outputFields, cl, bf );
155 
156  const auto field = Kokkos::subview( _inputFields, cl, bf, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL() );
157  const auto data = Kokkos::subview( _inputData, cl, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL() );
158 
159  const size_type npts = field.extent(0);
160  const ordinal_type iend = field.extent(1);
161  const ordinal_type jend = field.extent(2);
162 
163  value_type tmp(0);
164 
165  if(_inputData.extent(1) != 1)
166  for (size_type qp = 0; qp < npts; ++qp)
167  for (ordinal_type i = 0; i < iend; ++i)
168  for (ordinal_type j = 0; j < jend; ++j)
169  tmp += field(qp, i, j) * data(qp, i, j);
170  else
171  for (size_type qp = 0; qp < npts; ++qp)
172  for (ordinal_type i = 0; i < iend; ++i)
173  for (ordinal_type j = 0; j < jend; ++j)
174  tmp += field(qp, i, j) * data(0, i, j);
175 
176  if (_sumInto)
177  result() = result() + tmp;
178  else
179  result() = tmp;
180  }
181  };
182  } //namespace
183 
184  template<typename SpT>
185  template<typename outputFieldValueType, class ...outputFieldProperties,
186  typename inputDataValueType, class ...inputDataProperties,
187  typename inputFieldValueType, class ...inputFieldProperties>
188  void
190  contractDataField( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
191  const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
192  const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields,
193  const bool sumInto ) {
194 
195  typedef Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFieldsViewType;
196  typedef Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputDataViewType;
197  typedef Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFieldsViewType;
199  typedef typename ExecSpace< typename inputFieldsViewType::execution_space , SpT >::ExecSpaceType ExecSpaceType;
200 
201  const size_type loopSize = inputFields.extent(0)*inputFields.extent(1);
202  Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
203  Kokkos::parallel_for( policy, FunctorType(outputFields, inputData, inputFields, sumInto) );
204  }
205 
206 
207  namespace FunctorArrayTools {
211  template < typename outputDataViewType , typename inputDataLeftViewType , typename inputDataRightViewType >
213  outputDataViewType _outputData;
214  inputDataLeftViewType _inputDataLeft;
215  inputDataRightViewType _inputDataRight;
216  const bool _sumInto;
217  typedef typename outputDataViewType::value_type value_type;
218 
219  KOKKOS_INLINE_FUNCTION
220  F_contractDataData(outputDataViewType outputData_,
221  inputDataLeftViewType inputDataLeft_,
222  inputDataRightViewType inputDataRight_,
223  const bool sumInto_)
224  : _outputData(outputData_), _inputDataLeft(inputDataLeft_), _inputDataRight(inputDataRight_), _sumInto(sumInto_) {}
225 
226  KOKKOS_DEFAULTED_FUNCTION
227  ~F_contractDataData() = default;
228 
229  KOKKOS_INLINE_FUNCTION
230  void operator()(const size_type iter) const {
231  const size_type cl = iter;
232 
233  auto result = Kokkos::subview( _outputData, cl );
234  const auto left = Kokkos::subview( _inputDataLeft, cl, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL() );
235  const auto right = Kokkos::subview( _inputDataRight, cl, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL() );
236 
237  size_type npts = left.extent(0);
238  ordinal_type iend = left.extent(1);
239  ordinal_type jend = left.extent(2);
240 
241  value_type tmp(0);
242  for (size_type qp = 0; qp < npts; ++qp)
243  for (ordinal_type i = 0; i < iend; ++i)
244  for (ordinal_type j = 0; j < jend; ++j)
245  tmp += left(qp, i, j)*right(qp, i, j);
246 
247  if (_sumInto)
248  result() = result() + tmp;
249  else
250  result() = tmp;
251  }
252  };
253  } //namespace
254 
255  template<typename SpT>
256  template<typename outputDataValueType, class ...outputDataProperties,
257  typename inputDataLeftValueType, class ...inputDataLeftProperties,
258  typename inputDataRightValueType, class ...inputDataRightProperties>
259  void
261  contractDataData( Kokkos::DynRankView<outputDataValueType, outputDataProperties...> outputData,
262  const Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft,
263  const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight,
264  const bool sumInto ) {
265  typedef Kokkos::DynRankView<outputDataValueType, outputDataProperties...> outputDataViewType;
266  typedef Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeftViewType;
267  typedef Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRightViewType;
269  typedef typename ExecSpace< typename inputDataLeftViewType::execution_space , SpT>::ExecSpaceType ExecSpaceType;
270 
271  const size_type loopSize = inputDataLeft.extent(0);
272  Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
273  Kokkos::parallel_for( policy, FunctorType(outputData, inputDataLeft, inputDataRight, sumInto) );
274  }
275 
276 
277 
278  template<typename ExecSpaceType>
279  template<typename outputFieldValueType, class ...outputFieldProperties,
280  typename leftFieldValueType, class ...leftFieldProperties,
281  typename rightFieldValueType, class ...rightFieldProperties>
282  void
284  contractFieldFieldScalar( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
285  const Kokkos::DynRankView<leftFieldValueType, leftFieldProperties...> leftFields,
286  const Kokkos::DynRankView<rightFieldValueType, rightFieldProperties...> rightFields,
287  const bool sumInto ) {
288 
289 #ifdef HAVE_INTREPID2_DEBUG
290  {
291  INTREPID2_TEST_FOR_EXCEPTION( leftFields.rank() != 3, std::invalid_argument,
292  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Rank of the left input argument must equal 3!");
293  INTREPID2_TEST_FOR_EXCEPTION( rightFields.rank() != 3, std::invalid_argument,
294  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Rank of right input argument must equal 3!");
295  INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 3, std::invalid_argument,
296  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Rank of output argument must equal 3!");
297  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(0) != rightFields.extent(0), std::invalid_argument,
298  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Zeroth dimensions (number of integration domains) of the left and right input containers must agree!");
299  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(2) != rightFields.extent(2), std::invalid_argument,
300  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Second dimensions (numbers of integration points) of the left and right input containers must agree!");
301  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != rightFields.extent(0), std::invalid_argument,
302  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Zeroth dimensions (numbers of integration domains) of the input and output containers must agree!");
303  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(1) != leftFields.extent(1), std::invalid_argument,
304  ">>> ERROR (ArrayTools::contractFieldFieldScalar): First dimension of output container and first dimension of left input container must agree!");
305  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(2) != rightFields.extent(1), std::invalid_argument,
306  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Second dimension of output container and first dimension of right input container must agree!");
307 
308  }
309 #endif
310 
312  leftFields,
313  rightFields,
314  sumInto );
315  }
316 
317 
318  template<typename ExecSpaceType>
319  template<typename outputFieldValueType, class ...outputFieldProperties,
320  typename leftFieldValueType, class ...leftFieldProperties,
321  typename rightFieldValueType, class ...rightFieldProperties>
322  void
324  contractFieldFieldVector( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
325  const Kokkos::DynRankView<leftFieldValueType, leftFieldProperties...> leftFields,
326  const Kokkos::DynRankView<rightFieldValueType, rightFieldProperties...> rightFields,
327  const bool sumInto ) {
328 
329 #ifdef HAVE_INTREPID2_DEBUG
330  {
331  INTREPID2_TEST_FOR_EXCEPTION( leftFields.rank() != 4, std::invalid_argument,
332  ">>> ERROR (ArrayTools::contractFieldFieldVector): Rank of the left input argument must equal 4!");
333  INTREPID2_TEST_FOR_EXCEPTION( rightFields.rank() != 4, std::invalid_argument,
334  ">>> ERROR (ArrayTools::contractFieldFieldVector): Rank of right input argument must equal 4!");
335  INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 3, std::invalid_argument,
336  ">>> ERROR (ArrayTools::contractFieldFieldVector): Rank of output argument must equal 3!");
337  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(0) != rightFields.extent(0), std::invalid_argument,
338  ">>> ERROR (ArrayTools::contractFieldFieldVector): Zeroth dimensions (number of integration domains) of the left and right input containers must agree!");
339  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(2) != rightFields.extent(2), std::invalid_argument,
340  ">>> ERROR (ArrayTools::contractFieldFieldVector): Second dimensions (numbers of integration points) of the left and right input containers must agree!");
341  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(3) != rightFields.extent(3), std::invalid_argument,
342  ">>> ERROR (ArrayTools::contractFieldFieldVector): Third dimensions (numbers of vector components) of the left and right input containers must agree!");
343  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != rightFields.extent(0), std::invalid_argument,
344  ">>> ERROR (ArrayTools::contractFieldFieldVector): Zeroth dimensions (numbers of integration domains) of the input and output containers must agree!");
345  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(1) != leftFields.extent(1), std::invalid_argument,
346  ">>> ERROR (ArrayTools::contractFieldFieldVector): First dimension of output container and first dimension of left input container must agree!");
347  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(2) != rightFields.extent(1), std::invalid_argument,
348  ">>> ERROR (ArrayTools::contractFieldFieldVector): Second dimension of output container and first dimension of right input container must agree!");
349  }
350 #endif
351 
353  leftFields,
354  rightFields,
355  sumInto );
356  }
357 
358 
359  template<typename ExecSpaceType>
360  template<typename outputFieldValueType, class ...outputFieldProperties,
361  typename leftFieldValueType, class ...leftFieldProperties,
362  typename rightFieldValueType, class ...rightFieldProperties>
363  void
365  contractFieldFieldTensor( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
366  const Kokkos::DynRankView<leftFieldValueType, leftFieldProperties...> leftFields,
367  const Kokkos::DynRankView<rightFieldValueType, rightFieldProperties...> rightFields,
368  const bool sumInto ) {
369 
370 #ifdef HAVE_INTREPID2_DEBUG
371  {
372  INTREPID2_TEST_FOR_EXCEPTION( leftFields.rank() != 5, std::invalid_argument,
373  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Rank of the left input argument must equal 5!");
374  INTREPID2_TEST_FOR_EXCEPTION( rightFields.rank() != 5, std::invalid_argument,
375  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Rank of right input argument must equal 5!");
376  INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 3, std::invalid_argument,
377  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Rank of output argument must equal 3!");
378  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(0) != rightFields.extent(0), std::invalid_argument,
379  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Zeroth dimensions (number of integration domains) of the left and right input containers must agree!");
380  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(2) != rightFields.extent(2), std::invalid_argument,
381  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Second dimensions (numbers of integration points) of the left and right input containers must agree!");
382  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(3) != rightFields.extent(3), std::invalid_argument,
383  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Third dimensions (first tensor dimensions) of the left and right input containers must agree!");
384  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(4) != rightFields.extent(4), std::invalid_argument,
385  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Fourth dimensions (second tensor dimensions) of the left and right input containers must agree!");
386  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != rightFields.extent(0), std::invalid_argument,
387  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Zeroth dimensions (numbers of integration domains) of the input and output containers must agree!");
388  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(1) != leftFields.extent(1), std::invalid_argument,
389  ">>> ERROR (ArrayTools::contractFieldFieldTensor): First dimension of output container and first dimension of left input container must agree!");
390  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(2) != rightFields.extent(1), std::invalid_argument,
391  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Second dimension of output container and first dimension of right input container must agree!");
392  }
393 #endif
394 
396  leftFields,
397  rightFields,
398  sumInto );
399  }
400 
401 
402  template<typename ExecSpaceType>
403  template<typename outputFieldValueType, class ...outputFieldProperties,
404  typename inputDataValueType, class ...inputDataProperties,
405  typename inputFieldValueType, class ...inputFieldProperties>
406  void
408  contractDataFieldScalar( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
409  const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
410  const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields,
411  const bool sumInto ) {
412 
413 #ifdef HAVE_INTREPID2_DEBUG
414  {
415  INTREPID2_TEST_FOR_EXCEPTION( inputFields.rank() != 3, std::invalid_argument,
416  ">>> ERROR (ArrayTools::contractDataFieldScalar): Rank of the fields input argument must equal 3!");
417  INTREPID2_TEST_FOR_EXCEPTION( inputData.rank() != 2, std::invalid_argument,
418  ">>> ERROR (ArrayTools::contractDataFieldScalar): Rank of the data input argument must equal 2!");
419  INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 2, std::invalid_argument,
420  ">>> ERROR (ArrayTools::contractDataFieldScalar): Rank of output argument must equal 2!");
421  INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(0) != inputData.extent(0), std::invalid_argument,
422  ">>> ERROR (ArrayTools::contractDataFieldScalar): Zeroth dimensions (number of integration domains) of the fields and data input containers must agree!");
423 
424  INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(1) != inputFields.extent(2) &&
425  inputData.extent(1) != 1, std::invalid_argument,
426  ">>> 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!");
427  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != inputFields.extent(0), std::invalid_argument,
428  ">>> ERROR (ArrayTools::contractDataFieldScalar): Zeroth dimensions (numbers of integration domains) of the fields input and output containers must agree!");
429  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(1) != inputFields.extent(1), std::invalid_argument,
430  ">>> ERROR (ArrayTools::contractDataFieldScalar): First dimensions (number of fields) of the fields input and output containers must agree!");
431  }
432 #endif
433 
435  inputData,
436  inputFields,
437  sumInto );
438  }
439 
440 
441  template<typename ExecSpaceType>
442  template<typename outputFieldValueType, class ...outputFieldProperties,
443  typename inputDataValueType, class ...inputDataProperties,
444  typename inputFieldValueType, class ...inputFieldProperties>
445  void
447  contractDataFieldVector( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
448  const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
449  const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields,
450  const bool sumInto ) {
451 
452 #ifdef HAVE_INTREPID2_DEBUG
453  {
454  INTREPID2_TEST_FOR_EXCEPTION( inputFields.rank() != 4, std::invalid_argument,
455  ">>> ERROR (ArrayTools::contractDataFieldVector): Rank of the fields input argument must equal 4!");
456  INTREPID2_TEST_FOR_EXCEPTION( inputData.rank() != 3, std::invalid_argument,
457  ">>> ERROR (ArrayTools::contractDataFieldVector): Rank of the data input argument must equal 3!");
458  INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 2, std::invalid_argument,
459  ">>> ERROR (ArrayTools::contractDataFieldVector): Rank of output argument must equal 2!");
460  INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(0) != inputData.extent(0), std::invalid_argument,
461  ">>> ERROR (ArrayTools::contractDataFieldVector): Zeroth dimensions (number of integration domains) of the fields and data input containers must agree!");
462  INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(1) != inputFields.extent(2) &&
463  inputData.extent(1) != 1, std::invalid_argument,
464  ">>> 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!");
465  INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(3) != inputData.extent(2), std::invalid_argument,
466  ">>> ERROR (ArrayTools::contractDataFieldVector): Third dimension of the fields input container and second dimension of data input container (vector index) must agree!");
467  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != inputFields.extent(0), std::invalid_argument,
468  ">>> ERROR (ArrayTools::contractDataFieldVector): Zeroth dimensions (numbers of integration domains) of the fields input and output containers must agree!");
469  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(1) != inputFields.extent(1), std::invalid_argument,
470  ">>> ERROR (ArrayTools::contractDataFieldVector): First dimensions of output container and fields input container (number of fields) must agree!");
471  }
472 #endif
473 
475  inputData,
476  inputFields,
477  sumInto );
478  }
479 
480 
481 
482  template<typename ExecSpaceType>
483  template<typename outputFieldValueType, class ...outputFieldProperties,
484  typename inputDataValueType, class ...inputDataProperties,
485  typename inputFieldValueType, class ...inputFieldProperties>
486  void
488  contractDataFieldTensor( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
489  const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
490  const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields,
491  const bool sumInto ) {
492 
493 #ifdef HAVE_INTREPID2_DEBUG
494  {
495  INTREPID2_TEST_FOR_EXCEPTION( inputFields.rank() != 5, std::invalid_argument,
496  ">>> ERROR (ArrayTools::contractDataFieldTensor): Rank of the fields input argument must equal 5!");
497  INTREPID2_TEST_FOR_EXCEPTION( inputData.rank() != 4, std::invalid_argument,
498  ">>> ERROR (ArrayTools::contractDataFieldTensor): Rank of the data input argument must equal 4!");
499  INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 2, std::invalid_argument,
500  ">>> ERROR (ArrayTools::contractDataFieldTensor): Rank of output argument must equal 2!");
501  INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(0) != inputData.extent(0), std::invalid_argument,
502  ">>> ERROR (ArrayTools::contractDataFieldTensor): Zeroth dimensions (number of integration domains) of the fields and data input containers must agree!");
503  INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(1) != inputFields.extent(2) && inputData.extent(1) != 1, std::invalid_argument,
504  ">>> 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!");
505  INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(3) != inputData.extent(2), std::invalid_argument,
506  ">>> ERROR (ArrayTools::contractDataFieldTensor): Third dimension of the fields input container and second dimension of data input container (first tensor dimension) must agree!");
507  INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(4) != inputData.extent(3), std::invalid_argument,
508  ">>> ERROR (ArrayTools::contractDataFieldTensor): Fourth dimension of the fields input container and third dimension of data input container (second tensor dimension) must agree!");
509  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != inputFields.extent(0), std::invalid_argument,
510  ">>> ERROR (ArrayTools::contractDataFieldTensor): Zeroth dimensions (numbers of integration domains) of the fields input and output containers must agree!");
511  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(1) != inputFields.extent(1), std::invalid_argument,
512  ">>> ERROR (ArrayTools::contractDataFieldTensor): First dimensions (number of fields) of output container and fields input container must agree!");
513  }
514 #endif
515 
517  inputData,
518  inputFields,
519  sumInto );
520  }
521 
522 
523 
524  template<typename ExecSpaceType>
525  template<typename outputDataValueType, class ...outputDataProperties,
526  typename inputDataLeftValueType, class ...inputDataLeftProperties,
527  typename inputDataRightValueType, class ...inputDataRightProperties>
528  void
530  contractDataDataScalar( Kokkos::DynRankView<outputDataValueType, outputDataProperties...> outputData,
531  const Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft,
532  const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight,
533  const bool sumInto ) {
534 
535 #ifdef HAVE_INTREPID2_DEBUG
536  {
537  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.rank() != 2, std::invalid_argument,
538  ">>> ERROR (ArrayTools::contractDataDataScalar): Rank of the left input argument must equal 2!");
539  INTREPID2_TEST_FOR_EXCEPTION( inputDataRight.rank() != 2, std::invalid_argument,
540  ">>> ERROR (ArrayTools::contractDataDataScalar): Rank of right input argument must equal 2!");
541  INTREPID2_TEST_FOR_EXCEPTION( outputData.rank() != 1, std::invalid_argument,
542  ">>> ERROR (ArrayTools::contractDataDataScalar): Rank of output argument must equal 1!");
543  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(0) != inputDataRight.extent(0), std::invalid_argument,
544  ">>> ERROR (ArrayTools::contractDataDataScalar): Zeroth dimensions (number of integration domains) of the left and right input containers must agree!");
545  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(1) != inputDataRight.extent(1), std::invalid_argument,
546  ">>> ERROR (ArrayTools::contractDataDataScalar): First dimensions (numbers of integration points) of the left and right input containers must agree!");
547  INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(0) != inputDataRight.extent(0), std::invalid_argument,
548  ">>> ERROR (ArrayTools::contractDataDataScalar): Zeroth dimensions (numbers of integration domains) of the input and output containers must agree!");
549  }
550 #endif
551 
553  inputDataLeft,
554  inputDataRight,
555  sumInto );
556  }
557 
558 
559  template<typename ExecSpaceType>
560  template<typename outputDataValueType, class ...outputDataProperties,
561  typename inputDataLeftValueType, class ...inputDataLeftProperties,
562  typename inputDataRightValueType, class ...inputDataRightProperties>
563  void
565  contractDataDataVector( Kokkos::DynRankView<outputDataValueType, outputDataProperties...> outputData,
566  const Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft,
567  const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight,
568  const bool sumInto ) {
569 
570 #ifdef HAVE_INTREPID2_DEBUG
571  {
572  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.rank() != 3, std::invalid_argument,
573  ">>> ERROR (ArrayTools::contractDataDataVector): Rank of the left input argument must equal 3!");
574  INTREPID2_TEST_FOR_EXCEPTION( inputDataRight.rank() != 3, std::invalid_argument,
575  ">>> ERROR (ArrayTools::contractDataDataVector): Rank of right input argument must equal 3!");
576  INTREPID2_TEST_FOR_EXCEPTION( outputData.rank() != 1, std::invalid_argument,
577  ">>> ERROR (ArrayTools::contractDataDataVector): Rank of output argument must equal 1!");
578  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(0) != inputDataRight.extent(0), std::invalid_argument,
579  ">>> ERROR (ArrayTools::contractDataDataVector): Zeroth dimensions (number of integration domains) of the left and right input containers must agree!");
580  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(1) != inputDataRight.extent(1), std::invalid_argument,
581  ">>> ERROR (ArrayTools::contractDataDataVector): First dimensions (numbers of integration points) of the left and right input containers must agree!");
582  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(2) != inputDataRight.extent(2), std::invalid_argument,
583  ">>> ERROR (ArrayTools::contractDataDataVector): Second dimensions (numbers of vector components) of the left and right input containers must agree!");
584  INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(0) != inputDataRight.extent(0), std::invalid_argument,
585  ">>> ERROR (ArrayTools::contractDataDataVector): Zeroth dimensions (numbers of integration domains) of the input and output containers must agree!");
586  }
587 #endif
588 
590  inputDataLeft,
591  inputDataRight,
592  sumInto );
593  }
594 
595 
596  template<typename ExecSpaceType>
597  template<typename outputDataValueType, class ...outputDataProperties,
598  typename inputDataLeftValueType, class ...inputDataLeftProperties,
599  typename inputDataRightValueType, class ...inputDataRightProperties>
600  void
602  contractDataDataTensor( Kokkos::DynRankView<outputDataValueType, outputDataProperties...> outputData,
603  const Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft,
604  const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight,
605  const bool sumInto ) {
606 
607 #ifdef HAVE_INTREPID2_DEBUG
608  {
609  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.rank() != 4, std::invalid_argument,
610  ">>> ERROR (ArrayTools::contractDataDataTensor): Rank of the left input argument must equal 4");
611  INTREPID2_TEST_FOR_EXCEPTION( inputDataRight.rank() != 4, std::invalid_argument,
612  ">>> ERROR (ArrayTools::contractDataDataTensor): Rank of right input argument must equal 4!");
613  INTREPID2_TEST_FOR_EXCEPTION( outputData.rank() != 1, std::invalid_argument,
614  ">>> ERROR (ArrayTools::contractDataDataTensor): Rank of output argument must equal 1!");
615  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(0) != inputDataRight.extent(0), std::invalid_argument,
616  ">>> ERROR (ArrayTools::contractDataDataTensor): Zeroth dimensions (number of integration domains) of the left and right input containers must agree!");
617  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(1) != inputDataRight.extent(1), std::invalid_argument,
618  ">>> ERROR (ArrayTools::contractDataDataTensor): First dimensions (numbers of integration points) of the left and right input containers must agree!");
619  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(2) != inputDataRight.extent(2), std::invalid_argument,
620  ">>> ERROR (ArrayTools::contractDataDataTensor): Second dimensions (first tensor dimensions) of the left and right input containers must agree!");
621  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(3) != inputDataRight.extent(3), std::invalid_argument,
622  ">>> ERROR (ArrayTools::contractDataDataTensor): Third dimensions (second tensor dimensions) of the left and right input containers must agree!");
623  INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(0) != inputDataRight.extent(0), std::invalid_argument,
624  ">>> ERROR (ArrayTools::contractDataDataTensor): Zeroth dimensions (numbers of integration domains) of the input and output containers must agree!");
625  }
626 #endif
627 
629  inputDataLeft,
630  inputDataRight,
631  sumInto );
632  }
633 
634 }
635 #endif
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 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 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...
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 contractDataField see Intrepid2::ArrayTools for more.
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...
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 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...
Functor to contractDataData see Intrepid2::ArrayTools for more.
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...
Functor to contractFieldField 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...
Utility class that provides methods for higher-order algebraic manipulation of user-defined arrays...