|
Intrepid
|
00001 // @HEADER 00002 // ************************************************************************ 00003 // 00004 // Intrepid Package 00005 // Copyright (2007) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // Redistribution and use in source and binary forms, with or without 00011 // modification, are permitted provided that the following conditions are 00012 // met: 00013 // 00014 // 1. Redistributions of source code must retain the above copyright 00015 // notice, this list of conditions and the following disclaimer. 00016 // 00017 // 2. Redistributions in binary form must reproduce the above copyright 00018 // notice, this list of conditions and the following disclaimer in the 00019 // documentation and/or other materials provided with the distribution. 00020 // 00021 // 3. Neither the name of the Corporation nor the names of the 00022 // contributors may be used to endorse or promote products derived from 00023 // this software without specific prior written permission. 00024 // 00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 // 00037 // Questions? Contact Pavel Bochev (pbboche@sandia.gov) 00038 // Denis Ridzal (dridzal@sandia.gov), or 00039 // Kara Peterson (kjpeter@sandia.gov) 00040 // 00041 // ************************************************************************ 00042 // @HEADER 00043 00044 00050 #include "Intrepid_FieldContainer.hpp" 00051 #include "Teuchos_oblackholestream.hpp" 00052 #include "Teuchos_RCP.hpp" 00053 #include "Teuchos_GlobalMPISession.hpp" 00054 #include "Intrepid_PointTools.hpp" 00055 #include "Intrepid_HGRAD_TRI_Cn_FEM.hpp" 00056 #include "Shards_CellTopology.hpp" 00057 00058 #include <iostream> 00059 using namespace Intrepid; 00060 00066 int main(int argc, char *argv[]) { 00067 00068 Teuchos::GlobalMPISession mpiSession(&argc, &argv); 00069 00070 // This little trick lets us print to std::cout only if a (dummy) command-line argument is provided. 00071 int iprint = argc - 1; 00072 00073 Teuchos::RCP<std::ostream> outStream; 00074 Teuchos::oblackholestream bhs; // outputs nothing 00075 00076 if (iprint > 0) 00077 outStream = Teuchos::rcp(&std::cout, false); 00078 else 00079 outStream = Teuchos::rcp(&bhs, false); 00080 00081 // Save the format state of the original std::cout. 00082 Teuchos::oblackholestream oldFormatState; 00083 oldFormatState.copyfmt(std::cout); 00084 00085 *outStream \ 00086 << "===============================================================================\n" \ 00087 << "| |\n" \ 00088 << "| Unit Test HGRAD_TRI_Cn_FEM |\n" \ 00089 << "| |\n" \ 00090 << "| 1) Tests triangular Lagrange basis |\n" \ 00091 << "| |\n" \ 00092 << "| Questions? Contact Pavel Bochev (pbboche@sandia.gov) or |\n" \ 00093 << "| Denis Ridzal (dridzal@sandia.gov) or |\n" \ 00094 << "| Robert Kirby (robert.c.kirby@ttu.edu) |\n" \ 00095 << "| |\n" \ 00096 << "| Intrepid's website: http://trilinos.sandia.gov/packages/intrepid |\n" \ 00097 << "| Trilinos website: http://trilinos.sandia.gov |\n" \ 00098 << "| |\n" \ 00099 << "===============================================================================\n"; 00100 00101 int errorFlag = 0; 00102 00103 // Let's instantiate a basis 00104 try { 00105 const int deg = 10; 00106 Basis_HGRAD_TRI_Cn_FEM<double,FieldContainer<double> > myBasis( deg , POINTTYPE_WARPBLEND ); 00107 00108 // Get a lattice 00109 const int np_lattice = PointTools::getLatticeSize( myBasis.getBaseCellTopology() , deg , 0 ); 00110 const int nbf = myBasis.getCardinality(); 00111 FieldContainer<double> lattice( np_lattice , 2 ); 00112 PointTools::getLattice<double,FieldContainer<double> >( lattice , 00113 myBasis.getBaseCellTopology() , 00114 deg , 00115 0 , 00116 POINTTYPE_WARPBLEND ); 00117 FieldContainer<double> vals( nbf , np_lattice ); 00118 00119 myBasis.getValues( vals , lattice , OPERATOR_VALUE ); 00120 00121 // test for Kronecker property 00122 for (int i=0;i<nbf;i++) { 00123 for (int j=0;j<np_lattice;j++) { 00124 if ( i==j && std::abs( vals(i,j) - 1.0 ) > INTREPID_TOL ) { 00125 errorFlag++; 00126 *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; 00127 *outStream << " Basis function " << i << " does not have unit value at its node\n"; 00128 } 00129 if ( i!=j && std::abs( vals(i,j) ) > INTREPID_TOL ) { 00130 errorFlag++; 00131 *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; 00132 *outStream << " Basis function " << i << " does not vanish at node " << j << "\n"; 00133 } 00134 } 00135 } 00136 } 00137 catch (std::exception err) { 00138 *outStream << err.what() << "\n\n"; 00139 errorFlag = -1000; 00140 } 00141 00142 try { 00143 const int deg = 3; 00144 Basis_HGRAD_TRI_Cn_FEM<double,FieldContainer<double> > myBasis( deg , POINTTYPE_WARPBLEND ); 00145 const std::vector<std::vector<std::vector<int> > >& dofdata = myBasis.getDofOrdinalData(); 00146 for (unsigned d=0;d<dofdata.size();d++) { 00147 std::cout << "Dimension " << d << "\n"; 00148 for (unsigned f=0;f<dofdata[d].size();f++) { 00149 std::cout << "\tFacet number " << f << "\n"; 00150 std::cout << "\t\tDOFS:\n"; 00151 for (unsigned n=0;n<dofdata[d][f].size();n++) { 00152 std::cout << "\t\t\t" << dofdata[d][f][n] << "\n"; 00153 } 00154 } 00155 } 00156 } 00157 catch (std::exception err) { 00158 *outStream << err.what() << "\n\n"; 00159 errorFlag = -1000; 00160 } 00161 00162 try { 00163 const int deg = 1; 00164 Basis_HGRAD_TRI_Cn_FEM<double,FieldContainer<double> > myBasis( deg , POINTTYPE_WARPBLEND ); 00165 00166 // Get a lattice 00167 const int np_lattice = PointTools::getLatticeSize( myBasis.getBaseCellTopology() , deg , 0 ); 00168 const int nbf = myBasis.getCardinality(); 00169 FieldContainer<double> lattice( np_lattice , 2 ); 00170 PointTools::getLattice<double,FieldContainer<double> >( lattice , 00171 myBasis.getBaseCellTopology() , 00172 deg , 00173 0 , 00174 POINTTYPE_WARPBLEND ); 00175 FieldContainer<double> vals( nbf , np_lattice , 2 ); 00176 00177 myBasis.getValues( vals , lattice , OPERATOR_CURL ); 00178 00179 std::cout << vals << std::endl; 00180 } 00181 catch (std::exception err) { 00182 *outStream << err.what() << "\n\n"; 00183 errorFlag = -1000; 00184 } 00185 00186 00187 if (errorFlag != 0) 00188 std::cout << "End Result: TEST FAILED\n"; 00189 else 00190 std::cout << "End Result: TEST PASSED\n"; 00191 00192 // reset format state of std::cout 00193 std::cout.copyfmt(oldFormatState); 00194 00195 return errorFlag; 00196 }
1.7.6.1