50 #include "Teuchos_oblackholestream.hpp" 51 #include "Teuchos_RCP.hpp" 52 #include "Teuchos_GlobalMPISession.hpp" 57 #define INTREPID_TEST_COMMAND( S , throwCounter, nException ) \ 63 catch (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_HGRAD_TET_COMP12_FEM) |\n" \
94 <<
"| 1) Evaluation of Basis Function Values |\n" \
96 <<
"| Questions? Contact Pavel Bochev (pbboche@sandia.gov), |\n" \
97 <<
"| Denis Ridzal (dridzal@sandia.gov), |\n" \
98 <<
"| Kara Peterson (kjpeter@sandia.gov), |\n" \
99 <<
"| Jake Ostien (jtostie@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, values |\n"\
106 <<
"===============================================================================\n";
118 tetNodes(0,0) = 0.0; tetNodes(0,1) = 0.0; tetNodes(0,2) = 0.0;
119 tetNodes(1,0) = 1.0; tetNodes(1,1) = 0.0; tetNodes(1,2) = 0.0;
120 tetNodes(2,0) = 0.0; tetNodes(2,1) = 1.0; tetNodes(2,2) = 0.0;
121 tetNodes(3,0) = 0.0; tetNodes(3,1) = 0.0; tetNodes(3,2) = 1.0;
122 tetNodes(4,0) = 0.5; tetNodes(4,1) = 0.0; tetNodes(4,2) = 0.0;
123 tetNodes(5,0) = 0.5; tetNodes(5,1) = 0.5; tetNodes(5,2) = 0.0;
124 tetNodes(6,0) = 0.0; tetNodes(6,1) = 0.5; tetNodes(6,2) = 0.0;
125 tetNodes(7,0) = 0.0; tetNodes(7,1) = 0.0; tetNodes(7,2) = 0.5;
126 tetNodes(8,0) = 0.5; tetNodes(8,1) = 0.0; tetNodes(8,2) = 0.5;
127 tetNodes(9,0) = 0.0; tetNodes(9,1) = 0.5; tetNodes(9,2) = 0.5;
130 tetPoints(0,0) = 0.25; tetPoints(0,1) = 0.25; tetPoints(0,2) = 0.25;
131 tetPoints(1,0) = 0.5; tetPoints(1,1) = (1./6.); tetPoints(1,2) = (1./6.);
132 tetPoints(2,0) = (1./6.); tetPoints(2,1) = 0.5; tetPoints(2,2) = (1./6.);
133 tetPoints(3,0) = (1./6.); tetPoints(3,1) = (1./6.); tetPoints(3,2) = 0.5;
134 tetPoints(4,0) = (1./6.); tetPoints(4,1) = (1./6.); tetPoints(4,2) = (1./6.);
137 outStream -> precision(20);
140 double nodalBasisValues[] = {
142 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
143 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
144 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
145 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
147 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0,
148 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0,
149 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0,
150 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
151 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0,
152 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0
154 double pointBasisValues[] = {
156 0.0, 0.0, 0.0, 0.0, 1./6., 1./6., 1./6., 1./6., 1./6., 1./6.,
158 0.0, 0.0, 0.0, 0.0, 1./3., 1./3., 0.0, 0.0, 1./3., 0.0,
160 0.0, 0.0, 0.0, 0.0, 0.0, 1./3., 1./3., 0.0, 0.0, 1./3.,
162 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1./3., 1./3., 1./3.,
164 0.0, 0.0, 0.0, 0.0, 1./3., 0.0, 1./3., 1./3., 0.0, 0.0
168 double pointBasisGrads[] = {
170 -0.25, -0.25, -0.25, 0.25, 0.00, 0.00, 0.00, 0.25, 0.0, 0.00, 0.0, 0.25, 0.0, -0.75, -0.75, \
171 0.75, 0.75, 0.00, -0.75, 0.00, -0.75, -0.75, -0.75, 0.0, 0.75, 0.0, 0.75, 0.0, 0.75, 0.75,
174 0.15, 0.15, 0.15, 1.45, 0.00, 0.00, 0.00, -0.15, 0.0, 0.00, 0.0, -0.15, -104./60., -2.15, -2.15, \
175 5./12., 2.15, 0.00, -17./60., 0.00, -0.15, -17./60., -0.15, 0.0, 5./12., 0.0, 2.15, -2./15., 0.15, 0.15,
178 0.15, 0.15, 0.15, -0.15, 0.0, 0.0, 0.0, 1.45, 0.0, 0.0, 0.0, -0.15, 0.0, -17./60., -0.15, \
179 2.15, 5./12., 0.0, -2.15, -104./60., -2.15, -0.15, -17./60., 0.0, 0.15, -2./15., 0.15, 0.0, 5./12., 2.15,
182 0.15, 0.15, 0.15, -0.15, 0.0, 0.0, 0.0, -0.15, 0.0, 0.0, 0.0, 1.45, 0.0, -0.15, -17./60., \
183 0.15, 0.15, -2./15., -0.15, 0.0, -17./60., -2.15, -2.15, -104./60., 2.15, 0.0, 5./12., 0.0, 2.15, 5./12.,
186 -1.45, -1.45, -1.45, -0.15, 0.0, 0.0, 0.0, -0.15, 0.0, 0.0, 0.0, -0.15, 104./60., -5./12., -5./12., \
187 17./60., 17./60., 2./15., -5./12., 104./60., -5./12., -5./12., -5./12., 104./60., 17./60., 2./15., 17./60., 2./15., 17./60., 17./60.
194 int numNodes = tetNodes.dimension(0);
201 vals.
resize(numFields, numNodes);
202 tetBasis.
getValues(vals, tetNodes, OPERATOR_VALUE);
204 for (
int i = 0; i < numFields; i++) {
205 for (
int j = 0; j < numNodes; j++) {
206 int l = i + j * numFields;
207 if (std::abs(vals(i,j) - nodalBasisValues[l]) > INTREPID_TOL) {
209 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
212 *outStream <<
" At multi-index { ";
213 *outStream << i <<
" ";*outStream << j <<
" ";
214 *outStream <<
"} computed value: " << vals(i,j)
215 <<
" but reference value: " << nodalBasisValues[l] <<
"\n";
222 vals.
resize(numFields, numPoints);
224 tetBasis.
getValues(vals, tetPoints, OPERATOR_VALUE);
226 for (
int i = 0; i < numFields; i++) {
227 for (
int j = 0; j < numPoints; j++) {
228 int l = i + j * numFields;
229 if (std::abs(vals(i,j) - pointBasisValues[l]) > INTREPID_TOL) {
231 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
234 *outStream <<
" At multi-index { ";
235 *outStream << i <<
" ";*outStream << j <<
" ";
236 *outStream <<
"} computed value: " << vals(i,j)
237 <<
" but reference value: " << pointBasisValues[l] <<
"\n";
244 vals.
resize(numFields, numPoints, spaceDim);
246 tetBasis.
getValues(vals, tetPoints, OPERATOR_GRAD);
248 for (
int i = 0; i < numFields; i++) {
249 for (
int j = 0; j < numPoints; j++) {
250 for (
int k = 0; k < spaceDim; k++) {
251 int l = k + i * spaceDim + j * spaceDim * numFields;
252 if (std::abs(vals(i,j,k) - pointBasisGrads[l]) > INTREPID_TOL) {
254 *outStream << std::setw(70) <<
"^^^^----FAILURE!" <<
"\n";
257 *outStream <<
" At multi-index { ";
258 *outStream << i <<
" ";*outStream << j <<
" ";*outStream << k <<
" ";
259 *outStream <<
"} computed grad component: " << vals(i,j,k)
260 <<
" but reference grad component: " << pointBasisGrads[l] <<
"\n";
267 catch (std::logic_error err) {
268 *outStream << err.what() <<
"\n\n";
274 std::cout <<
"End Result: TEST FAILED\n";
276 std::cout <<
"End Result: TEST PASSED\n";
279 std::cout.copyfmt(oldFormatState);
int main(int argc, char *argv[])
Performs a code-code comparison to FIAT for Nedelec bases on tets (values and curls) ...
virtual int getCardinality() const
Returns cardinality of the basis.
int dimension(const int whichDim) const
Returns the specified dimension.
Header file for utility class to provide multidimensional containers.
void resize(const int dim0)
Resizes FieldContainer to a rank-1 container with the specified dimension, initialized by 0...
void getValues(ArrayScalar &outputValues, const ArrayScalar &inputPoints, const EOperator operatorType) const
FEM basis evaluation on a reference Tetrahedron cell.
void initialize(const Scalar value=0)
Initializes a field container by assigning value to all its elements.
Header file for the Intrepid::HGRAD_TET_COMP12_FEM class.
virtual const shards::CellTopology getBaseCellTopology() const
Returns the base cell topology for which the basis is defined. See Shards documentation http://trilin...