49#include "Intrepid_HGRAD_QUAD_C2_FEM.hpp"
50#include "Teuchos_oblackholestream.hpp"
51#include "Teuchos_RCP.hpp"
52#include "Teuchos_GlobalMPISession.hpp"
55using namespace Intrepid;
57#define INTREPID_TEST_COMMAND( S , throwCounter, nException ) \
63 catch (const std::logic_error & err) { \
65 *outStream << "Expected Error " << nException << " -------------------------------------------------------------\n"; \
66 *outStream << err.what() << '\n'; \
67 *outStream << "-------------------------------------------------------------------------------" << "\n\n"; \
71int main(
int argc,
char *argv[]) {
73 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
77 int iprint = argc - 1;
78 Teuchos::RCP<std::ostream> outStream;
79 Teuchos::oblackholestream bhs;
81 outStream = Teuchos::rcp(&std::cout,
false);
83 outStream = Teuchos::rcp(&bhs,
false);
86 Teuchos::oblackholestream oldFormatState;
87 oldFormatState.copyfmt(std::cout);
90 <<
"===============================================================================\n" \
92 <<
"| Unit Test (Basis_HGRAD_QUAD_C2_FEM) |\n" \
94 <<
"| 1) Conversion of Dof tags into Dof ordinals and back |\n" \
95 <<
"| 2) Basis values for VALUE, GRAD, CURL, and Dk operators |\n" \
97 <<
"| Questions? Contact Pavel Bochev (pbboche@sandia.gov), |\n" \
98 <<
"| Denis Ridzal (dridzal@sandia.gov), |\n" \
99 <<
"| Kara Peterson (kjpeter@sandia.gov). |\n" \
101 <<
"| Intrepid's website: http://trilinos.sandia.gov/packages/intrepid |\n" \
102 <<
"| Trilinos website: http://trilinos.sandia.gov |\n" \
104 <<
"===============================================================================\n"\
105 <<
"| TEST 1: Basis creation, exception testing |\n"\
106 <<
"===============================================================================\n";
114 int throwCounter = 0;
118 quadNodes(0,0) = -1.0; quadNodes(0,1) = -1.0;
119 quadNodes(1,0) = 1.0; quadNodes(1,1) = -1.0;
120 quadNodes(2,0) = 1.0; quadNodes(2,1) = 1.0;
121 quadNodes(3,0) = -1.0; quadNodes(3,1) = 1.0;
123 quadNodes(4,0) = 0.0; quadNodes(4,1) = -1.0;
124 quadNodes(5,0) = 1.0; quadNodes(5,1) = 0.0;
125 quadNodes(6,0) = 0.0; quadNodes(6,1) = 1.0;
126 quadNodes(7,0) = -1.0; quadNodes(7,1) = 0.0;
128 quadNodes(8,0) = 0.0; quadNodes(8,1) = 0.0;
129 quadNodes(9,0) =1./3.; quadNodes(9,1) =-3./5.;
139 INTREPID_TEST_COMMAND( quadBasis.
getValues(vals, quadNodes, OPERATOR_DIV), throwCounter, nException );
144 INTREPID_TEST_COMMAND( quadBasis.
getDofOrdinal(3,0,0), throwCounter, nException );
146 INTREPID_TEST_COMMAND( quadBasis.
getDofOrdinal(1,1,1), throwCounter, nException );
148 INTREPID_TEST_COMMAND( quadBasis.
getDofOrdinal(0,4,0), throwCounter, nException );
150 INTREPID_TEST_COMMAND( quadBasis.
getDofTag(10), throwCounter, nException );
152 INTREPID_TEST_COMMAND( quadBasis.
getDofTag(-1), throwCounter, nException );
154#ifdef HAVE_INTREPID_DEBUG
158 INTREPID_TEST_COMMAND( quadBasis.
getValues(vals, badPoints1, OPERATOR_VALUE), throwCounter, nException );
162 INTREPID_TEST_COMMAND( quadBasis.
getValues(vals, badPoints2, OPERATOR_VALUE), throwCounter, nException );
166 INTREPID_TEST_COMMAND( quadBasis.
getValues(badVals1, quadNodes, OPERATOR_VALUE), throwCounter, nException );
170 INTREPID_TEST_COMMAND( quadBasis.
getValues(badVals2, quadNodes, OPERATOR_GRAD), throwCounter, nException );
173 INTREPID_TEST_COMMAND( quadBasis.
getValues(badVals2, quadNodes, OPERATOR_CURL), throwCounter, nException );
176 INTREPID_TEST_COMMAND( quadBasis.
getValues(badVals2, quadNodes, OPERATOR_D2), throwCounter, nException );
180 INTREPID_TEST_COMMAND( quadBasis.
getValues(badVals3, quadNodes, OPERATOR_VALUE), throwCounter, nException );
184 INTREPID_TEST_COMMAND( quadBasis.
getValues(badVals4, quadNodes, OPERATOR_VALUE), throwCounter, nException );
188 INTREPID_TEST_COMMAND( quadBasis.
getValues(badVals5, quadNodes, OPERATOR_GRAD), throwCounter, nException );
192 INTREPID_TEST_COMMAND( quadBasis.
getValues(badVals6, quadNodes, OPERATOR_D2), throwCounter, nException );
195 INTREPID_TEST_COMMAND( quadBasis.
getValues(badVals6, quadNodes, OPERATOR_D3), throwCounter, nException );
199 catch (
const std::logic_error & err) {
200 *outStream <<
"UNEXPECTED ERROR !!! ----------------------------------------------------------\n";
201 *outStream << err.what() <<
'\n';
202 *outStream <<
"-------------------------------------------------------------------------------" <<
"\n\n";
207 if (throwCounter != nException) {
209 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
214 <<
"===============================================================================\n"\
215 <<
"| TEST 2: correctness of tag to enum and enum to tag lookups |\n"\
216 <<
"===============================================================================\n";
219 std::vector<std::vector<int> > allTags = quadBasis.
getAllDofTags();
222 for (
unsigned i = 0; i < allTags.size(); i++) {
223 int bfOrd = quadBasis.
getDofOrdinal(allTags[i][0], allTags[i][1], allTags[i][2]);
225 std::vector<int> myTag = quadBasis.
getDofTag(bfOrd);
226 if( !( (myTag[0] == allTags[i][0]) &&
227 (myTag[1] == allTags[i][1]) &&
228 (myTag[2] == allTags[i][2]) &&
229 (myTag[3] == allTags[i][3]) ) ) {
231 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
232 *outStream <<
" getDofOrdinal( {"
233 << allTags[i][0] <<
", "
234 << allTags[i][1] <<
", "
235 << allTags[i][2] <<
", "
236 << allTags[i][3] <<
"}) = " << bfOrd <<
" but \n";
237 *outStream <<
" getDofTag(" << bfOrd <<
") = { "
241 << myTag[3] <<
"}\n";
246 for(
int bfOrd = 0; bfOrd < quadBasis.
getCardinality(); bfOrd++) {
247 std::vector<int> myTag = quadBasis.
getDofTag(bfOrd);
248 int myBfOrd = quadBasis.
getDofOrdinal(myTag[0], myTag[1], myTag[2]);
249 if( bfOrd != myBfOrd) {
251 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
252 *outStream <<
" getDofTag(" << bfOrd <<
") = { "
256 << myTag[3] <<
"} but getDofOrdinal({"
260 << myTag[3] <<
"} ) = " << myBfOrd <<
"\n";
264 catch (
const std::logic_error & err){
265 *outStream << err.what() <<
"\n\n";
271 <<
"===============================================================================\n"\
272 <<
"| TEST 3: correctness of basis function values |\n"\
273 <<
"===============================================================================\n";
275 outStream -> precision(20);
278 double basisValues[] = {
279 1.000000000000000, 0, 0, 0, 0, 0, 0, 0, 0, -0.05333333333333334, 0, \
280 1.000000000000000, 0, 0, 0, 0, 0, 0, 0, 0.1066666666666667, 0, 0, \
281 1.000000000000000, 0, 0, 0, 0, 0, 0, -0.02666666666666666, 0, 0, 0, \
282 1.000000000000000, 0, 0, 0, 0, 0, 0.01333333333333333, 0, 0, 0, 0, \
283 1.000000000000000, 0, 0, 0, 0, 0.4266666666666667, 0, 0, 0, 0, 0, \
284 1.000000000000000, 0, 0, 0, 0.1422222222222222, 0, 0, 0, 0, 0, 0, \
285 1.000000000000000, 0, 0, -0.1066666666666667, 0, 0, 0, 0, 0, 0, 0, \
286 1.000000000000000, 0, -0.07111111111111112, 0, 0, 0, 0, 0, 0, 0, 0, \
287 1.000000000000000, 0.5688888888888890};
290 double basisGrads[] = {
291 -1.500000000000000, -1.500000000000000, 0.5000000000000000, 0, 0, 0, \
292 0, 0.5000000000000000, -0.5000000000000000, 0, 0, 0, 0, 0, 0, \
293 -0.5000000000000000, 0, 0, -0.08000000000000002, 0.1222222222222222, \
294 -0.5000000000000000, 0, 1.500000000000000, -1.500000000000000, 0, \
295 0.5000000000000000, 0, 0, 0.5000000000000000, 0, 0, \
296 -0.5000000000000000, 0, 0, 0, 0, 0, 0, 0.3999999999999999, \
297 -0.2444444444444444, 0, 0, 0, -0.5000000000000000, 1.500000000000000, \
298 1.500000000000000, -0.5000000000000000, 0, 0, 0, 0, \
299 0.5000000000000000, 0.5000000000000000, 0, 0, 0, 0, 0, \
300 -0.09999999999999998, -0.02222222222222221, 0, -0.5000000000000000, \
301 0, 0, 0.5000000000000000, 0, -1.500000000000000, 1.500000000000000, \
302 0, 0, 0, 0, -0.5000000000000000, 0, 0, 0.5000000000000000, 0, 0, \
303 0.02000000000000000, 0.01111111111111112, 2.000000000000000, 0, \
304 -2.000000000000000, 0, 0, 0, 0, 0, 0, -1.500000000000000, 0, 0, 0, \
305 0.5000000000000000, 0, 0, 0, -0.5000000000000000, \
306 -0.3199999999999999, -0.9777777777777779, 0, 0, 0, 2.000000000000000, \
307 0, -2.000000000000000, 0, 0, 0, 0, 1.500000000000000, 0, 0, 0, \
308 -0.5000000000000000, 0, 0.5000000000000000, 0, 0.5333333333333334, \
309 0.2666666666666666, 0, 0, 0, 0, -2.000000000000000, 0, \
310 2.000000000000000, 0, 0, -0.5000000000000000, 0, 0, 0, \
311 1.500000000000000, 0, 0, 0, 0.5000000000000000, 0.07999999999999997, \
312 -0.08888888888888888, 0, 2.000000000000000, 0, 0, 0, 0, 0, \
313 -2.000000000000000, 0, 0, 0.5000000000000000, 0, 0, 0, \
314 -1.500000000000000, 0, -0.5000000000000000, 0, -0.1066666666666667, \
315 -0.1333333333333333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2.000000000000000, \
316 -2.000000000000000, 0, 0, -2.000000000000000, 2.000000000000000, 0, \
317 0, 0, -0.4266666666666667, 1.066666666666667};
321 1.000000000000000, 2.250000000000000, 1.000000000000000, \
322 1.000000000000000, -0.7500000000000000, 0, 0, 0.2500000000000000, 0, \
323 0, -0.7500000000000000, 1.000000000000000, 1.000000000000000, \
324 0.7500000000000000, 0, 0, -0.2500000000000000, 0, 0, \
325 -0.2500000000000000, 0, 0, 0.7500000000000000, 1.000000000000000, 0, \
326 0.2500000000000000, 0, 0.4800000000000000, 0.1833333333333334, \
327 -0.1111111111111111, 1.000000000000000, 0.7500000000000000, 0, \
328 1.000000000000000, -2.250000000000000, 1.000000000000000, 0, \
329 0.7500000000000000, 1.000000000000000, 0, -0.2500000000000000, 0, \
330 1.000000000000000, -0.7500000000000000, 0, 0, -0.7500000000000000, \
331 1.000000000000000, 0, 0.2500000000000000, 0, 0, 0.2500000000000000, \
332 0, 0, -0.2500000000000000, 0, 0.4800000000000000, \
333 -0.9166666666666666, 0.2222222222222222, 0, 0.2500000000000000, 0, 0, \
334 -0.7500000000000000, 1.000000000000000, 1.000000000000000, \
335 2.250000000000000, 1.000000000000000, 1.000000000000000, \
336 -0.7500000000000000, 0, 0, -0.2500000000000000, 0, 0, \
337 0.7500000000000000, 1.000000000000000, 1.000000000000000, \
338 0.7500000000000000, 0, 0, -0.2500000000000000, 0, 0, \
339 0.2500000000000000, 0, -0.1200000000000000, -0.08333333333333331, \
340 0.2222222222222222, 0, 0.7500000000000000, 1.000000000000000, 0, \
341 -0.2500000000000000, 0, 1.000000000000000, 0.7500000000000000, 0, \
342 1.000000000000000, -2.250000000000000, 1.000000000000000, 0, \
343 0.2500000000000000, 0, 0, 0.2500000000000000, 0, 1.000000000000000, \
344 -0.7500000000000000, 0, 0, -0.7500000000000000, 1.000000000000000, 0, \
345 -0.2500000000000000, 0, -0.1200000000000000, 0.01666666666666666, \
346 -0.1111111111111111, -2.000000000000000, -3.000000000000000, 0, \
347 -2.000000000000000, 3.000000000000000, 0, 0, -1.000000000000000, 0, \
348 0, 1.000000000000000, 0, -2.000000000000000, 0, 1.000000000000000, 0, \
349 1.000000000000000, 0, 0, 0, 1.000000000000000, 0, -1.000000000000000, \
350 0, 0, 0, 1.000000000000000, -0.9600000000000000, 0.7333333333333332, \
351 0.8888888888888890, 0, -1.000000000000000, 0, 0, 3.000000000000000, \
352 -2.000000000000000, 0, -3.000000000000000, -2.000000000000000, 0, \
353 1.000000000000000, 0, 0, 1.000000000000000, 0, 1.000000000000000, 0, \
354 -2.000000000000000, 0, -1.000000000000000, 0, 1.000000000000000, 0, \
355 0, 1.000000000000000, 0, 0, 0.6400000000000001, 1.000000000000000, \
356 -0.4444444444444444, 0, -1.000000000000000, 0, 0, 1.000000000000000, \
357 0, -2.000000000000000, -3.000000000000000, 0, -2.000000000000000, \
358 3.000000000000000, 0, 0, 0, 1.000000000000000, 0, -1.000000000000000, \
359 0, -2.000000000000000, 0, 1.000000000000000, 0, 1.000000000000000, 0, \
360 0, 0, 1.000000000000000, 0.2400000000000000, 0.06666666666666665, \
361 0.8888888888888890, 0, -3.000000000000000, -2.000000000000000, 0, \
362 1.000000000000000, 0, 0, -1.000000000000000, 0, 0, 3.000000000000000, \
363 -2.000000000000000, 0, -1.000000000000000, 0, 1.000000000000000, 0, \
364 0, 0, 1.000000000000000, 0, 1.000000000000000, 0, -2.000000000000000, \
365 1.000000000000000, 0, 0, 0.6400000000000001, -0.2000000000000001, \
366 0.2222222222222222, 0, 4.000000000000000, 0, 0, -4.000000000000000, \
367 0, 0, 4.000000000000000, 0, 0, -4.000000000000000, 0, 0, 0, \
368 -2.000000000000000, -2.000000000000000, 0, 0, 0, 0, \
369 -2.000000000000000, -2.000000000000000, 0, 0, -2.000000000000000, 0, \
370 -2.000000000000000, -1.280000000000000, -0.7999999999999998, \
375 0, -1.500000000000000, -1.500000000000000, 0, 0, -1.500000000000000, \
376 0.5000000000000000, 0, 0, 0.5000000000000000, 0.5000000000000000, 0, \
377 0, 0.5000000000000000, -1.500000000000000, 0, 0, -1.500000000000000, \
378 -0.5000000000000000, 0, 0, -0.5000000000000000, 0.5000000000000000, \
379 0, 0, 0.5000000000000000, -0.5000000000000000, 0, 0, \
380 -0.5000000000000000, -1.500000000000000, 0, 0, -0.5000000000000000, \
381 -0.5000000000000000, 0, 0, -1.100000000000000, -0.1666666666666667, \
382 0, 0, -1.500000000000000, -0.5000000000000000, 0, 0, \
383 -1.500000000000000, 1.500000000000000, 0, 0, 0.5000000000000000, \
384 1.500000000000000, 0, 0, 0.5000000000000000, -0.5000000000000000, 0, \
385 0, -1.500000000000000, 0.5000000000000000, 0, 0, -0.5000000000000000, \
386 1.500000000000000, 0, 0, 0.5000000000000000, 0.5000000000000000, 0, \
387 0, -0.5000000000000000, -0.5000000000000000, 0, 0, \
388 -0.5000000000000000, 0.5000000000000000, 0, 0, -1.100000000000000, \
389 0.8333333333333333, 0, 0, -0.5000000000000000, -0.5000000000000000, \
390 0, 0, -0.5000000000000000, 1.500000000000000, 0, 0, \
391 1.500000000000000, 1.500000000000000, 0, 0, 1.500000000000000, \
392 -0.5000000000000000, 0, 0, -0.5000000000000000, 0.5000000000000000, \
393 0, 0, 0.5000000000000000, 1.500000000000000, 0, 0, 1.500000000000000, \
394 0.5000000000000000, 0, 0, 0.5000000000000000, -0.5000000000000000, 0, \
395 0, 0.5000000000000000, 0.5000000000000000, 0, 0, \
396 -0.09999999999999998, 0.8333333333333333, 0, 0, -0.5000000000000000, \
397 -1.500000000000000, 0, 0, -0.5000000000000000, 0.5000000000000000, 0, \
398 0, 1.500000000000000, 0.5000000000000000, 0, 0, 1.500000000000000, \
399 -1.500000000000000, 0, 0, -0.5000000000000000, -0.5000000000000000, \
400 0, 0, 0.5000000000000000, 0.5000000000000000, 0, 0, \
401 1.500000000000000, -0.5000000000000000, 0, 0, 0.5000000000000000, \
402 -1.500000000000000, 0, 0, 0.5000000000000000, -0.5000000000000000, 0, \
403 0, -0.09999999999999998, -0.1666666666666667, 0, 0, \
404 3.000000000000000, 2.000000000000000, 0, 0, 3.000000000000000, \
405 -2.000000000000000, 0, 0, -1.000000000000000, -2.000000000000000, 0, \
406 0, -1.000000000000000, 2.000000000000000, 0, 0, 3.000000000000000, 0, \
407 0, 0, 1.000000000000000, -2.000000000000000, 0, 0, \
408 -1.000000000000000, 0, 0, 0, 1.000000000000000, 2.000000000000000, 0, \
409 0, 1.000000000000000, 0, 0, 0, 2.200000000000000, \
410 -0.6666666666666665, 0, 0, 2.000000000000000, 1.000000000000000, 0, \
411 0, 2.000000000000000, -3.000000000000000, 0, 0, -2.000000000000000, \
412 -3.000000000000000, 0, 0, -2.000000000000000, 1.000000000000000, 0, \
413 0, 2.000000000000000, -1.000000000000000, 0, 0, 0, \
414 -3.000000000000000, 0, 0, -2.000000000000000, -1.000000000000000, 0, \
415 0, 0, 1.000000000000000, 0, 0, 0, -1.000000000000000, 0, 0, \
416 1.200000000000000, -1.666666666666667, 0, 0, 1.000000000000000, \
417 2.000000000000000, 0, 0, 1.000000000000000, -2.000000000000000, 0, 0, \
418 -3.000000000000000, -2.000000000000000, 0, 0, -3.000000000000000, \
419 2.000000000000000, 0, 0, 1.000000000000000, 0, 0, 0, \
420 -1.000000000000000, -2.000000000000000, 0, 0, -3.000000000000000, 0, \
421 0, 0, -1.000000000000000, 2.000000000000000, 0, 0, \
422 -1.000000000000000, 0, 0, 0, 0.2000000000000000, -0.6666666666666665, \
423 0, 0, 2.000000000000000, 3.000000000000000, 0, 0, 2.000000000000000, \
424 -1.000000000000000, 0, 0, -2.000000000000000, -1.000000000000000, 0, \
425 0, -2.000000000000000, 3.000000000000000, 0, 0, 2.000000000000000, \
426 1.000000000000000, 0, 0, 0, -1.000000000000000, 0, 0, \
427 -2.000000000000000, 1.000000000000000, 0, 0, 0, 3.000000000000000, 0, \
428 0, 0, 1.000000000000000, 0, 0, 1.200000000000000, 0.3333333333333334, \
429 0, 0, -4.000000000000000, -4.000000000000000, 0, 0, \
430 -4.000000000000000, 4.000000000000000, 0, 0, 4.000000000000000, \
431 4.000000000000000, 0, 0, 4.000000000000000, -4.000000000000000, 0, 0, \
432 -4.000000000000000, 0, 0, 0, 0, 4.000000000000000, 0, 0, \
433 4.000000000000000, 0, 0, 0, 0, -4.000000000000000, 0, 0, 0, 0, 0, 0, \
434 -2.400000000000000, 1.333333333333333, 0};
437 0, 0, 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
438 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
439 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
440 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
441 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
442 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
443 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
444 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
445 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
446 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
447 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
448 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
449 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
450 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
451 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
452 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
453 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
454 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
455 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
456 1.000000000000000, 0, 0, 0, 0, 1.000000000000000, 0, 0, 0, 0, \
457 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
458 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
459 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
460 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
461 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
462 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
463 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
464 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
465 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
466 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
467 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
468 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
469 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
470 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
471 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
472 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
473 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
474 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
475 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
476 -2.000000000000000, 0, 0, 0, 0, -2.000000000000000, 0, 0, 0, 0, \
477 4.000000000000000, 0, 0, 0, 0, 4.000000000000000, 0, 0, 0, 0, \
478 4.000000000000000, 0, 0, 0, 0, 4.000000000000000, 0, 0, 0, 0, \
479 4.000000000000000, 0, 0, 0, 0, 4.000000000000000, 0, 0, 0, 0, \
480 4.000000000000000, 0, 0, 0, 0, 4.000000000000000, 0, 0, 0, 0, \
481 4.000000000000000, 0, 0, 0, 0, 4.000000000000000, 0, 0};
487 int numPoints = quadNodes.dimension(0);
494 vals.
resize(numFields, numPoints);
495 quadBasis.
getValues(vals, quadNodes, OPERATOR_VALUE);
496 for (
int i = 0; i < numFields; i++) {
497 for (
int j = 0; j < numPoints; j++) {
500 int l = j + i * numPoints;
501 if (std::abs(vals(i,j) - basisValues[l]) > INTREPID_TOL) {
503 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
506 *outStream <<
" At multi-index { ";
507 *outStream << i <<
" ";*outStream << j <<
" ";
508 *outStream <<
"} computed value: " << vals(i,j)
509 <<
" but reference value: " << basisValues[l] <<
"\n";
515 vals.
resize(numFields, numPoints, spaceDim);
516 quadBasis.
getValues(vals, quadNodes, OPERATOR_GRAD);
517 for (
int i = 0; i < numFields; i++) {
518 for (
int j = 0; j < numPoints; j++) {
519 for (
int k = 0; k < spaceDim; k++) {
522 int l = k + j * spaceDim + i * spaceDim * numPoints;
523 if (std::abs(vals(i,j,k) - basisGrads[l]) > INTREPID_TOL) {
525 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
528 *outStream <<
" At multi-index { ";
529 *outStream << i <<
" ";*outStream << j <<
" ";*outStream << k <<
" ";
530 *outStream <<
"} computed grad component: " << vals(i,j,k)
531 <<
" but reference grad component: " << basisGrads[l] <<
"\n";
539 quadBasis.
getValues(vals, quadNodes, OPERATOR_D1);
540 for (
int i = 0; i < numFields; i++) {
541 for (
int j = 0; j < numPoints; j++) {
542 for (
int k = 0; k < spaceDim; k++) {
545 int l = k + j * spaceDim + i * spaceDim * numPoints;
546 if (std::abs(vals(i,j,k) - basisGrads[l]) > INTREPID_TOL) {
548 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
551 *outStream <<
" At multi-index { ";
552 *outStream << i <<
" ";*outStream << j <<
" ";*outStream << k <<
" ";
553 *outStream <<
"} computed D1 component: " << vals(i,j,k)
554 <<
" but reference D1 component: " << basisGrads[l] <<
"\n";
562 vals.
resize(numFields, numPoints, spaceDim);
563 quadBasis.
getValues(vals, quadNodes, OPERATOR_CURL);
564 for (
int i = 0; i < numFields; i++) {
565 for (
int j = 0; j < numPoints; j++) {
567 int curl_0 = 1 + j * spaceDim + i * spaceDim * numPoints;
568 int curl_1 = 0 + j * spaceDim + i * spaceDim * numPoints;
570 double curl_value_0 = basisGrads[curl_0];
571 double curl_value_1 =-basisGrads[curl_1];
572 if (std::abs(vals(i,j,0) - curl_value_0) > INTREPID_TOL) {
574 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
576 *outStream <<
" At multi-index { ";
577 *outStream << i <<
" ";*outStream << j <<
" ";*outStream << 0 <<
" ";
578 *outStream <<
"} computed curl component: " << vals(i,j,0)
579 <<
" but reference curl component: " << curl_value_0 <<
"\n";
581 if (std::abs(vals(i,j,1) - curl_value_1) > INTREPID_TOL) {
583 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
585 *outStream <<
" At multi-index { ";
586 *outStream << i <<
" ";*outStream << j <<
" ";*outStream << 1 <<
" ";
587 *outStream <<
"} computed curl component: " << vals(i,j,1)
588 <<
" but reference curl component: " << curl_value_1 <<
"\n";
595 vals.
resize(numFields, numPoints, D2cardinality);
596 quadBasis.
getValues(vals, quadNodes, OPERATOR_D2);
597 for (
int i = 0; i < numFields; i++) {
598 for (
int j = 0; j < numPoints; j++) {
599 for (
int k = 0; k < D2cardinality; k++) {
602 int l = k + j * D2cardinality + i * D2cardinality * numPoints;
603 if (std::abs(vals(i,j,k) - basisD2[l]) > INTREPID_TOL) {
605 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
608 *outStream <<
" At multi-index { ";
609 *outStream << i <<
" ";*outStream << j <<
" ";*outStream << k <<
" ";
610 *outStream <<
"} computed D2 component: " << vals(i,j,k)
611 <<
" but reference D2 component: " << basisD2[l] <<
"\n";
620 vals.
resize(numFields, numPoints, D3cardinality);
621 quadBasis.
getValues(vals, quadNodes, OPERATOR_D3);
622 for (
int i = 0; i < numFields; i++) {
623 for (
int j = 0; j < numPoints; j++) {
624 for (
int k = 0; k < D3cardinality; k++) {
627 int l = k + j * D3cardinality + i * D3cardinality * numPoints;
628 if (std::abs(vals(i,j,k) - basisD3[l]) > INTREPID_TOL) {
630 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
633 *outStream <<
" At multi-index { ";
634 *outStream << i <<
" ";*outStream << j <<
" ";*outStream << k <<
" ";
635 *outStream <<
"} computed D3 component: " << vals(i,j,k)
636 <<
" but reference D3 component: " << basisD2[l] <<
"\n";
645 vals.
resize(numFields, numPoints, D4cardinality);
646 quadBasis.
getValues(vals, quadNodes, OPERATOR_D4);
647 for (
int i = 0; i < numFields; i++) {
648 for (
int j = 0; j < numPoints; j++) {
649 for (
int k = 0; k < D4cardinality; k++) {
652 int l = k + j * D4cardinality + i * D4cardinality * numPoints;
653 if (std::abs(vals(i,j,k) - basisD4[l]) > INTREPID_TOL) {
655 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
658 *outStream <<
" At multi-index { ";
659 *outStream << i <<
" ";*outStream << j <<
" ";*outStream << k <<
" ";
660 *outStream <<
"} computed D4 component: " << vals(i,j,k)
661 <<
" but reference D4 component: " << basisD2[l] <<
"\n";
669 for(EOperator op = OPERATOR_D5; op < OPERATOR_MAX; op++) {
673 vals.
resize(numFields, numPoints, DkCardin);
675 quadBasis.
getValues(vals, quadNodes, op);
676 for (
int i = 0; i < vals.
size(); i++) {
677 if (std::abs(vals[i]) > INTREPID_TOL) {
679 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
682 std::vector<int> myIndex;
685 *outStream <<
" At multi-index { ";
686 for(
int j = 0; j < vals.
rank(); j++) {
687 *outStream << myIndex[j] <<
" ";
689 *outStream <<
"} computed D"<< ord <<
" component: " << vals[i]
690 <<
" but reference D" << ord <<
" component: 0 \n";
696 catch (
const std::logic_error & err) {
697 *outStream << err.what() <<
"\n\n";
704 <<
"===============================================================================\n"\
705 <<
"| TEST 4: correctness of DoF locations |\n"\
706 <<
"===============================================================================\n";
709 Teuchos::RCP<Basis<double, FieldContainer<double> > > basis =
711 Teuchos::RCP<DofCoordsInterface<FieldContainer<double> > > coord_iface =
712 Teuchos::rcp_dynamic_cast<DofCoordsInterface<FieldContainer<double> > >(basis);
718#ifdef HAVE_INTREPID_DEBUG
720 INTREPID_TEST_COMMAND( coord_iface->getDofCoords(cvals), throwCounter, nException );
722 INTREPID_TEST_COMMAND( coord_iface->getDofCoords(cvals), throwCounter, nException );
724 INTREPID_TEST_COMMAND( coord_iface->getDofCoords(cvals), throwCounter, nException );
727 INTREPID_TEST_COMMAND( coord_iface->getDofCoords(cvals), throwCounter, nException ); nException--;
729 if (throwCounter != nException) {
731 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
735 basis->getValues(bvals, cvals, OPERATOR_VALUE);
737 for (
int i=0; i<bvals.dimension(0); i++) {
738 for (
int j=0; j<bvals.dimension(1); j++) {
739 if ((i != j) && (std::abs(bvals(i,j) - 0.0) > INTREPID_TOL)) {
741 sprintf(buffer,
"\nValue of basis function %d at (%6.4e, %6.4e) is %6.4e but should be %6.4e!\n", i, cvals(i,0), cvals(i,1), bvals(i,j), 0.0);
742 *outStream << buffer;
744 else if ((i == j) && (std::abs(bvals(i,j) - 1.0) > INTREPID_TOL)) {
746 sprintf(buffer,
"\nValue of basis function %d at (%6.4e, %6.4e) is %6.4e but should be %6.4e!\n", i, cvals(i,0), cvals(i,1), bvals(i,j), 1.0);
747 *outStream << buffer;
753 catch (
const std::logic_error & err){
754 *outStream << err.what() <<
"\n\n";
759 std::cout <<
"End Result: TEST FAILED\n";
761 std::cout <<
"End Result: TEST PASSED\n";
764 std::cout.copyfmt(oldFormatState);
Header file for utility class to provide multidimensional containers.
int getOperatorOrder(const EOperator operatorType)
Returns order of an operator.
int getDkCardinality(const EOperator operatorType, const int spaceDim)
Returns cardinality of Dk, i.e., the number of all derivatives of order k.
Implementation of the default H(grad)-compatible FEM basis of degree 2 on Quadrilateral cell.
void getValues(ArrayScalar &outputValues, const ArrayScalar &inputPoints, const EOperator operatorType) const
FEM basis evaluation on a reference Quadrilateral cell.
virtual int getDofOrdinal(const int subcDim, const int subcOrd, const int subcDofOrd)
DoF tag to ordinal lookup.
virtual const std::vector< std::vector< int > > & getAllDofTags()
Retrieves all DoF tags.
virtual const shards::CellTopology getBaseCellTopology() const
Returns the base cell topology for which the basis is defined. See Shards documentation http://trilin...
virtual const std::vector< int > & getDofTag(const int dofOrd)
DoF ordinal to DoF tag lookup.
virtual int getCardinality() const
Returns cardinality of the basis.
Implementation of a templated lexicographical container for a multi-indexed scalar quantity....
int size() const
Returns size of the FieldContainer defined as the product of its dimensions.
void resize(const int dim0)
Resizes FieldContainer to a rank-1 container with the specified dimension, initialized by 0.
void getMultiIndex(int &i0, const int valueEnum) const
Returns the multi-index of a value, based on its enumeration, as a list, for rank-1 containers.
int rank() const
Return rank of the FieldContainer = number of indices used to tag the multi-indexed value.