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  _outputFields( cl, lbf, rbf ) *= (_sumInto ? 1 : 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  _outputFields( cl, lbf, rbf ) += _leftFields(cl, lbf, qp, i, j)*_rightFields(cl, rbf, qp, i, j);
92  }
93  };
94  } //end namespace
95 
96  template<typename DeviceType>
97  template<typename outputFieldValueType, class ...outputFieldProperties,
98  typename leftFieldValueType, class ...leftFieldProperties,
99  typename rightFieldValueType, class ...rightFieldProperties>
100  void
102  contractFieldField( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
103  const Kokkos::DynRankView<leftFieldValueType, leftFieldProperties...> leftFields,
104  const Kokkos::DynRankView<rightFieldValueType, rightFieldProperties...> rightFields,
105  const bool sumInto ) {
106 
107  typedef Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outFieldViewType;
108  typedef Kokkos::DynRankView<leftFieldValueType,leftFieldProperties...> leftFieldViewType;
109  typedef Kokkos::DynRankView<rightFieldValueType,rightFieldProperties...> rightFieldViewType;
111 
112  const size_type loopSize = leftFields.extent(0)*leftFields.extent(1)*rightFields.extent(1);
113  Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
114  Kokkos::parallel_for( policy, FunctorType(outputFields, leftFields, rightFields, sumInto) );
115  }
116 
117 
118  namespace FunctorArrayTools {
122  template < typename outputFieldsViewType , typename inputDataViewType , typename inputFieldsViewType >
124  outputFieldsViewType _outputFields;
125  inputDataViewType _inputData;
126  inputFieldsViewType _inputFields;
127  const bool _sumInto;
128  typedef typename outputFieldsViewType::value_type value_type;
129 
130  KOKKOS_INLINE_FUNCTION
131  F_contractDataField(outputFieldsViewType outputFields_,
132  inputDataViewType inputData_,
133  inputFieldsViewType inputFields_,
134  const bool sumInto_)
135  : _outputFields(outputFields_), _inputData(inputData_), _inputFields(inputFields_), _sumInto(sumInto_) {}
136 
137  KOKKOS_DEFAULTED_FUNCTION
138  ~F_contractDataField() = default;
139 
140  KOKKOS_INLINE_FUNCTION
141  void operator()(const size_type iter) const {
142  size_type cl, bf;
143  unrollIndex( cl, bf,
144  _inputFields.extent(0),
145  _inputFields.extent(1),
146  iter );
147 
148  auto result = Kokkos::subview( _outputFields, cl, bf );
149 
150  const auto field = Kokkos::subview( _inputFields, cl, bf, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL() );
151  const auto data = Kokkos::subview( _inputData, cl, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL() );
152 
153  const size_type npts = field.extent(0);
154  const ordinal_type iend = field.extent(1);
155  const ordinal_type jend = field.extent(2);
156 
157  result() *= (_sumInto ? 1 : 0);
158 
159  if(_inputData.extent(1) != 1)
160  for (size_type qp = 0; qp < npts; ++qp)
161  for (ordinal_type i = 0; i < iend; ++i)
162  for (ordinal_type j = 0; j < jend; ++j)
163  result() += field(qp, i, j) * data(qp, i, j);
164  else
165  for (size_type qp = 0; qp < npts; ++qp)
166  for (ordinal_type i = 0; i < iend; ++i)
167  for (ordinal_type j = 0; j < jend; ++j)
168  result() += field(qp, i, j) * data(0, i, j);
169  }
170  };
171  } //namespace
172 
173  template<typename DeviceType>
174  template<typename outputFieldValueType, class ...outputFieldProperties,
175  typename inputDataValueType, class ...inputDataProperties,
176  typename inputFieldValueType, class ...inputFieldProperties>
177  void
179  contractDataField( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
180  const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
181  const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields,
182  const bool sumInto ) {
183 
184  typedef Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFieldsViewType;
185  typedef Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputDataViewType;
186  typedef Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFieldsViewType;
188 
189  const size_type loopSize = inputFields.extent(0)*inputFields.extent(1);
190  Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
191  Kokkos::parallel_for( policy, FunctorType(outputFields, inputData, inputFields, sumInto) );
192  }
193 
194 
195  namespace FunctorArrayTools {
199  template < typename outputDataViewType , typename inputDataLeftViewType , typename inputDataRightViewType >
201  outputDataViewType _outputData;
202  inputDataLeftViewType _inputDataLeft;
203  inputDataRightViewType _inputDataRight;
204  const bool _sumInto;
205  typedef typename outputDataViewType::value_type value_type;
206 
207  KOKKOS_INLINE_FUNCTION
208  F_contractDataData(outputDataViewType outputData_,
209  inputDataLeftViewType inputDataLeft_,
210  inputDataRightViewType inputDataRight_,
211  const bool sumInto_)
212  : _outputData(outputData_), _inputDataLeft(inputDataLeft_), _inputDataRight(inputDataRight_), _sumInto(sumInto_) {}
213 
214  KOKKOS_DEFAULTED_FUNCTION
215  ~F_contractDataData() = default;
216 
217  KOKKOS_INLINE_FUNCTION
218  void operator()(const size_type iter) const {
219  const size_type cl = iter;
220 
221  auto result = Kokkos::subview( _outputData, cl );
222  const auto left = Kokkos::subview( _inputDataLeft, cl, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL() );
223  const auto right = Kokkos::subview( _inputDataRight, cl, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL() );
224 
225  size_type npts = left.extent(0);
226  ordinal_type iend = left.extent(1);
227  ordinal_type jend = left.extent(2);
228 
229  result() *= (_sumInto ? 1 : 0);
230  for (size_type qp = 0; qp < npts; ++qp)
231  for (ordinal_type i = 0; i < iend; ++i)
232  for (ordinal_type j = 0; j < jend; ++j)
233  result() += left(qp, i, j)*right(qp, i, j);
234  }
235  };
236  } //namespace
237 
238  template<typename DeviceType>
239  template<typename outputDataValueType, class ...outputDataProperties,
240  typename inputDataLeftValueType, class ...inputDataLeftProperties,
241  typename inputDataRightValueType, class ...inputDataRightProperties>
242  void
244  contractDataData( Kokkos::DynRankView<outputDataValueType, outputDataProperties...> outputData,
245  const Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft,
246  const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight,
247  const bool sumInto ) {
248  typedef Kokkos::DynRankView<outputDataValueType, outputDataProperties...> outputDataViewType;
249  typedef Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeftViewType;
250  typedef Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRightViewType;
252 
253  const size_type loopSize = inputDataLeft.extent(0);
254  Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
255  Kokkos::parallel_for( policy, FunctorType(outputData, inputDataLeft, inputDataRight, sumInto) );
256  }
257 
258 
259 
260  template<typename DeviceType>
261  template<typename outputFieldValueType, class ...outputFieldProperties,
262  typename leftFieldValueType, class ...leftFieldProperties,
263  typename rightFieldValueType, class ...rightFieldProperties>
264  void
266  contractFieldFieldScalar( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
267  const Kokkos::DynRankView<leftFieldValueType, leftFieldProperties...> leftFields,
268  const Kokkos::DynRankView<rightFieldValueType, rightFieldProperties...> rightFields,
269  const bool sumInto ) {
270 
271 #ifdef HAVE_INTREPID2_DEBUG
272  {
273  INTREPID2_TEST_FOR_EXCEPTION( leftFields.rank() != 3, std::invalid_argument,
274  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Rank of the left input argument must equal 3!");
275  INTREPID2_TEST_FOR_EXCEPTION( rightFields.rank() != 3, std::invalid_argument,
276  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Rank of right input argument must equal 3!");
277  INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 3, std::invalid_argument,
278  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Rank of output argument must equal 3!");
279  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(0) != rightFields.extent(0), std::invalid_argument,
280  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Zeroth dimensions (number of integration domains) of the left and right input containers must agree!");
281  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(2) != rightFields.extent(2), std::invalid_argument,
282  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Second dimensions (numbers of integration points) of the left and right input containers must agree!");
283  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != rightFields.extent(0), std::invalid_argument,
284  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Zeroth dimensions (numbers of integration domains) of the input and output containers must agree!");
285  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(1) != leftFields.extent(1), std::invalid_argument,
286  ">>> ERROR (ArrayTools::contractFieldFieldScalar): First dimension of output container and first dimension of left input container must agree!");
287  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(2) != rightFields.extent(1), std::invalid_argument,
288  ">>> ERROR (ArrayTools::contractFieldFieldScalar): Second dimension of output container and first dimension of right input container must agree!");
289 
290  }
291 #endif
292 
294  leftFields,
295  rightFields,
296  sumInto );
297  }
298 
299 
300  template<typename DeviceType>
301  template<typename outputFieldValueType, class ...outputFieldProperties,
302  typename leftFieldValueType, class ...leftFieldProperties,
303  typename rightFieldValueType, class ...rightFieldProperties>
304  void
306  contractFieldFieldVector( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
307  const Kokkos::DynRankView<leftFieldValueType, leftFieldProperties...> leftFields,
308  const Kokkos::DynRankView<rightFieldValueType, rightFieldProperties...> rightFields,
309  const bool sumInto ) {
310 
311 #ifdef HAVE_INTREPID2_DEBUG
312  {
313  INTREPID2_TEST_FOR_EXCEPTION( leftFields.rank() != 4, std::invalid_argument,
314  ">>> ERROR (ArrayTools::contractFieldFieldVector): Rank of the left input argument must equal 4!");
315  INTREPID2_TEST_FOR_EXCEPTION( rightFields.rank() != 4, std::invalid_argument,
316  ">>> ERROR (ArrayTools::contractFieldFieldVector): Rank of right input argument must equal 4!");
317  INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 3, std::invalid_argument,
318  ">>> ERROR (ArrayTools::contractFieldFieldVector): Rank of output argument must equal 3!");
319  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(0) != rightFields.extent(0), std::invalid_argument,
320  ">>> ERROR (ArrayTools::contractFieldFieldVector): Zeroth dimensions (number of integration domains) of the left and right input containers must agree!");
321  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(2) != rightFields.extent(2), std::invalid_argument,
322  ">>> ERROR (ArrayTools::contractFieldFieldVector): Second dimensions (numbers of integration points) of the left and right input containers must agree!");
323  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(3) != rightFields.extent(3), std::invalid_argument,
324  ">>> ERROR (ArrayTools::contractFieldFieldVector): Third dimensions (numbers of vector components) of the left and right input containers must agree!");
325  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != rightFields.extent(0), std::invalid_argument,
326  ">>> ERROR (ArrayTools::contractFieldFieldVector): Zeroth dimensions (numbers of integration domains) of the input and output containers must agree!");
327  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(1) != leftFields.extent(1), std::invalid_argument,
328  ">>> ERROR (ArrayTools::contractFieldFieldVector): First dimension of output container and first dimension of left input container must agree!");
329  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(2) != rightFields.extent(1), std::invalid_argument,
330  ">>> ERROR (ArrayTools::contractFieldFieldVector): Second dimension of output container and first dimension of right input container must agree!");
331  }
332 #endif
333 
335  leftFields,
336  rightFields,
337  sumInto );
338  }
339 
340 
341  template<typename DeviceType>
342  template<typename outputFieldValueType, class ...outputFieldProperties,
343  typename leftFieldValueType, class ...leftFieldProperties,
344  typename rightFieldValueType, class ...rightFieldProperties>
345  void
347  contractFieldFieldTensor( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
348  const Kokkos::DynRankView<leftFieldValueType, leftFieldProperties...> leftFields,
349  const Kokkos::DynRankView<rightFieldValueType, rightFieldProperties...> rightFields,
350  const bool sumInto ) {
351 
352 #ifdef HAVE_INTREPID2_DEBUG
353  {
354  INTREPID2_TEST_FOR_EXCEPTION( leftFields.rank() != 5, std::invalid_argument,
355  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Rank of the left input argument must equal 5!");
356  INTREPID2_TEST_FOR_EXCEPTION( rightFields.rank() != 5, std::invalid_argument,
357  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Rank of right input argument must equal 5!");
358  INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 3, std::invalid_argument,
359  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Rank of output argument must equal 3!");
360  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(0) != rightFields.extent(0), std::invalid_argument,
361  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Zeroth dimensions (number of integration domains) of the left and right input containers must agree!");
362  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(2) != rightFields.extent(2), std::invalid_argument,
363  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Second dimensions (numbers of integration points) of the left and right input containers must agree!");
364  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(3) != rightFields.extent(3), std::invalid_argument,
365  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Third dimensions (first tensor dimensions) of the left and right input containers must agree!");
366  INTREPID2_TEST_FOR_EXCEPTION( leftFields.extent(4) != rightFields.extent(4), std::invalid_argument,
367  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Fourth dimensions (second tensor dimensions) of the left and right input containers must agree!");
368  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != rightFields.extent(0), std::invalid_argument,
369  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Zeroth dimensions (numbers of integration domains) of the input and output containers must agree!");
370  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(1) != leftFields.extent(1), std::invalid_argument,
371  ">>> ERROR (ArrayTools::contractFieldFieldTensor): First dimension of output container and first dimension of left input container must agree!");
372  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(2) != rightFields.extent(1), std::invalid_argument,
373  ">>> ERROR (ArrayTools::contractFieldFieldTensor): Second dimension of output container and first dimension of right input container must agree!");
374  }
375 #endif
376 
378  leftFields,
379  rightFields,
380  sumInto );
381  }
382 
383 
384  template<typename DeviceType>
385  template<typename outputFieldValueType, class ...outputFieldProperties,
386  typename inputDataValueType, class ...inputDataProperties,
387  typename inputFieldValueType, class ...inputFieldProperties>
388  void
390  contractDataFieldScalar( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
391  const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
392  const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields,
393  const bool sumInto ) {
394 
395 #ifdef HAVE_INTREPID2_DEBUG
396  {
397  INTREPID2_TEST_FOR_EXCEPTION( inputFields.rank() != 3, std::invalid_argument,
398  ">>> ERROR (ArrayTools::contractDataFieldScalar): Rank of the fields input argument must equal 3!");
399  INTREPID2_TEST_FOR_EXCEPTION( inputData.rank() != 2, std::invalid_argument,
400  ">>> ERROR (ArrayTools::contractDataFieldScalar): Rank of the data input argument must equal 2!");
401  INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 2, std::invalid_argument,
402  ">>> ERROR (ArrayTools::contractDataFieldScalar): Rank of output argument must equal 2!");
403  INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(0) != inputData.extent(0), std::invalid_argument,
404  ">>> ERROR (ArrayTools::contractDataFieldScalar): Zeroth dimensions (number of integration domains) of the fields and data input containers must agree!");
405 
406  INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(1) != inputFields.extent(2) &&
407  inputData.extent(1) != 1, std::invalid_argument,
408  ">>> 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!");
409  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != inputFields.extent(0), std::invalid_argument,
410  ">>> ERROR (ArrayTools::contractDataFieldScalar): Zeroth dimensions (numbers of integration domains) of the fields input and output containers must agree!");
411  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(1) != inputFields.extent(1), std::invalid_argument,
412  ">>> ERROR (ArrayTools::contractDataFieldScalar): First dimensions (number of fields) of the fields input and output containers must agree!");
413  }
414 #endif
415 
417  inputData,
418  inputFields,
419  sumInto );
420  }
421 
422 
423  template<typename DeviceType>
424  template<typename outputFieldValueType, class ...outputFieldProperties,
425  typename inputDataValueType, class ...inputDataProperties,
426  typename inputFieldValueType, class ...inputFieldProperties>
427  void
429  contractDataFieldVector( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
430  const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
431  const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields,
432  const bool sumInto ) {
433 
434 #ifdef HAVE_INTREPID2_DEBUG
435  {
436  INTREPID2_TEST_FOR_EXCEPTION( inputFields.rank() != 4, std::invalid_argument,
437  ">>> ERROR (ArrayTools::contractDataFieldVector): Rank of the fields input argument must equal 4!");
438  INTREPID2_TEST_FOR_EXCEPTION( inputData.rank() != 3, std::invalid_argument,
439  ">>> ERROR (ArrayTools::contractDataFieldVector): Rank of the data input argument must equal 3!");
440  INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 2, std::invalid_argument,
441  ">>> ERROR (ArrayTools::contractDataFieldVector): Rank of output argument must equal 2!");
442  INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(0) != inputData.extent(0), std::invalid_argument,
443  ">>> ERROR (ArrayTools::contractDataFieldVector): Zeroth dimensions (number of integration domains) of the fields and data input containers must agree!");
444  INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(1) != inputFields.extent(2) &&
445  inputData.extent(1) != 1, std::invalid_argument,
446  ">>> 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!");
447  INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(3) != inputData.extent(2), std::invalid_argument,
448  ">>> ERROR (ArrayTools::contractDataFieldVector): Third dimension of the fields input container and second dimension of data input container (vector index) must agree!");
449  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != inputFields.extent(0), std::invalid_argument,
450  ">>> ERROR (ArrayTools::contractDataFieldVector): Zeroth dimensions (numbers of integration domains) of the fields input and output containers must agree!");
451  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(1) != inputFields.extent(1), std::invalid_argument,
452  ">>> ERROR (ArrayTools::contractDataFieldVector): First dimensions of output container and fields input container (number of fields) must agree!");
453  }
454 #endif
455 
457  inputData,
458  inputFields,
459  sumInto );
460  }
461 
462 
463 
464  template<typename DeviceType>
465  template<typename outputFieldValueType, class ...outputFieldProperties,
466  typename inputDataValueType, class ...inputDataProperties,
467  typename inputFieldValueType, class ...inputFieldProperties>
468  void
470  contractDataFieldTensor( Kokkos::DynRankView<outputFieldValueType,outputFieldProperties...> outputFields,
471  const Kokkos::DynRankView<inputDataValueType, inputDataProperties...> inputData,
472  const Kokkos::DynRankView<inputFieldValueType, inputFieldProperties...> inputFields,
473  const bool sumInto ) {
474 
475 #ifdef HAVE_INTREPID2_DEBUG
476  {
477  INTREPID2_TEST_FOR_EXCEPTION( inputFields.rank() != 5, std::invalid_argument,
478  ">>> ERROR (ArrayTools::contractDataFieldTensor): Rank of the fields input argument must equal 5!");
479  INTREPID2_TEST_FOR_EXCEPTION( inputData.rank() != 4, std::invalid_argument,
480  ">>> ERROR (ArrayTools::contractDataFieldTensor): Rank of the data input argument must equal 4!");
481  INTREPID2_TEST_FOR_EXCEPTION( outputFields.rank() != 2, std::invalid_argument,
482  ">>> ERROR (ArrayTools::contractDataFieldTensor): Rank of output argument must equal 2!");
483  INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(0) != inputData.extent(0), std::invalid_argument,
484  ">>> ERROR (ArrayTools::contractDataFieldTensor): Zeroth dimensions (number of integration domains) of the fields and data input containers must agree!");
485  INTREPID2_TEST_FOR_EXCEPTION( inputData.extent(1) != inputFields.extent(2) && inputData.extent(1) != 1, std::invalid_argument,
486  ">>> 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!");
487  INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(3) != inputData.extent(2), std::invalid_argument,
488  ">>> ERROR (ArrayTools::contractDataFieldTensor): Third dimension of the fields input container and second dimension of data input container (first tensor dimension) must agree!");
489  INTREPID2_TEST_FOR_EXCEPTION( inputFields.extent(4) != inputData.extent(3), std::invalid_argument,
490  ">>> ERROR (ArrayTools::contractDataFieldTensor): Fourth dimension of the fields input container and third dimension of data input container (second tensor dimension) must agree!");
491  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(0) != inputFields.extent(0), std::invalid_argument,
492  ">>> ERROR (ArrayTools::contractDataFieldTensor): Zeroth dimensions (numbers of integration domains) of the fields input and output containers must agree!");
493  INTREPID2_TEST_FOR_EXCEPTION( outputFields.extent(1) != inputFields.extent(1), std::invalid_argument,
494  ">>> ERROR (ArrayTools::contractDataFieldTensor): First dimensions (number of fields) of output container and fields input container must agree!");
495  }
496 #endif
497 
499  inputData,
500  inputFields,
501  sumInto );
502  }
503 
504 
505 
506  template<typename DeviceType>
507  template<typename outputDataValueType, class ...outputDataProperties,
508  typename inputDataLeftValueType, class ...inputDataLeftProperties,
509  typename inputDataRightValueType, class ...inputDataRightProperties>
510  void
512  contractDataDataScalar( Kokkos::DynRankView<outputDataValueType, outputDataProperties...> outputData,
513  const Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft,
514  const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight,
515  const bool sumInto ) {
516 
517 #ifdef HAVE_INTREPID2_DEBUG
518  {
519  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.rank() != 2, std::invalid_argument,
520  ">>> ERROR (ArrayTools::contractDataDataScalar): Rank of the left input argument must equal 2!");
521  INTREPID2_TEST_FOR_EXCEPTION( inputDataRight.rank() != 2, std::invalid_argument,
522  ">>> ERROR (ArrayTools::contractDataDataScalar): Rank of right input argument must equal 2!");
523  INTREPID2_TEST_FOR_EXCEPTION( outputData.rank() != 1, std::invalid_argument,
524  ">>> ERROR (ArrayTools::contractDataDataScalar): Rank of output argument must equal 1!");
525  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(0) != inputDataRight.extent(0), std::invalid_argument,
526  ">>> ERROR (ArrayTools::contractDataDataScalar): Zeroth dimensions (number of integration domains) of the left and right input containers must agree!");
527  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(1) != inputDataRight.extent(1), std::invalid_argument,
528  ">>> ERROR (ArrayTools::contractDataDataScalar): First dimensions (numbers of integration points) of the left and right input containers must agree!");
529  INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(0) != inputDataRight.extent(0), std::invalid_argument,
530  ">>> ERROR (ArrayTools::contractDataDataScalar): Zeroth dimensions (numbers of integration domains) of the input and output containers must agree!");
531  }
532 #endif
533 
535  inputDataLeft,
536  inputDataRight,
537  sumInto );
538  }
539 
540 
541  template<typename DeviceType>
542  template<typename outputDataValueType, class ...outputDataProperties,
543  typename inputDataLeftValueType, class ...inputDataLeftProperties,
544  typename inputDataRightValueType, class ...inputDataRightProperties>
545  void
547  contractDataDataVector( Kokkos::DynRankView<outputDataValueType, outputDataProperties...> outputData,
548  const Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft,
549  const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight,
550  const bool sumInto ) {
551 
552 #ifdef HAVE_INTREPID2_DEBUG
553  {
554  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.rank() != 3, std::invalid_argument,
555  ">>> ERROR (ArrayTools::contractDataDataVector): Rank of the left input argument must equal 3!");
556  INTREPID2_TEST_FOR_EXCEPTION( inputDataRight.rank() != 3, std::invalid_argument,
557  ">>> ERROR (ArrayTools::contractDataDataVector): Rank of right input argument must equal 3!");
558  INTREPID2_TEST_FOR_EXCEPTION( outputData.rank() != 1, std::invalid_argument,
559  ">>> ERROR (ArrayTools::contractDataDataVector): Rank of output argument must equal 1!");
560  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(0) != inputDataRight.extent(0), std::invalid_argument,
561  ">>> ERROR (ArrayTools::contractDataDataVector): Zeroth dimensions (number of integration domains) of the left and right input containers must agree!");
562  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(1) != inputDataRight.extent(1), std::invalid_argument,
563  ">>> ERROR (ArrayTools::contractDataDataVector): First dimensions (numbers of integration points) of the left and right input containers must agree!");
564  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(2) != inputDataRight.extent(2), std::invalid_argument,
565  ">>> ERROR (ArrayTools::contractDataDataVector): Second dimensions (numbers of vector components) of the left and right input containers must agree!");
566  INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(0) != inputDataRight.extent(0), std::invalid_argument,
567  ">>> ERROR (ArrayTools::contractDataDataVector): Zeroth dimensions (numbers of integration domains) of the input and output containers must agree!");
568  }
569 #endif
570 
572  inputDataLeft,
573  inputDataRight,
574  sumInto );
575  }
576 
577 
578  template<typename DeviceType>
579  template<typename outputDataValueType, class ...outputDataProperties,
580  typename inputDataLeftValueType, class ...inputDataLeftProperties,
581  typename inputDataRightValueType, class ...inputDataRightProperties>
582  void
584  contractDataDataTensor( Kokkos::DynRankView<outputDataValueType, outputDataProperties...> outputData,
585  const Kokkos::DynRankView<inputDataLeftValueType, inputDataLeftProperties...> inputDataLeft,
586  const Kokkos::DynRankView<inputDataRightValueType,inputDataRightProperties...> inputDataRight,
587  const bool sumInto ) {
588 
589 #ifdef HAVE_INTREPID2_DEBUG
590  {
591  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.rank() != 4, std::invalid_argument,
592  ">>> ERROR (ArrayTools::contractDataDataTensor): Rank of the left input argument must equal 4");
593  INTREPID2_TEST_FOR_EXCEPTION( inputDataRight.rank() != 4, std::invalid_argument,
594  ">>> ERROR (ArrayTools::contractDataDataTensor): Rank of right input argument must equal 4!");
595  INTREPID2_TEST_FOR_EXCEPTION( outputData.rank() != 1, std::invalid_argument,
596  ">>> ERROR (ArrayTools::contractDataDataTensor): Rank of output argument must equal 1!");
597  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(0) != inputDataRight.extent(0), std::invalid_argument,
598  ">>> ERROR (ArrayTools::contractDataDataTensor): Zeroth dimensions (number of integration domains) of the left and right input containers must agree!");
599  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(1) != inputDataRight.extent(1), std::invalid_argument,
600  ">>> ERROR (ArrayTools::contractDataDataTensor): First dimensions (numbers of integration points) of the left and right input containers must agree!");
601  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(2) != inputDataRight.extent(2), std::invalid_argument,
602  ">>> ERROR (ArrayTools::contractDataDataTensor): Second dimensions (first tensor dimensions) of the left and right input containers must agree!");
603  INTREPID2_TEST_FOR_EXCEPTION( inputDataLeft.extent(3) != inputDataRight.extent(3), std::invalid_argument,
604  ">>> ERROR (ArrayTools::contractDataDataTensor): Third dimensions (second tensor dimensions) of the left and right input containers must agree!");
605  INTREPID2_TEST_FOR_EXCEPTION( outputData.extent(0) != inputDataRight.extent(0), std::invalid_argument,
606  ">>> ERROR (ArrayTools::contractDataDataTensor): Zeroth dimensions (numbers of integration domains) of the input and output containers must agree!");
607  }
608 #endif
609 
611  inputDataLeft,
612  inputDataRight,
613  sumInto );
614  }
615 
616 }
617 #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...