50 #include "Teuchos_oblackholestream.hpp"
51 #include "Teuchos_RCP.hpp"
52 #include "Teuchos_GlobalMPISession.hpp"
55 using 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"; \
71 int 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_HCURL_WEDGE_I1_FEM) |\n" \
94 <<
"| 1) Conversion of Dof tags into Dof ordinals and back |\n" \
95 <<
"| 2) Basis values for VALUE and CURL 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 wedgeNodes(0,0) = 0.0; wedgeNodes(0,1) = 0.0; wedgeNodes(0,2) = -1.0;
119 wedgeNodes(1,0) = 1.0; wedgeNodes(1,1) = 0.0; wedgeNodes(1,2) = -1.0;
120 wedgeNodes(2,0) = 0.0; wedgeNodes(2,1) = 1.0; wedgeNodes(2,2) = -1.0;
121 wedgeNodes(3,0) = 0.0; wedgeNodes(3,1) = 0.0; wedgeNodes(3,2) = 1.0;
122 wedgeNodes(4,0) = 1.0; wedgeNodes(4,1) = 0.0; wedgeNodes(4,2) = 1.0;
123 wedgeNodes(5,0) = 0.0; wedgeNodes(5,1) = 1.0; wedgeNodes(5,2) = 1.0;
125 wedgeNodes(6,0) = 0.25; wedgeNodes(6,1) = 0.5; wedgeNodes(6,2) = -1.0;
126 wedgeNodes(7,0) = 0.5; wedgeNodes(7,1) = 0.25; wedgeNodes(7,2) = 0.0;
127 wedgeNodes(8,0) = 0.25; wedgeNodes(8,1) = 0.25; wedgeNodes(8,2) = 1.0;
128 wedgeNodes(9,0) = 0.25; wedgeNodes(9,1) = 0.0; wedgeNodes(9,2) = 0.75;
129 wedgeNodes(10,0)= 0.0; wedgeNodes(10,1)= 0.5; wedgeNodes(10,2)= -0.25;
130 wedgeNodes(11,0)= 0.5; wedgeNodes(11,1)= 0.5; wedgeNodes(11,2)= 0.0;
141 INTREPID_TEST_COMMAND( wedgeBasis.
getValues(vals, wedgeNodes, OPERATOR_GRAD), throwCounter, nException );
146 INTREPID_TEST_COMMAND( wedgeBasis.
getValues(vals, wedgeNodes, OPERATOR_DIV), throwCounter, nException );
151 INTREPID_TEST_COMMAND( wedgeBasis.
getDofOrdinal(3,0,0), throwCounter, nException );
153 INTREPID_TEST_COMMAND( wedgeBasis.
getDofOrdinal(1,1,1), throwCounter, nException );
155 INTREPID_TEST_COMMAND( wedgeBasis.
getDofOrdinal(0,4,1), throwCounter, nException );
157 INTREPID_TEST_COMMAND( wedgeBasis.
getDofTag(10), throwCounter, nException );
159 INTREPID_TEST_COMMAND( wedgeBasis.
getDofTag(-1), throwCounter, nException );
161 #ifdef HAVE_INTREPID_DEBUG
165 INTREPID_TEST_COMMAND( wedgeBasis.
getValues(vals, badPoints1, OPERATOR_VALUE), throwCounter, nException );
169 INTREPID_TEST_COMMAND( wedgeBasis.
getValues(vals, badPoints1, OPERATOR_VALUE), throwCounter, nException );
173 INTREPID_TEST_COMMAND( wedgeBasis.
getValues(badVals1, wedgeNodes, OPERATOR_VALUE), throwCounter, nException );
176 INTREPID_TEST_COMMAND( wedgeBasis.
getValues(badVals1, wedgeNodes, OPERATOR_CURL), throwCounter, nException );
180 INTREPID_TEST_COMMAND( wedgeBasis.
getValues(badVals2, wedgeNodes, OPERATOR_VALUE), throwCounter, nException );
184 INTREPID_TEST_COMMAND( wedgeBasis.
getValues(badVals3, wedgeNodes, OPERATOR_VALUE), throwCounter, nException );
188 INTREPID_TEST_COMMAND( wedgeBasis.
getValues(badVals4, wedgeNodes, OPERATOR_VALUE), throwCounter, nException );
191 INTREPID_TEST_COMMAND( wedgeBasis.
getValues(badVals4, wedgeNodes, OPERATOR_CURL), throwCounter, nException );
195 catch (
const std::logic_error & err) {
196 *outStream <<
"UNEXPECTED ERROR !!! ----------------------------------------------------------\n";
197 *outStream << err.what() <<
'\n';
198 *outStream <<
"-------------------------------------------------------------------------------" <<
"\n\n";
204 if (throwCounter != nException) {
206 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
211 <<
"===============================================================================\n"\
212 <<
"| TEST 2: correctness of tag to enum and enum to tag lookups |\n"\
213 <<
"===============================================================================\n";
216 std::vector<std::vector<int> > allTags = wedgeBasis.
getAllDofTags();
219 for (
unsigned i = 0; i < allTags.size(); i++) {
220 int bfOrd = wedgeBasis.
getDofOrdinal(allTags[i][0], allTags[i][1], allTags[i][2]);
222 std::vector<int> myTag = wedgeBasis.
getDofTag(bfOrd);
223 if( !( (myTag[0] == allTags[i][0]) &&
224 (myTag[1] == allTags[i][1]) &&
225 (myTag[2] == allTags[i][2]) &&
226 (myTag[3] == allTags[i][3]) ) ) {
228 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
229 *outStream <<
" getDofOrdinal( {"
230 << allTags[i][0] <<
", "
231 << allTags[i][1] <<
", "
232 << allTags[i][2] <<
", "
233 << allTags[i][3] <<
"}) = " << bfOrd <<
" but \n";
234 *outStream <<
" getDofTag(" << bfOrd <<
") = { "
238 << myTag[3] <<
"}\n";
243 for(
int bfOrd = 0; bfOrd < wedgeBasis.
getCardinality(); bfOrd++) {
244 std::vector<int> myTag = wedgeBasis.
getDofTag(bfOrd);
245 int myBfOrd = wedgeBasis.
getDofOrdinal(myTag[0], myTag[1], myTag[2]);
246 if( bfOrd != myBfOrd) {
248 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
249 *outStream <<
" getDofTag(" << bfOrd <<
") = { "
253 << myTag[3] <<
"} but getDofOrdinal({"
257 << myTag[3] <<
"} ) = " << myBfOrd <<
"\n";
261 catch (
const std::logic_error & err){
262 *outStream << err.what() <<
"\n\n";
268 <<
"===============================================================================\n"\
269 <<
"| TEST 3: correctness of basis function values |\n"\
270 <<
"===============================================================================\n";
272 outStream -> precision(20);
275 double basisValues[] = {
276 1.00000, 0, 0, 0, 0, 0, 0, -1.00000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
277 0, 0.500000, 0, 0, 0, 0, 0, 0, 1.00000, 1.00000, 0, 0, 1.00000, 0, 0, \
278 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.500000, 0, 0, 0, 0, \
279 0, 0, -1.00000, 0, 0, -1.00000, -1.00000, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
280 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.500000, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
281 1.00000, 0, 0, 0, 0, 0, 0, -1.00000, 0, 0, 0, 0.500000, 0, 0, 0, 0, \
282 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.00000, 1.00000, 0, 0, 1.00000, 0, \
283 0, 0, 0, 0, 0, 0, 0, 0, 0.500000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
284 0, 0, 0, -1.00000, 0, 0, -1.00000, -1.00000, 0, 0, 0, 0, 0, 0, 0, 0, \
285 0, 0.500000, 0.500000, 0.250000, 0, -0.500000, 0.250000, 0, \
286 -0.500000, -0.750000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.125000, \
287 0, 0, 0.125000, 0, 0, 0.250000, 0.375000, 0.250000, 0, -0.125000, \
288 0.250000, 0, -0.125000, -0.250000, 0, 0.375000, 0.250000, 0, \
289 -0.125000, 0.250000, 0, -0.125000, -0.250000, 0, 0, 0, 0.125000, 0, \
290 0, 0.250000, 0, 0, 0.125000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.750000, \
291 0.250000, 0, -0.250000, 0.250000, 0, -0.250000, -0.750000, 0, 0, 0, \
292 0.250000, 0, 0, 0.125000, 0, 0, 0.125000, 0.125000, 0.0312500, 0, 0, \
293 0.0312500, 0, 0, -0.0937500, 0, 0.875000, 0.218750, 0, 0, 0.218750, \
294 0, 0, -0.656250, 0, 0, 0, 0.375000, 0, 0, 0.125000, 0, 0, 0, \
295 0.312500, 0, 0, -0.312500, 0, 0, -0.312500, -0.625000, 0, 0.187500, \
296 0, 0, -0.187500, 0, 0, -0.187500, -0.375000, 0, 0, 0, 0.250000, 0, 0, \
297 0, 0, 0, 0.250000, 0.250000, 0.250000, 0, -0.250000, 0.250000, 0, \
298 -0.250000, -0.250000, 0, 0.250000, 0.250000, 0, -0.250000, 0.250000, \
299 0, -0.250000, -0.250000, 0, 0, 0, 0, 0, 0, 0.250000, 0, 0, 0.250000
303 double basisCurls[] = {
304 0, -0.500000, 2.00000, 0, 0, 2.00000, -0.500000, 0, 2.00000, 0, \
305 0.500000, 0, 0, 0, 0, 0.500000, 0, 0, -0.500000, 0.500000, 0, 0, \
306 -0.500000, 0, 0.500000, 0, 0, 0.500000, -0.500000, 2.00000, 0.500000, \
307 0, 2.00000, 0, 0, 2.00000, -0.500000, 0.500000, 0, -0.500000, 0, 0, \
308 0, 0, 0, -0.500000, 0.500000, 0, 0, -0.500000, 0, 0.500000, 0, 0, 0, \
309 0, 2.00000, 0, 0.500000, 2.00000, -0.500000, 0.500000, 2.00000, 0, 0, \
310 0, 0, -0.500000, 0, 0.500000, -0.500000, 0, -0.500000, 0.500000, 0, \
311 0, -0.500000, 0, 0.500000, 0, 0, 0, -0.500000, 0, 0, 0, 0, -0.500000, \
312 0, 0, 0, 0.500000, 2.00000, 0, 0, 2.00000, 0.500000, 0, 2.00000, \
313 -0.500000, 0.500000, 0, 0, -0.500000, 0, 0.500000, 0, 0, 0.500000, \
314 -0.500000, 0, 0.500000, 0, 0, 0, 0, 0, -0.500000, 0.500000, 2.00000, \
315 -0.500000, 0, 2.00000, 0, 0, 2.00000, -0.500000, 0.500000, 0, 0, \
316 -0.500000, 0, 0.500000, 0, 0, 0, 0, 0, 0, 0.500000, 0, -0.500000, \
317 0.500000, 0, 0, 0, 2.00000, 0, -0.500000, 2.00000, 0.500000, \
318 -0.500000, 2.00000, -0.500000, 0.500000, 0, 0, -0.500000, 0, \
319 0.500000, 0, 0, 0.125000, -0.250000, 2.00000, 0.125000, 0.250000, \
320 2.00000, -0.375000, 0.250000, 2.00000, -0.125000, 0.250000, 0, \
321 -0.125000, -0.250000, 0, 0.375000, -0.250000, 0, -0.500000, 0.500000, \
322 0, 0, -0.500000, 0, 0.500000, 0, 0, 0.250000, -0.375000, 1.00000, \
323 0.250000, 0.125000, 1.00000, -0.250000, 0.125000, 1.00000, -0.250000, \
324 0.375000, 1.00000, -0.250000, -0.125000, 1.00000, 0.250000, \
325 -0.125000, 1.00000, -0.500000, 0.500000, 0, 0, -0.500000, 0, \
326 0.500000, 0, 0, 0.125000, -0.375000, 0, 0.125000, 0.125000, 0, \
327 -0.375000, 0.125000, 0, -0.125000, 0.375000, 2.00000, -0.125000, \
328 -0.125000, 2.00000, 0.375000, -0.125000, 2.00000, -0.500000, \
329 0.500000, 0, 0, -0.500000, 0, 0.500000, 0, 0, 0.125000, -0.500000, \
330 0.250000, 0.125000, 0, 0.250000, -0.375000, 0, 0.250000, -0.125000, \
331 0.500000, 1.75000, -0.125000, 0, 1.75000, 0.375000, 0, 1.75000, \
332 -0.500000, 0.500000, 0, 0, -0.500000, 0, 0.500000, 0, 0, 0, \
333 -0.250000, 1.25000, 0, 0.250000, 1.25000, -0.500000, 0.250000, \
334 1.25000, 0, 0.250000, 0.750000, 0, -0.250000, 0.750000, 0.500000, \
335 -0.250000, 0.750000, -0.500000, 0.500000, 0, 0, -0.500000, 0, \
336 0.500000, 0, 0, 0.250000, -0.250000, 1.00000, 0.250000, 0.250000, \
337 1.00000, -0.250000, 0.250000, 1.00000, -0.250000, 0.250000, 1.00000, \
338 -0.250000, -0.250000, 1.00000, 0.250000, -0.250000, 1.00000, \
339 -0.500000, 0.500000, 0, 0, -0.500000, 0, 0.500000, 0, 0
346 int numPoints = wedgeNodes.dimension(0);
353 vals.
resize(numFields, numPoints, spaceDim);
354 wedgeBasis.
getValues(vals, wedgeNodes, OPERATOR_VALUE);
355 for (
int i = 0; i < numFields; i++) {
356 for (
int j = 0; j < numPoints; j++) {
357 for (
int k = 0; k < spaceDim; k++) {
360 int l = k + i * spaceDim + j * spaceDim * numFields;
361 if (std::abs(vals(i,j,k) - basisValues[l]) > INTREPID_TOL) {
363 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
366 *outStream <<
" At multi-index { ";
367 *outStream << i <<
" ";*outStream << j <<
" ";*outStream << k <<
" ";
368 *outStream <<
"} computed value: " << vals(i,j,k)
369 <<
" but reference value: " << basisValues[l] <<
"\n";
376 vals.
resize(numFields, numPoints, spaceDim);
377 wedgeBasis.
getValues(vals, wedgeNodes, OPERATOR_CURL);
378 for (
int i = 0; i < numFields; i++) {
379 for (
int j = 0; j < numPoints; j++) {
380 for (
int k = 0; k < spaceDim; k++) {
383 int l = k + i * spaceDim + j * spaceDim * numFields;
384 if (std::abs(vals(i,j,k) - basisCurls[l]) > INTREPID_TOL) {
386 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
389 *outStream <<
" At multi-index { ";
390 *outStream << i <<
" ";*outStream << j <<
" ";*outStream << k <<
" ";
391 *outStream <<
"} computed curl component: " << vals(i,j,k)
392 <<
" but reference curl component: " << basisCurls[l] <<
"\n";
401 catch (
const std::logic_error & err) {
402 *outStream << err.what() <<
"\n\n";
407 std::cout <<
"End Result: TEST FAILED\n";
409 std::cout <<
"End Result: TEST PASSED\n";
412 std::cout.copyfmt(oldFormatState);
virtual const std::vector< int > & getDofTag(const int dofOrd)
DoF ordinal to DoF tag lookup.
virtual int getCardinality() const
Returns cardinality of the basis.
virtual const std::vector< std::vector< int > > & getAllDofTags()
Retrieves all DoF tags.
Header file for utility class to provide multidimensional containers.
Implementation of the default H(curl)-compatible FEM basis of degree 1 on Wedge cell.
void getValues(ArrayScalar &outputValues, const ArrayScalar &inputPoints, const EOperator operatorType) const
Evaluation of a FEM basis on a reference Wedge cell.
void resize(const int dim0)
Resizes FieldContainer to a rank-1 container with the specified dimension, initialized by 0...
virtual int getDofOrdinal(const int subcDim, const int subcOrd, const int subcDofOrd)
DoF tag to ordinal lookup.
virtual const shards::CellTopology getBaseCellTopology() const
Returns the base cell topology for which the basis is defined. See Shards documentation http://trilin...
Header file for the Intrepid::HCURL_WEDGE_I1_FEM class.