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