Intrepid
http://trilinos.sandia.gov/packages/docs/r10.10/packages/intrepid/test/Discretization/Basis/HGRAD_QUAD_C1_FEM/test_02.cpp
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 
00049 #include "Intrepid_FieldContainer.hpp"
00050 #include "Intrepid_HGRAD_QUAD_C1_FEM.hpp"
00051 #include "Intrepid_DefaultCubatureFactory.hpp"
00052 #include "Intrepid_RealSpaceTools.hpp"
00053 #include "Intrepid_ArrayTools.hpp"
00054 #include "Intrepid_FunctionSpaceTools.hpp"
00055 #include "Intrepid_CellTools.hpp"
00056 #include "Teuchos_oblackholestream.hpp"
00057 #include "Teuchos_RCP.hpp"
00058 #include "Teuchos_GlobalMPISession.hpp"
00059 #include "Teuchos_SerialDenseMatrix.hpp"
00060 #include "Teuchos_SerialDenseVector.hpp"
00061 #include "Teuchos_LAPACK.hpp"
00062 
00063 using namespace std;
00064 using namespace Intrepid;
00065 
00066 void rhsFunc(FieldContainer<double> &, const FieldContainer<double> &, int, int);
00067 void neumann(FieldContainer<double>       & ,
00068              const FieldContainer<double> & ,
00069              const FieldContainer<double> & ,
00070              const shards::CellTopology   & ,
00071              int, int, int);
00072 void u_exact(FieldContainer<double> &, const FieldContainer<double> &, int, int);
00073 
00075 void rhsFunc(FieldContainer<double> & result,
00076              const FieldContainer<double> & points,
00077              int xd,
00078              int yd) {
00079 
00080   int x = 0, y = 1;
00081 
00082   // second x-derivatives of u
00083   if (xd > 1) {
00084     for (int cell=0; cell<result.dimension(0); cell++) {
00085       for (int pt=0; pt<result.dimension(1); pt++) {
00086         result(cell,pt) = - xd*(xd-1)*std::pow(points(cell,pt,x), xd-2) * std::pow(points(cell,pt,y), yd);
00087       }
00088     }
00089   }
00090 
00091   // second y-derivatives of u
00092   if (yd > 1) {
00093     for (int cell=0; cell<result.dimension(0); cell++) {
00094       for (int pt=0; pt<result.dimension(1); pt++) {
00095         result(cell,pt) -=  yd*(yd-1)*std::pow(points(cell,pt,y), yd-2) * std::pow(points(cell,pt,x), xd);
00096       }
00097     }
00098   }
00099 
00100   // add u
00101   for (int cell=0; cell<result.dimension(0); cell++) {
00102     for (int pt=0; pt<result.dimension(1); pt++) {
00103       result(cell,pt) +=  std::pow(points(cell,pt,x), xd) * std::pow(points(cell,pt,y), yd);
00104     }
00105   }
00106 
00107 }
00108 
00109 
00111 void neumann(FieldContainer<double>       & result,
00112              const FieldContainer<double> & points,
00113              const FieldContainer<double> & jacs,
00114              const shards::CellTopology   & parentCell,
00115              int sideOrdinal, int xd, int yd) {
00116 
00117   int x = 0, y = 1;
00118 
00119   int numCells  = result.dimension(0);
00120   int numPoints = result.dimension(1);
00121 
00122   FieldContainer<double> grad_u(numCells, numPoints, 2);
00123   FieldContainer<double> side_normals(numCells, numPoints, 2);
00124   FieldContainer<double> normal_lengths(numCells, numPoints);
00125 
00126   // first x-derivatives of u
00127   if (xd > 0) {
00128     for (int cell=0; cell<numCells; cell++) {
00129       for (int pt=0; pt<numPoints; pt++) {
00130         grad_u(cell,pt,x) = xd*std::pow(points(cell,pt,x), xd-1) * std::pow(points(cell,pt,y), yd);
00131       }
00132     }
00133   }
00134 
00135   // first y-derivatives of u
00136   if (yd > 0) {
00137     for (int cell=0; cell<numCells; cell++) {
00138       for (int pt=0; pt<numPoints; pt++) {
00139         grad_u(cell,pt,y) = yd*std::pow(points(cell,pt,y), yd-1) * std::pow(points(cell,pt,x), xd);
00140       }
00141     }
00142   }
00143   
00144   CellTools<double>::getPhysicalSideNormals(side_normals, jacs, sideOrdinal, parentCell);
00145 
00146   // scale normals
00147   RealSpaceTools<double>::vectorNorm(normal_lengths, side_normals, NORM_TWO);
00148   FunctionSpaceTools::scalarMultiplyDataData<double>(side_normals, normal_lengths, side_normals, true); 
00149 
00150   FunctionSpaceTools::dotMultiplyDataData<double>(result, grad_u, side_normals);
00151 
00152 }
00153 
00155 void u_exact(FieldContainer<double> & result, const FieldContainer<double> & points, int xd, int yd) {
00156   int x = 0, y = 1;
00157   for (int cell=0; cell<result.dimension(0); cell++) {
00158     for (int pt=0; pt<result.dimension(1); pt++) {
00159       result(cell,pt) = std::pow(points(pt,x), xd)*std::pow(points(pt,y), yd);
00160     }
00161   }
00162 }
00163 
00164 
00165 
00166 
00167 int main(int argc, char *argv[]) {
00168 
00169   Teuchos::GlobalMPISession mpiSession(&argc, &argv);
00170 
00171   // This little trick lets us print to std::cout only if
00172   // a (dummy) command-line argument is provided.
00173   int iprint     = argc - 1;
00174   Teuchos::RCP<std::ostream> outStream;
00175   Teuchos::oblackholestream bhs; // outputs nothing
00176   if (iprint > 0)
00177     outStream = Teuchos::rcp(&std::cout, false);
00178   else
00179     outStream = Teuchos::rcp(&bhs, false);
00180 
00181   // Save the format state of the original std::cout.
00182   Teuchos::oblackholestream oldFormatState;
00183   oldFormatState.copyfmt(std::cout);
00184 
00185   *outStream \
00186     << "===============================================================================\n" \
00187     << "|                                                                             |\n" \
00188     << "|                    Unit Test (Basis_HGRAD_QUAD_C1_FEM)                      |\n" \
00189     << "|                                                                             |\n" \
00190     << "|     1) Patch test involving mass and stiffness matrices,                    |\n" \
00191     << "|        for the Neumann problem on a physical parallelogram                  |\n" \
00192     << "|        AND a reference quad Omega with boundary Gamma.                      |\n" \
00193     << "|                                                                             |\n" \
00194     << "|        - div (grad u) + u = f  in Omega,  (grad u) . n = g  on Gamma        |\n" \
00195     << "|                                                                             |\n" \
00196     << "|        For a generic parallelogram, the basis recovers a complete           |\n" \
00197     << "|        polynomial space of order 1. On a (scaled and/or translated)         |\n" \
00198     << "|        reference quad, the basis recovers a complete tensor product         |\n" \
00199     << "|        space of order 1 (i.e. incl. the xy term).                           |\n" \
00200     << "|                                                                             |\n" \
00201     << "|  Questions? Contact  Pavel Bochev  (pbboche@sandia.gov),                    |\n" \
00202     << "|                      Denis Ridzal  (dridzal@sandia.gov),                    |\n" \
00203     << "|                      Kara Peterson (kjpeter@sandia.gov).                    |\n" \
00204     << "|                                                                             |\n" \
00205     << "|  Intrepid's website: http://trilinos.sandia.gov/packages/intrepid           |\n" \
00206     << "|  Trilinos website:   http://trilinos.sandia.gov                             |\n" \
00207     << "|                                                                             |\n" \
00208     << "===============================================================================\n"\
00209     << "| TEST 1: Patch test                                                          |\n"\
00210     << "===============================================================================\n";
00211 
00212   
00213   int errorFlag = 0;
00214 
00215   outStream -> precision(16);
00216 
00217 
00218   try {
00219 
00220     int max_order = 1;                                                                    // max total order of polynomial solution
00221     DefaultCubatureFactory<double>  cubFactory;                                           // create cubature factory
00222     shards::CellTopology cell(shards::getCellTopologyData< shards::Quadrilateral<> >());  // create parent cell topology
00223     shards::CellTopology side(shards::getCellTopologyData< shards::Line<> >());           // create relevant subcell (side) topology
00224     int cellDim = cell.getDimension();
00225     int sideDim = side.getDimension();
00226 
00227     // Define array containing points at which the solution is evaluated, in reference cell.
00228     int numIntervals = 10;
00229     int numInterpPoints = (numIntervals + 1)*(numIntervals + 1);
00230     FieldContainer<double> interp_points_ref(numInterpPoints, 2);
00231     int counter = 0;
00232     for (int j=0; j<=numIntervals; j++) {
00233       for (int i=0; i<=numIntervals; i++) {
00234         interp_points_ref(counter,0) = i*(2.0/numIntervals)-1.0;
00235         interp_points_ref(counter,1) = j*(2.0/numIntervals)-1.0;
00236         counter++;
00237       }
00238     }
00239 
00240     /* Parent cell definition. */
00241     FieldContainer<double> cell_nodes[2];
00242     cell_nodes[0].resize(1, 4, cellDim);
00243     cell_nodes[1].resize(1, 4, cellDim);
00244 
00245     // Generic parallelogram.
00246     cell_nodes[0](0, 0, 0) = -5.0;
00247     cell_nodes[0](0, 0, 1) = -1.0;
00248     cell_nodes[0](0, 1, 0) = 4.0;
00249     cell_nodes[0](0, 1, 1) = 1.0;
00250     cell_nodes[0](0, 2, 0) = 8.0;
00251     cell_nodes[0](0, 2, 1) = 3.0;
00252     cell_nodes[0](0, 3, 0) = -1.0;
00253     cell_nodes[0](0, 3, 1) = 1.0;
00254     // Reference quad. 
00255     cell_nodes[1](0, 0, 0) = -1.0;
00256     cell_nodes[1](0, 0, 1) = -1.0;
00257     cell_nodes[1](0, 1, 0) = 1.0;
00258     cell_nodes[1](0, 1, 1) = -1.0;
00259     cell_nodes[1](0, 2, 0) = 1.0;
00260     cell_nodes[1](0, 2, 1) = 1.0;
00261     cell_nodes[1](0, 3, 0) = -1.0;
00262     cell_nodes[1](0, 3, 1) = 1.0;
00263 
00264     std::stringstream mystream[2];
00265     mystream[0].str("\n>> Now testing basis on a generic parallelogram ...\n");
00266     mystream[1].str("\n>> Now testing basis on the reference quad ...\n");
00267 
00268     for (int pcell = 0; pcell < 2; pcell++) {
00269       *outStream << mystream[pcell].str();
00270       FieldContainer<double> interp_points(1, numInterpPoints, cellDim);
00271       CellTools<double>::mapToPhysicalFrame(interp_points, interp_points_ref, cell_nodes[pcell], cell);
00272       interp_points.resize(numInterpPoints, cellDim);
00273 
00274       for (int x_order=0; x_order <= max_order; x_order++) {
00275         int max_y_order = max_order;
00276         if (pcell == 0) {
00277           max_y_order -= x_order;
00278         }
00279         for (int y_order=0; y_order <= max_y_order; y_order++) {
00280 
00281           // evaluate exact solution
00282           FieldContainer<double> exact_solution(1, numInterpPoints);
00283           u_exact(exact_solution, interp_points, x_order, y_order);
00284 
00285           int basis_order = 1;
00286 
00287           // set test tolerance
00288           double zero = basis_order*basis_order*100*INTREPID_TOL;
00289 
00290           //create basis
00291           Teuchos::RCP<Basis<double,FieldContainer<double> > > basis =
00292             Teuchos::rcp(new Basis_HGRAD_QUAD_C1_FEM<double,FieldContainer<double> >() );
00293           int numFields = basis->getCardinality();
00294 
00295           // create cubatures
00296           Teuchos::RCP<Cubature<double> > cellCub = cubFactory.create(cell, 2*basis_order);
00297           Teuchos::RCP<Cubature<double> > sideCub = cubFactory.create(side, 2*basis_order);
00298           int numCubPointsCell = cellCub->getNumPoints();
00299           int numCubPointsSide = sideCub->getNumPoints();
00300 
00301           /* Computational arrays. */
00302           /* Section 1: Related to parent cell integration. */
00303           FieldContainer<double> cub_points_cell(numCubPointsCell, cellDim);
00304           FieldContainer<double> cub_points_cell_physical(1, numCubPointsCell, cellDim);
00305           FieldContainer<double> cub_weights_cell(numCubPointsCell);
00306           FieldContainer<double> jacobian_cell(1, numCubPointsCell, cellDim, cellDim);
00307           FieldContainer<double> jacobian_inv_cell(1, numCubPointsCell, cellDim, cellDim);
00308           FieldContainer<double> jacobian_det_cell(1, numCubPointsCell);
00309           FieldContainer<double> weighted_measure_cell(1, numCubPointsCell);
00310 
00311           FieldContainer<double> value_of_basis_at_cub_points_cell(numFields, numCubPointsCell);
00312           FieldContainer<double> transformed_value_of_basis_at_cub_points_cell(1, numFields, numCubPointsCell);
00313           FieldContainer<double> weighted_transformed_value_of_basis_at_cub_points_cell(1, numFields, numCubPointsCell);
00314           FieldContainer<double> grad_of_basis_at_cub_points_cell(numFields, numCubPointsCell, cellDim);
00315           FieldContainer<double> transformed_grad_of_basis_at_cub_points_cell(1, numFields, numCubPointsCell, cellDim);
00316           FieldContainer<double> weighted_transformed_grad_of_basis_at_cub_points_cell(1, numFields, numCubPointsCell, cellDim);
00317           FieldContainer<double> fe_matrix(1, numFields, numFields);
00318 
00319           FieldContainer<double> rhs_at_cub_points_cell_physical(1, numCubPointsCell);
00320           FieldContainer<double> rhs_and_soln_vector(1, numFields);
00321 
00322           /* Section 2: Related to subcell (side) integration. */
00323           unsigned numSides = 4;
00324           FieldContainer<double> cub_points_side(numCubPointsSide, sideDim);
00325           FieldContainer<double> cub_weights_side(numCubPointsSide);
00326           FieldContainer<double> cub_points_side_refcell(numCubPointsSide, cellDim);
00327           FieldContainer<double> cub_points_side_physical(1, numCubPointsSide, cellDim);
00328           FieldContainer<double> jacobian_side_refcell(1, numCubPointsSide, cellDim, cellDim);
00329           FieldContainer<double> jacobian_det_side_refcell(1, numCubPointsSide);
00330           FieldContainer<double> weighted_measure_side_refcell(1, numCubPointsSide);
00331 
00332           FieldContainer<double> value_of_basis_at_cub_points_side_refcell(numFields, numCubPointsSide);
00333           FieldContainer<double> transformed_value_of_basis_at_cub_points_side_refcell(1, numFields, numCubPointsSide);
00334           FieldContainer<double> weighted_transformed_value_of_basis_at_cub_points_side_refcell(1, numFields, numCubPointsSide);
00335           FieldContainer<double> neumann_data_at_cub_points_side_physical(1, numCubPointsSide);
00336           FieldContainer<double> neumann_fields_per_side(1, numFields);
00337 
00338           /* Section 3: Related to global interpolant. */
00339           FieldContainer<double> value_of_basis_at_interp_points(numFields, numInterpPoints);
00340           FieldContainer<double> transformed_value_of_basis_at_interp_points(1, numFields, numInterpPoints);
00341           FieldContainer<double> interpolant(1, numInterpPoints);
00342 
00343           FieldContainer<int> ipiv(numFields);
00344 
00345 
00346 
00347           /******************* START COMPUTATION ***********************/
00348 
00349           // get cubature points and weights
00350           cellCub->getCubature(cub_points_cell, cub_weights_cell);
00351 
00352           // compute geometric cell information
00353           CellTools<double>::setJacobian(jacobian_cell, cub_points_cell, cell_nodes[pcell], cell);
00354           CellTools<double>::setJacobianInv(jacobian_inv_cell, jacobian_cell);
00355           CellTools<double>::setJacobianDet(jacobian_det_cell, jacobian_cell);
00356 
00357           // compute weighted measure
00358           FunctionSpaceTools::computeCellMeasure<double>(weighted_measure_cell, jacobian_det_cell, cub_weights_cell);
00359 
00361           // Computing mass matrices:
00362           // tabulate values of basis functions at (reference) cubature points
00363           basis->getValues(value_of_basis_at_cub_points_cell, cub_points_cell, OPERATOR_VALUE);
00364 
00365           // transform values of basis functions
00366           FunctionSpaceTools::HGRADtransformVALUE<double>(transformed_value_of_basis_at_cub_points_cell,
00367                                                           value_of_basis_at_cub_points_cell);
00368 
00369           // multiply with weighted measure
00370           FunctionSpaceTools::multiplyMeasure<double>(weighted_transformed_value_of_basis_at_cub_points_cell,
00371                                                       weighted_measure_cell,
00372                                                       transformed_value_of_basis_at_cub_points_cell);
00373 
00374           // compute mass matrices
00375           FunctionSpaceTools::integrate<double>(fe_matrix,
00376                                                 transformed_value_of_basis_at_cub_points_cell,
00377                                                 weighted_transformed_value_of_basis_at_cub_points_cell,
00378                                                 COMP_BLAS);
00380 
00382           // Computing stiffness matrices:
00383           // tabulate gradients of basis functions at (reference) cubature points
00384           basis->getValues(grad_of_basis_at_cub_points_cell, cub_points_cell, OPERATOR_GRAD);
00385 
00386           // transform gradients of basis functions
00387           FunctionSpaceTools::HGRADtransformGRAD<double>(transformed_grad_of_basis_at_cub_points_cell,
00388                                                          jacobian_inv_cell,
00389                                                          grad_of_basis_at_cub_points_cell);
00390 
00391           // multiply with weighted measure
00392           FunctionSpaceTools::multiplyMeasure<double>(weighted_transformed_grad_of_basis_at_cub_points_cell,
00393                                                       weighted_measure_cell,
00394                                                       transformed_grad_of_basis_at_cub_points_cell);
00395 
00396           // compute stiffness matrices and sum into fe_matrix
00397           FunctionSpaceTools::integrate<double>(fe_matrix,
00398                                                 transformed_grad_of_basis_at_cub_points_cell,
00399                                                 weighted_transformed_grad_of_basis_at_cub_points_cell,
00400                                                 COMP_BLAS,
00401                                                 true);
00403 
00405           // Computing RHS contributions:
00406           // map cell (reference) cubature points to physical space
00407           CellTools<double>::mapToPhysicalFrame(cub_points_cell_physical, cub_points_cell, cell_nodes[pcell], cell);
00408 
00409           // evaluate rhs function
00410           rhsFunc(rhs_at_cub_points_cell_physical, cub_points_cell_physical, x_order, y_order);
00411 
00412           // compute rhs
00413           FunctionSpaceTools::integrate<double>(rhs_and_soln_vector,
00414                                                 rhs_at_cub_points_cell_physical,
00415                                                 weighted_transformed_value_of_basis_at_cub_points_cell,
00416                                                 COMP_BLAS);
00417 
00418           // compute neumann b.c. contributions and adjust rhs
00419           sideCub->getCubature(cub_points_side, cub_weights_side);
00420           for (unsigned i=0; i<numSides; i++) {
00421             // compute geometric cell information
00422             CellTools<double>::mapToReferenceSubcell(cub_points_side_refcell, cub_points_side, sideDim, (int)i, cell);
00423             CellTools<double>::setJacobian(jacobian_side_refcell, cub_points_side_refcell, cell_nodes[pcell], cell);
00424             CellTools<double>::setJacobianDet(jacobian_det_side_refcell, jacobian_side_refcell);
00425 
00426             // compute weighted edge measure
00427             FunctionSpaceTools::computeEdgeMeasure<double>(weighted_measure_side_refcell,
00428                                                            jacobian_side_refcell,
00429                                                            cub_weights_side,
00430                                                            i,
00431                                                            cell);
00432 
00433             // tabulate values of basis functions at side cubature points, in the reference parent cell domain
00434             basis->getValues(value_of_basis_at_cub_points_side_refcell, cub_points_side_refcell, OPERATOR_VALUE);
00435             // transform
00436             FunctionSpaceTools::HGRADtransformVALUE<double>(transformed_value_of_basis_at_cub_points_side_refcell,
00437                                                             value_of_basis_at_cub_points_side_refcell);
00438 
00439             // multiply with weighted measure
00440             FunctionSpaceTools::multiplyMeasure<double>(weighted_transformed_value_of_basis_at_cub_points_side_refcell,
00441                                                         weighted_measure_side_refcell,
00442                                                         transformed_value_of_basis_at_cub_points_side_refcell);
00443 
00444             // compute Neumann data
00445             // map side cubature points in reference parent cell domain to physical space
00446             CellTools<double>::mapToPhysicalFrame(cub_points_side_physical, cub_points_side_refcell, cell_nodes[pcell], cell);
00447             // now compute data
00448             neumann(neumann_data_at_cub_points_side_physical, cub_points_side_physical, jacobian_side_refcell,
00449                     cell, (int)i, x_order, y_order);
00450 
00451             FunctionSpaceTools::integrate<double>(neumann_fields_per_side,
00452                                                   neumann_data_at_cub_points_side_physical,
00453                                                   weighted_transformed_value_of_basis_at_cub_points_side_refcell,
00454                                                   COMP_BLAS);
00455 
00456             // adjust RHS
00457             RealSpaceTools<double>::add(rhs_and_soln_vector, neumann_fields_per_side);;
00458           }
00460 
00462           // Solution of linear system:
00463           int info = 0;
00464           Teuchos::LAPACK<int, double> solver;
00465           solver.GESV(numFields, 1, &fe_matrix[0], numFields, &ipiv(0), &rhs_and_soln_vector[0], numFields, &info);
00467 
00469           // Building interpolant:
00470           // evaluate basis at interpolation points
00471           basis->getValues(value_of_basis_at_interp_points, interp_points_ref, OPERATOR_VALUE);
00472           // transform values of basis functions
00473           FunctionSpaceTools::HGRADtransformVALUE<double>(transformed_value_of_basis_at_interp_points,
00474                                                           value_of_basis_at_interp_points);
00475           FunctionSpaceTools::evaluate<double>(interpolant, rhs_and_soln_vector, transformed_value_of_basis_at_interp_points);
00477 
00478           /******************* END COMPUTATION ***********************/
00479       
00480           RealSpaceTools<double>::subtract(interpolant, exact_solution);
00481 
00482           *outStream << "\nRelative norm-2 error between exact solution polynomial of order ("
00483                      << x_order << ", " << y_order << ") and finite element interpolant of order " << basis_order << ": "
00484                      << RealSpaceTools<double>::vectorNorm(&interpolant[0], interpolant.dimension(1), NORM_TWO) /
00485                         RealSpaceTools<double>::vectorNorm(&exact_solution[0], exact_solution.dimension(1), NORM_TWO) << "\n";
00486 
00487           if (RealSpaceTools<double>::vectorNorm(&interpolant[0], interpolant.dimension(1), NORM_TWO) /
00488               RealSpaceTools<double>::vectorNorm(&exact_solution[0], exact_solution.dimension(1), NORM_TWO) > zero) {
00489             *outStream << "\n\nPatch test failed for solution polynomial order ("
00490                        << x_order << ", " << y_order << ") and basis order " << basis_order << "\n\n";
00491             errorFlag++;
00492           }
00493         } // end for y_order
00494       } // end for x_order
00495     } // end for pcell
00496 
00497   }
00498   // Catch unexpected errors
00499   catch (std::logic_error err) {
00500     *outStream << err.what() << "\n\n";
00501     errorFlag = -1000;
00502   };
00503 
00504   if (errorFlag != 0)
00505     std::cout << "End Result: TEST FAILED\n";
00506   else
00507     std::cout << "End Result: TEST PASSED\n";
00508 
00509   // reset format state of std::cout
00510   std::cout.copyfmt(oldFormatState);
00511 
00512   return errorFlag;
00513 }