Intrepid
Intrepid_ArrayToolsDefDot.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 Pavel Bochev (pbboche@sandia.gov)
38 // Denis Ridzal (dridzal@sandia.gov), or
39 // Kara Peterson (kjpeter@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
49 namespace Intrepid {
50 
51 template<class Scalar, class ArrayOutFields, class ArrayInData, class ArrayInFields>
52 void ArrayTools::dotMultiplyDataField(ArrayOutFields & outputFields,
53  const ArrayInData & inputData,
54  const ArrayInFields & inputFields) {
55 
56 #ifdef HAVE_INTREPID_DEBUG
57  if (inputFields.rank() > inputData.rank()) {
58  TEUCHOS_TEST_FOR_EXCEPTION( ((inputData.rank() < 2) || (inputData.rank() > 4)), std::invalid_argument,
59  ">>> ERROR (ArrayTools::dotMultiplyDataField): Input data container must have rank 2, 3 or 4.");
60  TEUCHOS_TEST_FOR_EXCEPTION( (inputFields.rank() != inputData.rank()+1), std::invalid_argument,
61  ">>> ERROR (ArrayTools::dotMultiplyDataField): Input fields container must have rank one larger than the rank of the input data container.");
62  TEUCHOS_TEST_FOR_EXCEPTION( (outputFields.rank() != 3), std::invalid_argument,
63  ">>> ERROR (ArrayTools::dotMultiplyDataField): Output fields container must have rank 3.");
64  TEUCHOS_TEST_FOR_EXCEPTION( (inputFields.dimension(0) != inputData.dimension(0) ), std::invalid_argument,
65  ">>> ERROR (ArrayTools::dotMultiplyDataField): Zeroth dimensions (number of integration domains) of the fields and data input containers must agree!");
66  TEUCHOS_TEST_FOR_EXCEPTION( ( (inputFields.dimension(2) != inputData.dimension(1)) && (inputData.dimension(1) != 1) ), std::invalid_argument,
67  ">>> ERROR (ArrayTools::dotMultiplyDataField): 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!");
68  for (int i=2; i<inputData.rank(); i++) {
69  std::string errmsg = ">>> ERROR (ArrayTools::dotMultiplyDataField): Dimensions ";
70  errmsg += (char)(48+i);
71  errmsg += " and ";
72  errmsg += (char)(48+i+1);
73  errmsg += " of the input data and fields containers must agree!";
74  TEUCHOS_TEST_FOR_EXCEPTION( (inputData.dimension(i) != inputFields.dimension(i+1)), std::invalid_argument, errmsg );
75  }
76  for (int i=0; i<outputFields.rank(); i++) {
77  std::string errmsg = ">>> ERROR (ArrayTools::dotMultiplyDataField): Dimensions ";
78  errmsg += (char)(48+i);
79  errmsg += " of the input and output fields containers must agree!";
80  TEUCHOS_TEST_FOR_EXCEPTION( (inputFields.dimension(i) != outputFields.dimension(i)), std::invalid_argument, errmsg );
81  }
82  }
83  else {
84  TEUCHOS_TEST_FOR_EXCEPTION( ((inputData.rank() < 2) || (inputData.rank() > 4)), std::invalid_argument,
85  ">>> ERROR (ArrayTools::dotMultiplyDataField): Input data container must have rank 2, 3 or 4.");
86  TEUCHOS_TEST_FOR_EXCEPTION( (inputFields.rank() != inputData.rank()), std::invalid_argument,
87  ">>> ERROR (ArrayTools::dotMultiplyDataField): The rank of fields input container must equal the rank of data input container.");
88  TEUCHOS_TEST_FOR_EXCEPTION( (outputFields.rank() != 3), std::invalid_argument,
89  ">>> ERROR (ArrayTools::dotMultiplyDataField): Output fields container must have rank 3.");
90  TEUCHOS_TEST_FOR_EXCEPTION( ( (inputFields.dimension(1) != inputData.dimension(1)) && (inputData.dimension(1) != 1) ), std::invalid_argument,
91  ">>> ERROR (ArrayTools::dotMultiplyDataField): First dimensions of the fields and data input containers (number of integration points) must agree or first data dimension must be 1!");
92  TEUCHOS_TEST_FOR_EXCEPTION( (inputFields.dimension(0) != outputFields.dimension(1)), std::invalid_argument,
93  ">>> ERROR (ArrayTools::dotMultiplyDataField): Zeroth dimension of the fields input container and first dimension of the fields output container (number of fields) must agree!");
94  TEUCHOS_TEST_FOR_EXCEPTION( (inputFields.dimension(1) != outputFields.dimension(2)), std::invalid_argument,
95  ">>> ERROR (ArrayTools::dotMultiplyDataField): First dimension of the fields input container and second dimension of the fields output container (number of integration points) must agree!");
96  TEUCHOS_TEST_FOR_EXCEPTION( (outputFields.dimension(0) != inputData.dimension(0)), std::invalid_argument,
97  ">>> ERROR (ArrayTools::dotMultiplyDataField): Zeroth dimensions of the fields output and data input containers (number of integration domains) must agree!");
98  for (int i=2; i<inputData.rank(); i++) {
99  std::string errmsg = ">>> ERROR (ArrayTools::dotMultiplyDataField): Dimensions ";
100  errmsg += (char)(48+i);
101  errmsg += " of the input data and fields containers must agree!";
102  TEUCHOS_TEST_FOR_EXCEPTION( (inputData.dimension(i) != inputFields.dimension(i)), std::invalid_argument, errmsg );
103  }
104  }
105 #endif
106 
107  // get sizes
108  int invalRank = inputFields.rank();
109  int dataRank = inputData.rank();
110  int numCells = outputFields.dimension(0);
111  int numFields = outputFields.dimension(1);
112  int numPoints = outputFields.dimension(2);
113  int numDataPoints = inputData.dimension(1);
114  int dim1Tens = 0;
115  int dim2Tens = 0;
116  if (dataRank > 2) {
117  dim1Tens = inputData.dimension(2);
118  if (dataRank > 3) {
119  dim2Tens = inputData.dimension(3);
120  }
121  }
122 
123  Scalar temp(0);
124 
125  if (invalRank == dataRank + 1) {
126 
127  if (numDataPoints != 1) { // nonconstant data
128 
129  switch(invalRank) {
130  case 3: {
131  for(int cl = 0; cl < numCells; cl++) {
132  for(int bf = 0; bf < numFields; bf++) {
133  for(int pt = 0; pt < numPoints; pt++) {
134  outputFields(cl, bf, pt) = inputData(cl, pt)*inputFields(cl, bf, pt);
135  } // P-loop
136  } // F-loop
137  } // C-loop
138  }// case 3
139  break;
140 
141  case 4: {
142  for(int cl = 0; cl < numCells; cl++) {
143  for(int bf = 0; bf < numFields; bf++) {
144  for(int pt = 0; pt < numPoints; pt++) {
145  temp = 0;
146  for( int iVec = 0; iVec < dim1Tens; iVec++) {
147  temp += inputData(cl, pt, iVec)*inputFields(cl, bf, pt, iVec);
148  } // D1-loop
149  outputFields(cl, bf, pt) = temp;
150  } // P-loop
151  } // F-loop
152  } // C-loop
153  }// case 4
154  break;
155 
156  case 5: {
157  for(int cl = 0; cl < numCells; cl++) {
158  for(int bf = 0; bf < numFields; bf++) {
159  for(int pt = 0; pt < numPoints; pt++) {
160  temp = 0;
161  for(int iTens2 = 0; iTens2 < dim2Tens; iTens2++) {
162  for( int iTens1 = 0; iTens1 < dim1Tens; iTens1++) {
163  temp += inputData(cl, pt, iTens1, iTens2)*inputFields(cl, bf, pt, iTens1, iTens2);
164  } // D1-loop
165  } // D2-loop
166  outputFields(cl, bf, pt) = temp;
167  } // P-loop
168  } // F-loop
169  } // C-loop
170  }// case 5
171  break;
172 
173  default:
174  TEUCHOS_TEST_FOR_EXCEPTION( !( (invalRank == 3) || (invalRank == 4) || (invalRank == 5) ), std::invalid_argument,
175  ">>> ERROR (ArrayTools::dotMultiplyDataField): This branch of the method is defined only for rank-3, 4 or 5 input fields containers.");
176  }// invalRank
177 
178  }
179  else { //constant data
180 
181  switch(invalRank) {
182  case 3: {
183  for(int cl = 0; cl < numCells; cl++) {
184  for(int bf = 0; bf < numFields; bf++) {
185  for(int pt = 0; pt < numPoints; pt++) {
186  outputFields(cl, bf, pt) = inputData(cl, 0)*inputFields(cl, bf, pt);
187  } // P-loop
188  } // F-loop
189  } // C-loop
190  }// case 3
191  break;
192 
193  case 4: {
194  for(int cl = 0; cl < numCells; cl++) {
195  for(int bf = 0; bf < numFields; bf++) {
196  for(int pt = 0; pt < numPoints; pt++) {
197  temp = 0;
198  for( int iVec = 0; iVec < dim1Tens; iVec++) {
199  temp += inputData(cl, 0, iVec)*inputFields(cl, bf, pt, iVec);
200  } // D1-loop
201  outputFields(cl, bf, pt) = temp;
202  } // P-loop
203  } // F-loop
204  } // C-loop
205  }// case 4
206  break;
207 
208  case 5: {
209  for(int cl = 0; cl < numCells; cl++) {
210  for(int bf = 0; bf < numFields; bf++) {
211  for(int pt = 0; pt < numPoints; pt++) {
212  temp = 0;
213  for(int iTens2 = 0; iTens2 < dim2Tens; iTens2++) {
214  for( int iTens1 = 0; iTens1 < dim1Tens; iTens1++) {
215  temp += inputData(cl, 0, iTens1, iTens2)*inputFields(cl, bf, pt, iTens1, iTens2);
216  } // D1-loop
217  } // D2-loop
218  outputFields(cl, bf, pt) = temp;
219  } // P-loop
220  } // F-loop
221  } // C-loop
222  }// case 5
223  break;
224 
225  default:
226  TEUCHOS_TEST_FOR_EXCEPTION( !( (invalRank == 3) || (invalRank == 4) || (invalRank == 5) ), std::invalid_argument,
227  ">>> ERROR (ArrayTools::dotMultiplyDataField): This branch of the method is defined only for rank-3, 4 or 5 input fields containers.");
228  }// invalRank
229 
230  } // numDataPoints
231 
232  }
233  else {
234 
235  if (numDataPoints != 1) { // nonconstant data
236 
237  switch(invalRank) {
238  case 2: {
239  for(int cl = 0; cl < numCells; cl++) {
240  for(int bf = 0; bf < numFields; bf++) {
241  for(int pt = 0; pt < numPoints; pt++) {
242  outputFields(cl, bf, pt) = inputData(cl, pt)*inputFields(bf, pt);
243  } // P-loop
244  } // F-loop
245  } // C-loop
246  }// case 2
247  break;
248 
249  case 3: {
250  for(int cl = 0; cl < numCells; cl++) {
251  for(int bf = 0; bf < numFields; bf++) {
252  for(int pt = 0; pt < numPoints; pt++) {
253  temp = 0;
254  for( int iVec = 0; iVec < dim1Tens; iVec++) {
255  temp += inputData(cl, pt, iVec)*inputFields(bf, pt, iVec);
256  } // D1-loop
257  outputFields(cl, bf, pt) = temp;
258  } // P-loop
259  } // F-loop
260  } // C-loop
261  }// case 3
262  break;
263 
264  case 4: {
265  for(int cl = 0; cl < numCells; cl++) {
266  for(int bf = 0; bf < numFields; bf++) {
267  for(int pt = 0; pt < numPoints; pt++) {
268  temp = 0;
269  for(int iTens2 = 0; iTens2 < dim2Tens; iTens2++) {
270  for( int iTens1 = 0; iTens1 < dim1Tens; iTens1++) {
271  temp += inputData(cl, pt, iTens1, iTens2)*inputFields(bf, pt, iTens1, iTens2);
272  } // D1-loop
273  } // D2-loop
274  outputFields(cl, bf, pt) = temp;
275  } // P-loop
276  } // F-loop
277  } // C-loop
278  }// case 4
279  break;
280 
281  default:
282  TEUCHOS_TEST_FOR_EXCEPTION( !( (invalRank == 2) || (invalRank == 3) || (invalRank == 4) ), std::invalid_argument,
283  ">>> ERROR (ArrayTools::dotMultiplyDataField): This branch of the method is defined only for rank-2, 3 or 4 input fields containers.");
284  }// invalRank
285 
286  }
287  else { //constant data
288 
289  switch(invalRank) {
290  case 2: {
291  for(int cl = 0; cl < numCells; cl++) {
292  for(int bf = 0; bf < numFields; bf++) {
293  for(int pt = 0; pt < numPoints; pt++) {
294  outputFields(cl, bf, pt) = inputData(cl, 0)*inputFields(bf, pt);
295  } // P-loop
296  } // F-loop
297  } // C-loop
298  }// case 2
299  break;
300 
301  case 3: {
302  for(int cl = 0; cl < numCells; cl++) {
303  for(int bf = 0; bf < numFields; bf++) {
304  for(int pt = 0; pt < numPoints; pt++) {
305  temp = 0;
306  for( int iVec = 0; iVec < dim1Tens; iVec++) {
307  temp += inputData(cl, 0, iVec)*inputFields(bf, pt, iVec);
308  } // D1-loop
309  outputFields(cl, bf, pt) = temp;
310  } // P-loop
311  } // F-loop
312  } // C-loop
313  }// case 3
314  break;
315 
316  case 4: {
317  for(int cl = 0; cl < numCells; cl++) {
318  for(int bf = 0; bf < numFields; bf++) {
319  for(int pt = 0; pt < numPoints; pt++) {
320  temp = 0;
321  for(int iTens2 = 0; iTens2 < dim2Tens; iTens2++) {
322  for( int iTens1 = 0; iTens1 < dim1Tens; iTens1++) {
323  temp += inputData(cl, 0, iTens1, iTens2)*inputFields(bf, pt, iTens1, iTens2);
324  } // D1-loop
325  } // D2-loop
326  outputFields(cl, bf, pt) = temp;
327  } // P-loop
328  } // F-loop
329  } // C-loop
330  }// case 4
331  break;
332 
333  default:
334  TEUCHOS_TEST_FOR_EXCEPTION( !( (invalRank == 2) || (invalRank == 3) || (invalRank == 4) ), std::invalid_argument,
335  ">>> ERROR (ArrayTools::dotMultiplyDataField): This branch of the method is defined only for rank-2, 3 or 4 input fields containers.");
336  }// invalRank
337 
338  } // numDataPoints
339 
340  } // end if (invalRank == dataRank + 1)
341 
342 }// dotMultiplyDataField
343 
344 
345 
346 template<class Scalar, class ArrayOutData, class ArrayInDataLeft, class ArrayInDataRight>
347 void ArrayTools::dotMultiplyDataData(ArrayOutData & outputData,
348  const ArrayInDataLeft & inputDataLeft,
349  const ArrayInDataRight & inputDataRight) {
350 
351 #ifdef HAVE_INTREPID_DEBUG
352  if (inputDataRight.rank() >= inputDataLeft.rank()) {
353  TEUCHOS_TEST_FOR_EXCEPTION( ((inputDataLeft.rank() < 2) || (inputDataLeft.rank() > 4)), std::invalid_argument,
354  ">>> ERROR (ArrayTools::dotMultiplyDataData): Left data input container must have rank 2, 3 or 4.");
355  TEUCHOS_TEST_FOR_EXCEPTION( (inputDataRight.rank() != inputDataLeft.rank()), std::invalid_argument,
356  ">>> ERROR (ArrayTools::dotMultiplyDataData): The rank of the right data input container must equal the rank of the left data input container.");
357  TEUCHOS_TEST_FOR_EXCEPTION( (outputData.rank() != 2), std::invalid_argument,
358  ">>> ERROR (ArrayTools::dotMultiplyDataData): Data output container must have rank 2.");
359  TEUCHOS_TEST_FOR_EXCEPTION( ( (inputDataRight.dimension(1) != inputDataLeft.dimension(1)) && (inputDataLeft.dimension(1) != 1) ), std::invalid_argument,
360  ">>> ERROR (ArrayTools::dotMultiplyDataField): First dimensions of the left and right data input containers (number of integration points) must agree or first left data dimension must be 1!");
361  for (int i=0; i<inputDataLeft.rank(); i++) {
362  if (i != 1) {
363  std::string errmsg = ">>> ERROR (ArrayTools::dotMultiplyDataData): Dimensions ";
364  errmsg += (char)(48+i);
365  errmsg += " of the left and right data input containers must agree!";
366  TEUCHOS_TEST_FOR_EXCEPTION( (inputDataLeft.dimension(i) != inputDataRight.dimension(i)), std::invalid_argument, errmsg );
367  }
368  }
369  for (int i=0; i<outputData.rank(); i++) {
370  std::string errmsg = ">>> ERROR (ArrayTools::dotMultiplyDataData): Dimensions ";
371  errmsg += (char)(48+i);
372  errmsg += " of the output and right input data containers must agree!";
373  TEUCHOS_TEST_FOR_EXCEPTION( (inputDataRight.dimension(i) != outputData.dimension(i)), std::invalid_argument, errmsg );
374  }
375  }
376  else {
377  TEUCHOS_TEST_FOR_EXCEPTION( ((inputDataLeft.rank() < 2) || (inputDataLeft.rank() > 4)), std::invalid_argument,
378  ">>> ERROR (ArrayTools::dotMultiplyDataData): Left data input container must have rank 2, 3 or 4.");
379  TEUCHOS_TEST_FOR_EXCEPTION( (inputDataRight.rank() != inputDataLeft.rank()-1), std::invalid_argument,
380  ">>> ERROR (ArrayTools::dotMultiplyDataData): Right data input container must have rank one less than the rank of left data input container.");
381  TEUCHOS_TEST_FOR_EXCEPTION( (outputData.rank() != 2), std::invalid_argument,
382  ">>> ERROR (ArrayTools::dotMultiplyDataData): Data output container must have rank 2.");
383  TEUCHOS_TEST_FOR_EXCEPTION( ( (inputDataRight.dimension(0) != inputDataLeft.dimension(1)) && (inputDataLeft.dimension(1) != 1) ), std::invalid_argument,
384  ">>> ERROR (ArrayTools::dotMultiplyDataField): Zeroth dimension of the right data input container and first dimension of left data input container (number of integration points) must agree or first left data dimension must be 1!");
385  TEUCHOS_TEST_FOR_EXCEPTION( (inputDataRight.dimension(0) != outputData.dimension(1)), std::invalid_argument,
386  ">>> ERROR (ArrayTools::dotMultiplyDataField): Zeroth dimension of the right data input container and first dimension of output data container (number of integration points) must agree!");
387  TEUCHOS_TEST_FOR_EXCEPTION( (inputDataLeft.dimension(0) != outputData.dimension(0)), std::invalid_argument,
388  ">>> ERROR (ArrayTools::dotMultiplyDataField): Zeroth dimensions of the left data input and data output containers (number of integration domains) must agree!");
389  for (int i=1; i<inputDataRight.rank(); i++) {
390  std::string errmsg = ">>> ERROR (ArrayTools::dotMultiplyDataData): Dimensions ";
391  errmsg += (char)(48+i+1);
392  errmsg += " and ";
393  errmsg += (char)(48+i);
394  errmsg += " of the left and right data input containers must agree!";
395  TEUCHOS_TEST_FOR_EXCEPTION( (inputDataLeft.dimension(i+1) != inputDataRight.dimension(i)), std::invalid_argument, errmsg );
396  }
397  }
398 #endif
399 
400  // get sizes
401  int rightDataRank = inputDataRight.rank();
402  int leftDataRank = inputDataLeft.rank();
403  int numCells = outputData.dimension(0);
404  int numPoints = outputData.dimension(1);
405  int numDataPoints = inputDataLeft.dimension(1);
406  int dim1Tens = 0;
407  int dim2Tens = 0;
408  if (leftDataRank > 2) {
409  dim1Tens = inputDataLeft.dimension(2);
410  if (leftDataRank > 3) {
411  dim2Tens = inputDataLeft.dimension(3);
412  }
413  }
414 
415  Scalar temp(0);
416 
417  if (rightDataRank == leftDataRank) {
418 
419  if (numDataPoints != 1) { // nonconstant data
420 
421  switch(rightDataRank) {
422  case 2: {
423  for(int cl = 0; cl < numCells; cl++) {
424  for(int pt = 0; pt < numPoints; pt++) {
425  outputData(cl, pt) = inputDataLeft(cl, pt)*inputDataRight(cl, pt);
426  } // P-loop
427  } // C-loop
428  }// case 2
429  break;
430 
431  case 3: {
432  for(int cl = 0; cl < numCells; cl++) {
433  for(int pt = 0; pt < numPoints; pt++) {
434  temp = 0;
435  for( int iVec = 0; iVec < dim1Tens; iVec++) {
436  temp += inputDataLeft(cl, pt, iVec)*inputDataRight(cl, pt, iVec);
437  } // D1-loop
438  outputData(cl, pt) = temp;
439  } // P-loop
440  } // C-loop
441  }// case 3
442  break;
443 
444  case 4: {
445  for(int cl = 0; cl < numCells; cl++) {
446  for(int pt = 0; pt < numPoints; pt++) {
447  temp = 0;
448  for(int iTens2 = 0; iTens2 < dim2Tens; iTens2++) {
449  for( int iTens1 = 0; iTens1 < dim1Tens; iTens1++) {
450  temp += inputDataLeft(cl, pt, iTens1, iTens2)*inputDataRight(cl, pt, iTens1, iTens2);
451  } // D1-loop
452  } // D2-loop
453  outputData(cl, pt) = temp;
454  } // P-loop
455  } // C-loop
456  }// case 4
457  break;
458 
459  default:
460  TEUCHOS_TEST_FOR_EXCEPTION( !( (rightDataRank == 2) || (rightDataRank == 3) || (rightDataRank == 4) ), std::invalid_argument,
461  ">>> ERROR (ArrayTools::dotMultiplyDataData): This branch of the method is defined only for rank-2, 3 or 4 right data input containers.");
462  }// rightDataRank
463 
464  }
465  else { //constant data
466 
467  switch(rightDataRank) {
468  case 2: {
469  for(int cl = 0; cl < numCells; cl++) {
470  for(int pt = 0; pt < numPoints; pt++) {
471  outputData(cl, pt) = inputDataLeft(cl, 0)*inputDataRight(cl, pt);
472  } // P-loop
473  } // C-loop
474  }// case 2
475  break;
476 
477  case 3: {
478  for(int cl = 0; cl < numCells; cl++) {
479  for(int pt = 0; pt < numPoints; pt++) {
480  temp = 0;
481  for( int iVec = 0; iVec < dim1Tens; iVec++) {
482  temp += inputDataLeft(cl, 0, iVec)*inputDataRight(cl, pt, iVec);
483  } // D1-loop
484  outputData(cl, pt) = temp;
485  } // P-loop
486  } // C-loop
487  }// case 3
488  break;
489 
490  case 4: {
491  for(int cl = 0; cl < numCells; cl++) {
492  for(int pt = 0; pt < numPoints; pt++) {
493  temp = 0;
494  for(int iTens2 = 0; iTens2 < dim2Tens; iTens2++) {
495  for( int iTens1 = 0; iTens1 < dim1Tens; iTens1++) {
496  temp += inputDataLeft(cl, 0, iTens1, iTens2)*inputDataRight(cl, pt, iTens1, iTens2);
497  } // D1-loop
498  } // D2-loop
499  outputData(cl, pt) = temp;
500  } // P-loop
501  } // C-loop
502  }// case 4
503  break;
504 
505  default:
506  TEUCHOS_TEST_FOR_EXCEPTION( !( (rightDataRank == 2) || (rightDataRank == 3) || (rightDataRank == 4) ), std::invalid_argument,
507  ">>> ERROR (ArrayTools::dotMultiplyDataData): This branch of the method is defined only for rank-2, 3 or 4 right data input containers.");
508  }// rightDataRank
509 
510  } // numDataPoints
511 
512  }
513  else {
514 
515  if (numDataPoints != 1) { // nonconstant data
516 
517  switch(rightDataRank) {
518  case 1: {
519  for(int cl = 0; cl < numCells; cl++) {
520  for(int pt = 0; pt < numPoints; pt++) {
521  outputData(cl, pt) = inputDataLeft(cl, pt)*inputDataRight(pt);
522  } // P-loop
523  } // C-loop
524  }// case 1
525  break;
526 
527  case 2: {
528  for(int cl = 0; cl < numCells; cl++) {
529  for(int pt = 0; pt < numPoints; pt++) {
530  temp = 0;
531  for( int iVec = 0; iVec < dim1Tens; iVec++) {
532  temp += inputDataLeft(cl, pt, iVec)*inputDataRight(pt, iVec);
533  } // D1-loop
534  outputData(cl, pt) = temp;
535  } // P-loop
536  } // C-loop
537  }// case 2
538  break;
539 
540  case 3: {
541  for(int cl = 0; cl < numCells; cl++) {
542  for(int pt = 0; pt < numPoints; pt++) {
543  temp = 0;
544  for(int iTens2 = 0; iTens2 < dim2Tens; iTens2++) {
545  for( int iTens1 = 0; iTens1 < dim1Tens; iTens1++) {
546  temp += inputDataLeft(cl, pt, iTens1, iTens2)*inputDataRight(pt, iTens1, iTens2);
547  } // D1-loop
548  } // D2-loop
549  outputData(cl, pt) = temp;
550  } // P-loop
551  } // C-loop
552  }// case 3
553  break;
554 
555  default:
556  TEUCHOS_TEST_FOR_EXCEPTION( !( (rightDataRank == 1) || (rightDataRank == 2) || (rightDataRank == 3) ), std::invalid_argument,
557  ">>> ERROR (ArrayTools::dotMultiplyDataData): This branch of the method is defined only for rank-1, 2 or 3 right data input containers.");
558  }// rightDataRank
559 
560  }
561  else { //constant data
562 
563  switch(rightDataRank) {
564  case 1: {
565  for(int cl = 0; cl < numCells; cl++) {
566  for(int pt = 0; pt < numPoints; pt++) {
567  outputData(cl, pt) = inputDataLeft(cl, 0)*inputDataRight(pt);
568  } // P-loop
569  } // C-loop
570  }// case 1
571  break;
572 
573  case 2: {
574  for(int cl = 0; cl < numCells; cl++) {
575  for(int pt = 0; pt < numPoints; pt++) {
576  temp = 0;
577  for( int iVec = 0; iVec < dim1Tens; iVec++) {
578  temp += inputDataLeft(cl, 0, iVec)*inputDataRight(pt, iVec);
579  } // D1-loop
580  outputData(cl, pt) = temp;
581  } // P-loop
582  } // C-loop
583  }// case 2
584  break;
585 
586  case 3: {
587  for(int cl = 0; cl < numCells; cl++) {
588  for(int pt = 0; pt < numPoints; pt++) {
589  temp = 0;
590  for(int iTens2 = 0; iTens2 < dim2Tens; iTens2++) {
591  for( int iTens1 = 0; iTens1 < dim1Tens; iTens1++) {
592  temp += inputDataLeft(cl, 0, iTens1, iTens2)*inputDataRight(pt, iTens1, iTens2);
593  } // D1-loop
594  } // D2-loop
595  outputData(cl, pt) = temp;
596  } // P-loop
597  } // C-loop
598  }// case 3
599  break;
600 
601  default:
602  TEUCHOS_TEST_FOR_EXCEPTION( !( (rightDataRank == 1) || (rightDataRank == 2) || (rightDataRank == 3) ), std::invalid_argument,
603  ">>> ERROR (ArrayTools::dotMultiplyDataData): This branch of the method is defined only for rank-1, 2 or 3 right data input containers.");
604  }// rightDataRank
605 
606  } // numDataPoints
607 
608  } // end if (rightDataRank == leftDataRank)
609 
610 }// dotMultiplyDataData
611 
612 
613 
614 } // end namespace Intrepid
static void dotMultiplyDataData(ArrayOutData &outputData, const ArrayInDataLeft &inputDataLeft, const ArrayInDataRight &inputDataRight)
There are two use cases: (1) dot product of a rank-2, 3 or 4 container inputDataRight with dimensions...
static void dotMultiplyDataField(ArrayOutFields &outputFields, const ArrayInData &inputData, const ArrayInFields &inputFields)
There are two use cases: (1) dot product of a rank-3, 4 or 5 container inputFields with dimensions (C...