50 #include "Intrepid_HGRAD_LINE_Cn_FEM.hpp"
55 #include "Teuchos_oblackholestream.hpp"
56 #include "Teuchos_RCP.hpp"
57 #include "Teuchos_GlobalMPISession.hpp"
60 using namespace Intrepid;
62 #define INTREPID_TEST_COMMAND( S , throwCounter, nException ) \
68 catch (const std::logic_error & err) { \
70 *outStream << "Expected Error " << nException << " -------------------------------------------------------------\n"; \
71 *outStream << err.what() << '\n'; \
72 *outStream << "-------------------------------------------------------------------------------" << "\n\n"; \
77 int main(
int argc,
char *argv[]) {
79 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
83 int iprint = argc - 1;
84 Teuchos::RCP<std::ostream> outStream;
85 Teuchos::oblackholestream bhs;
87 outStream = Teuchos::rcp(&std::cout,
false);
89 outStream = Teuchos::rcp(&bhs,
false);
92 Teuchos::oblackholestream oldFormatState;
93 oldFormatState.copyfmt(std::cout);
96 <<
"===============================================================================\n" \
98 <<
"| Unit Test (Basis_HGRAD_LINE_Cn_FEM) |\n" \
100 <<
"| 1) Conversion of Dof tags into Dof ordinals and back |\n" \
101 <<
"| 2) Basis values for VALUE, GRAD, CURL, and Dk operators |\n" \
103 <<
"| Questions? Contact Pavel Bochev (pbboche@sandia.gov), |\n" \
104 <<
"| Denis Ridzal (dridzal@sandia.gov), |\n" \
105 <<
"| Kara Peterson (kjpeter@sandia.gov). |\n" \
107 <<
"| Intrepid's website: http://trilinos.sandia.gov/packages/intrepid |\n" \
108 <<
"| Trilinos website: http://trilinos.sandia.gov |\n" \
110 <<
"===============================================================================\n"\
111 <<
"| TEST 1: Basis creation, exception testing |\n"\
112 <<
"===============================================================================\n";
116 shards::CellTopology line(shards::getCellTopologyData< shards::Line<> >());
121 PointTools::getLattice<double,FieldContainer<double> >(pts,line,deg);
128 int throwCounter = 0;
131 int numIntervals = 100;
133 for (
int i=0; i<numIntervals+1; i++) {
134 lineNodes(i,0) = -1.0+(2.0*(double)i)/(double)numIntervals;
143 vals.
resize(lineBasis.getCardinality(), lineNodes.dimension(0) );
149 INTREPID_TEST_COMMAND( lineBasis.getDofOrdinal(2,0,0), throwCounter, nException );
151 INTREPID_TEST_COMMAND( lineBasis.getDofOrdinal(1,1,1), throwCounter, nException );
153 INTREPID_TEST_COMMAND( lineBasis.getDofOrdinal(1,0,7), throwCounter, nException );
155 INTREPID_TEST_COMMAND( lineBasis.getDofTag(6), throwCounter, nException );
157 INTREPID_TEST_COMMAND( lineBasis.getDofTag(-1), throwCounter, nException );
159 INTREPID_TEST_COMMAND( lineBasis.getDofTag(5), throwCounter, nException ); --nException;
161 #ifdef HAVE_INTREPID_DEBUG
165 INTREPID_TEST_COMMAND( lineBasis.getValues(vals, badPoints1, OPERATOR_VALUE), throwCounter, nException );
169 INTREPID_TEST_COMMAND( lineBasis.getValues(vals, badPoints2, OPERATOR_VALUE), throwCounter, nException );
173 INTREPID_TEST_COMMAND( lineBasis.getValues(badVals1, lineNodes, OPERATOR_VALUE), throwCounter, nException );
177 INTREPID_TEST_COMMAND( lineBasis.getValues(badVals2, lineNodes, OPERATOR_GRAD), throwCounter, nException );
180 INTREPID_TEST_COMMAND( lineBasis.getValues(badVals2, lineNodes, OPERATOR_D1), throwCounter, nException );
184 INTREPID_TEST_COMMAND( lineBasis.getValues(badVals3, lineNodes, OPERATOR_VALUE), throwCounter, nException );
188 INTREPID_TEST_COMMAND( lineBasis.getValues(badVals4, lineNodes, OPERATOR_VALUE), throwCounter, nException );
192 INTREPID_TEST_COMMAND( lineBasis.getValues(badVals5, lineNodes, OPERATOR_GRAD), throwCounter, nException );
197 INTREPID_TEST_COMMAND( lineBasis.getValues(goodVals2, lineNodes, OPERATOR_VALUE), throwCounter, nException ); --nException;
201 catch (
const std::logic_error & err) {
202 *outStream <<
"UNEXPECTED ERROR !!! ----------------------------------------------------------\n";
203 *outStream << err.what() <<
'\n';
204 *outStream <<
"-------------------------------------------------------------------------------" <<
"\n\n";
209 if (throwCounter != nException) {
211 *outStream << std::setw(70) <<
"FAILURE! Incorrect number of exceptions." <<
"\n";
216 <<
"===============================================================================\n" \
217 <<
"| TEST 2: correctness of basis function values |\n" \
218 <<
"===============================================================================\n";
219 outStream -> precision(20);
226 for (
int ordi=1; ordi <= maxorder; ordi++) {
228 PointTools::getLattice<double,FieldContainer<double> >(pts,line,ordi);
231 lineBasis.getValues(vals,pts,OPERATOR_VALUE);
232 for (
int i=0;i<lineBasis.getCardinality();i++) {
233 for (
int j=0;j<pts.dimension(0);j++) {
234 if ( i==j && std::abs( vals(i,j) - 1.0 ) > INTREPID_TOL ) {
236 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
237 *outStream <<
" Basis function " << i <<
" does not have unit value at its node\n";
239 if ( i!=j && std::abs( vals(i,j) ) > INTREPID_TOL ) {
241 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
242 *outStream <<
" Basis function " << i <<
" does not vanish at node " << j <<
"\n";
249 catch (
const std::logic_error & err) {
250 *outStream << err.what() <<
"\n\n";
255 std::cout <<
"End Result: TEST FAILED\n";
257 std::cout <<
"End Result: TEST PASSED\n";
260 std::cout.copyfmt(oldFormatState);
Implementation of the locally H(grad)-compatible FEM basis of variable order on the [-1...
Header file for utility class to provide multidimensional containers.
Header file for the abstract base class Intrepid::DefaultCubatureFactory.
void resize(const int dim0)
Resizes FieldContainer to a rank-1 container with the specified dimension, initialized by 0...