// @HEADER // ***************************************************************************** // Intrepid2 Package // // Copyright 2007 NTESS and the Intrepid2 contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER /** \file \brief Test interpolation and projection capabilities for quadrilateral elements The test considers two quadrilaterals in the physical space sharing a common face. In order to test significant configurations, we consider 4 rotations of the reference quadrilateral to the first (physical) quadrilateral, so that the common face is mapped from all the 4 sides of the reference quadrilateral. Then, for each of the mappings, the global ids of the vertices of the common side are permuted (2 permutations). The test considers HGRAD, HCURL, HDIV and HVOL, of different degree, and for each of them checks that the Lagrangian interpolation, the interpolation-based projection, and the L2 projection, reproduce the target function to round-off errors when the target function is in the corresponding finite element space. Also, for the Lagrangian Interpolations, it checks that: 1. that the Kronecker property holds for the oriented basis evaluated at the oriented DOF coordinates. 2. that the basis coefficients located at the common faces/edges are the same when computed on the first and second quadrilateral. \author Created by Mauro Perego */ #include "Intrepid2_config.h" #ifdef HAVE_INTREPID2_DEBUG #define INTREPID2_TEST_FOR_DEBUG_ABORT_OVERRIDE_TO_CONTINUE #endif #include "Intrepid2_Orientation.hpp" #include "Intrepid2_OrientationTools.hpp" #include "Intrepid2_ProjectionTools.hpp" #include "Intrepid2_HVOL_C0_FEM.hpp" #include "Intrepid2_HGRAD_QUAD_C1_FEM.hpp" #include "Intrepid2_HGRAD_QUAD_C2_FEM.hpp" #include "Intrepid2_HGRAD_QUAD_Cn_FEM.hpp" #include "Intrepid2_HVOL_QUAD_Cn_FEM.hpp" #include "Intrepid2_HCURL_QUAD_In_FEM.hpp" #include "Intrepid2_PointTools.hpp" #include "Intrepid2_CellTools.hpp" #include "Intrepid2_FunctionSpaceTools.hpp" #include "Intrepid2_LagrangianInterpolation.hpp" #include "Teuchos_oblackholestream.hpp" #include "Teuchos_RCP.hpp" #include #include #include #include namespace Intrepid2 { namespace Test { #define INTREPID2_TEST_ERROR_EXPECTED( S ) \ try { \ ++nthrow; \ S ; \ } \ catch (std::exception &err) { \ ++ncatch; \ *outStream << "Expected Error ----------------------------------------------------------------\n"; \ *outStream << err.what() << '\n'; \ *outStream << "-------------------------------------------------------------------------------" << "\n\n"; \ } template int InterpolationProjectionQuad(const bool verbose) { using ExecSpaceType = typename DeviceType::execution_space; using MemSpaceType = typename DeviceType::memory_space; using DynRankView = Kokkos::DynRankView; #define ConstructWithLabel(obj, ...) obj(#obj, __VA_ARGS__) Teuchos::RCP outStream; Teuchos::oblackholestream bhs; // outputs nothing if (verbose) outStream = Teuchos::rcp(&std::cout, false); else outStream = Teuchos::rcp(&bhs, false); Teuchos::oblackholestream oldFormatState; oldFormatState.copyfmt(std::cout); using HostSpaceType = Kokkos::DefaultHostExecutionSpace; using DynRankViewIntHost = Kokkos::DynRankView; *outStream << "DeviceSpace:: "; ExecSpaceType().print_configuration(*outStream, false); *outStream << "HostSpace:: "; HostSpaceType().print_configuration(*outStream, false); *outStream << "\n"; int errorFlag = 0; const ValueType tol = tolerence(); //target functions and their derivatives struct Fun { ValueType KOKKOS_INLINE_FUNCTION operator()(const ordinal_type& degree, const ValueType& x, const ValueType& y) { return std::pow(x+y,degree-1)*(x+y-2); } }; struct FunDiv { ValueType KOKKOS_INLINE_FUNCTION operator()(const ordinal_type& degree, const ValueType& x, const ValueType& y, const int comp) { ValueType a = std::pow(x-y, degree-1); ValueType f0 = 3; ValueType f1 = std::pow(y, degree-1); //fun = f + a x switch (comp) { case 0: return f0 + a*x; case 1: return f1 + a*y; default: return 0; } } }; struct FunCurl { ValueType KOKKOS_INLINE_FUNCTION operator()(const ordinal_type& degree, const ValueType& x, const ValueType& y, const int comp) { ValueType a = std::pow(x-1, degree-1); ValueType f0 = 3; ValueType f1 = std::pow(y, degree-1); //fun = f + a \times x switch (comp) { case 0: return f0 + -a*y; case 1: return f1 + a*x; default: return 0; } } }; using edgeType = std::array; using ct = CellTools; using ots = OrientationTools; using fst = FunctionSpaceTools; using pts = ProjectionTools; using li = LagrangianInterpolation; using ProjStruct = ProjectionStruct; using lt = LagrangianTools; using basisType = Basis; constexpr ordinal_type dim = 2; constexpr ordinal_type numCells = 2; constexpr ordinal_type numElemVertexes = 4; constexpr ordinal_type numTotalVertexes = 6; ValueType vertices_orig[numTotalVertexes][dim] = {{-1,-1},{1,-1},{1,1},{-1,1}, {-1,2},{1,2}}; ordinal_type cells_orig[numCells][numElemVertexes] = {{0,1,2,3},{2,3,4,5}}; edgeType common_edge = {{2,3}}; ordinal_type cells_rotated[numCells][numElemVertexes]; const ordinal_type max_degree = 4; using CG_NBasis = NodalBasisFamily; using CG_DNBasis = DerivedNodalBasisFamily; std::vector basis_set; shards::CellTopology cellTopo(shards::getCellTopologyData >()); ordinal_type numNodesPerElem = cellTopo.getNodeCount(); *outStream << "===============================================================================\n" << "| |\n" << "| Test 1 (Orientation - HGRAD) |\n" << "| |\n" << "===============================================================================\n"; try { //reordering of nodes to explore different orientations ordinal_type reorder[numTotalVertexes] = {0,1,2,3,4,5}; do { ordinal_type orderback[numTotalVertexes]; for(ordinal_type i=0;i elemOrts("elemOrts", numCells); ots::getOrientation(elemOrts, elemNodes, cellTopo); for (ordinal_type degree=1; degree <= max_degree; degree++) { basis_set.clear(); if(degree==1) basis_set.push_back(new Basis_HGRAD_QUAD_C1_FEM()); if(degree==2) basis_set.push_back(new Basis_HGRAD_QUAD_C2_FEM()); basis_set.push_back(new typename CG_NBasis::HGRAD_QUAD(degree,POINTTYPE_WARPBLEND)); basis_set.push_back(new typename CG_DNBasis::HGRAD_QUAD(degree,POINTTYPE_EQUISPACED)); for (auto basisPtr:basis_set) { auto name = basisPtr->getName(); *outStream << " " << name << ": " << degree << std::endl; ordinal_type basisCardinality = basisPtr->getCardinality(); //compute DofCoords Oriented DynRankView ConstructWithLabel(dofCoords, basisCardinality, dim); DynRankView ConstructWithLabel(physDofCoords, numCells, basisCardinality, dim); DynRankView ConstructWithLabel(funAtDofCoords, numCells, basisCardinality); DynRankView ConstructWithLabel(basisCoeffsLI, numCells, basisCardinality); //compute Lagrangian Interpolation of fun { basisPtr->getDofCoords(dofCoords); //Compute physical Dof Coordinates DynRankView ConstructWithLabel(linearBasisValuesAtDofCoords, numNodesPerElem, basisCardinality); Basis_HGRAD_QUAD_C1_FEM linearBasis; linearBasis.getValues(linearBasisValuesAtDofCoords,dofCoords); Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &i) { Fun fun; for(ordinal_type j=0; jgetValues(outView, inView); } // modify basis values to account for orientations ots::modifyBasisByOrientation(basisValuesAtDofCoordsOriented, basisValuesAtDofCoords, elemOrts, basisPtr); auto hostBasisValues = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), basisValuesAtDofCoordsOriented); auto hostDofCoeffsPhys = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), dofCoeffsPhys); ExecSpaceType().fence(); for(ordinal_type i=0; i 100*tol ) { errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << " Basis function " << k << " of cell " << i << " does not have unit value at its node (" << dofValue <<")\n"; } if ( k!=j && std::abs( dofValue ) > tol ) { errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << " Basis function " << k << " of cell " << i << " does not vanish at node " << j << "(" << dofValue <<")\n"; } } } } } //check that fun values are consistent on common edges dofs auto hostBasisCoeffsLI = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), basisCoeffsLI); { bool areDifferent(false); auto numEdgeDOFs = basisPtr->getDofCount(1,0); for(ordinal_type j=0;jgetDofOrdinal(1,edgeIndex[0],j)) - hostBasisCoeffsLI(1,basisPtr->getDofOrdinal(1,edgeIndex[1],j))) > 10*tol; } if(areDifferent) { errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "Function DOFs on common edge computed using Quad 0 basis functions are not consistent with those computed using Quad 1\n"; *outStream << "Function DOFs for Quad 0 are:"; for(ordinal_type j=0;jgetDofOrdinal(1,edgeIndex[0],j)); *outStream << "\nFunction DOFs for Quad 1 are:"; for(ordinal_type j=0;jgetDofOrdinal(1,edgeIndex[1],j)); *outStream << std::endl; } } //check that fun values at reference points coincide with those computed using basis functions DynRankView ConstructWithLabel(basisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality); DynRankView ConstructWithLabel(transformedBasisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality); DynRankView basisValuesAtDofCoords("inValues", basisCardinality, basisCardinality); basisPtr->getValues(basisValuesAtDofCoords, dofCoords); // modify basis values to account for orientations ots::modifyBasisByOrientation(basisValuesAtDofCoordsOriented, basisValuesAtDofCoords, elemOrts, basisPtr); // transform basis (pullback) fst::HGRADtransformVALUE(transformedBasisValuesAtDofCoordsOriented, basisValuesAtDofCoordsOriented); DynRankView ConstructWithLabel(funAtDofCoordsOriented, numCells, basisCardinality); Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &i) { for(ordinal_type j=0; j100*tol) { errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "Function values at reference points differ from those computed using basis functions of Quad " << i << "\n"; *outStream << "Function values at reference points are:\n"; for(ordinal_type j=0; jgetDegree()),targetDerivCubDegree(basisPtr->getDegree()); ProjStruct projStruct; projStruct.createHGradProjectionStruct(basisPtr, targetCubDegree, targetDerivCubDegree); auto evaluationPoints = projStruct.getAllEvalPoints(); auto evaluationGradPoints = projStruct.getAllDerivEvalPoints(); ordinal_type numPoints = evaluationPoints.extent(0), numGradPoints = evaluationGradPoints.extent(0); DynRankView ConstructWithLabel(targetAtEvalPoints, numCells, numPoints); DynRankView ConstructWithLabel(targetGradAtEvalPoints, numCells, numGradPoints, dim); DynRankView ConstructWithLabel(hgradBasisAtEvaluationPoints, numCells, basisCardinality , numPoints); DynRankView ConstructWithLabel(hgradBasisAtEvaluationPointsNonOriented, basisCardinality , numPoints); basisPtr->getValues(hgradBasisAtEvaluationPointsNonOriented, evaluationPoints, OPERATOR_VALUE); ots::modifyBasisByOrientation(hgradBasisAtEvaluationPoints, hgradBasisAtEvaluationPointsNonOriented, elemOrts, basisPtr); DynRankView ConstructWithLabel(gradOfHGradBasisAtEvaluationPoints, numCells, basisCardinality , numGradPoints, dim); if(numGradPoints>0) { DynRankView ConstructWithLabel(gradOfHGradBasisAtEvaluationPointsNonOriented, basisCardinality , numGradPoints, dim); basisPtr->getValues(gradOfHGradBasisAtEvaluationPointsNonOriented,evaluationGradPoints, OPERATOR_GRAD); ots::modifyBasisByOrientation(gradOfHGradBasisAtEvaluationPoints, gradOfHGradBasisAtEvaluationPointsNonOriented, elemOrts, basisPtr); } Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &ic) { for(int i=0;i pow(7, degree-1)*tol) { //heuristic relation on how round-off error depends on degree errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "HGRAD_C" << degree << ": The weights recovered with the optimization are different than the one used for generating the functon."<< "\nThe max The infinite norm of the difference between the weights is: " << diffErr << std::endl; } } //compute L2 projection of the Lagrangian interpolation DynRankView ConstructWithLabel(basisCoeffsL2, numCells, basisCardinality); { ordinal_type targetCubDegree(basisPtr->getDegree()); ProjStruct projStruct; projStruct.createL2ProjectionStruct(basisPtr, targetCubDegree); auto evaluationPoints = projStruct.getAllEvalPoints(); ordinal_type numPoints = evaluationPoints.extent(0); DynRankView ConstructWithLabel(targetAtEvalPoints, numCells, numPoints); DynRankView ConstructWithLabel(hgradBasisAtEvaluationPoints, numCells, basisCardinality , numPoints); DynRankView ConstructWithLabel(hgradBasisAtEvaluationPointsNonOriented, basisCardinality , numPoints); basisPtr->getValues(hgradBasisAtEvaluationPointsNonOriented, evaluationPoints, OPERATOR_VALUE); ots::modifyBasisByOrientation(hgradBasisAtEvaluationPoints, hgradBasisAtEvaluationPointsNonOriented, elemOrts, basisPtr); Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &ic) { for(int i=0;i pow(7, degree-1)*tol) { //heuristic relation on how round-off error depends on degree errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "HGRAD_C" << degree << ": The weights recovered with the L2 optimization are different than the one used for generating the functon."<< "\nThe max The infinite norm of the difference between the weights is: " << diffErr << std::endl; } } //compute Broken L2 projection of the Lagrangian interpolation DynRankView ConstructWithLabel(basisCoeffsL2DG, numCells, basisCardinality); { ordinal_type targetCubDegree(basisPtr->getDegree()); ProjStruct projStruct; projStruct.createL2DGProjectionStruct(basisPtr, targetCubDegree); auto evaluationPoints = projStruct.getAllEvalPoints(); ordinal_type numPoints = evaluationPoints.extent(0); DynRankView ConstructWithLabel(targetAtEvalPoints, numCells, numPoints); DynRankView ConstructWithLabel(hgradBasisAtEvaluationPoints, numCells, basisCardinality , numPoints); DynRankView ConstructWithLabel(hgradBasisAtEvaluationPointsNonOriented, basisCardinality , numPoints); basisPtr->getValues(hgradBasisAtEvaluationPointsNonOriented, evaluationPoints, OPERATOR_VALUE); ots::modifyBasisByOrientation(hgradBasisAtEvaluationPoints, hgradBasisAtEvaluationPointsNonOriented, elemOrts, basisPtr); Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &ic) { for(int i=0;i pow(7, degree-1)*tol) { //heuristic relation on how round-off error depends on degree errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "HGRAD_C" << degree << ": The weights recovered with the L2DG optimization are different than the one used for generating the functon."<< "\nThe max The infinite norm of the difference between the weights is: " << diffErr << std::endl; } } delete basisPtr; } } } } while(std::next_permutation(&reorder[0]+2, &reorder[0]+4)); //reorder vertices of common side } catch (std::exception &err) { std::cout << " Exeption\n"; *outStream << err.what() << "\n\n"; errorFlag = -1000; } *outStream << "===============================================================================\n" << "| |\n" << "| Test 2 (Orientation - HCURL) |\n" << "| |\n" << "===============================================================================\n"; try { ordinal_type reorder[numTotalVertexes] = {0,1,2,3,4,5}; do { ordinal_type orderback[numTotalVertexes]; for(ordinal_type i=0;i elemOrts("elemOrts", numCells); ots::getOrientation(elemOrts, elemNodes, cellTopo); for (ordinal_type degree=1; degree <= max_degree; degree++) { basis_set.clear(); if(degree==1) basis_set.push_back(new Basis_HCURL_QUAD_I1_FEM()); basis_set.push_back(new typename CG_NBasis::HCURL_QUAD(degree,POINTTYPE_EQUISPACED)); basis_set.push_back(new typename CG_DNBasis::HCURL_QUAD(degree,POINTTYPE_WARPBLEND)); for (auto basisPtr:basis_set) { auto name = basisPtr->getName(); *outStream << " " << name << ": " << degree << std::endl; ordinal_type basisCardinality = basisPtr->getCardinality(); //compute DofCoords Oriented DynRankView ConstructWithLabel(dofCoords, basisCardinality, dim); DynRankView ConstructWithLabel(physDofCoords, numCells, basisCardinality, dim); DynRankView ConstructWithLabel(funAtDofCoords, numCells, basisCardinality, dim); DynRankView ConstructWithLabel(basisCoeffsLI, numCells, basisCardinality); //compute Lagrangian Interpolation of fun { basisPtr->getDofCoords(dofCoords); //Compute physical Dof Coordinates DynRankView ConstructWithLabel(jacobian, numCells, basisCardinality, dim, dim); ct::setJacobian(jacobian, dofCoords, physVertexes, cellTopo); Basis_HGRAD_QUAD_C1_FEM linearBasis; DynRankView ConstructWithLabel(linearBasisValuesAtDofCoords, numNodesPerElem, basisCardinality); linearBasis.getValues(linearBasisValuesAtDofCoords, dofCoords); DynRankView ConstructWithLabel(fwdFunAtDofCoords, numCells, basisCardinality, dim); Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &i) { FunCurl fun; for(ordinal_type j=0; jgetValues(outView, inView); } // modify basis values to account for orientations ots::modifyBasisByOrientation(basisValuesAtDofCoordsOriented, basisValuesAtDofCoords, elemOrts, basisPtr); auto hostBasisValues = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), basisValuesAtDofCoordsOriented); auto hostDofCoeffs = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), dofCoeffs); for(ordinal_type i=0; i 100*tol ) { errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << " Basis function " << k << " of cell " << i << " does not have unit value at its node (" << dofValue <<")\n"; } if ( k!=j && std::abs( dofValue ) > tol ) { errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << " Basis function " << k << " of cell " << i << " does not vanish at node " << j << "(" << dofValue <<")\n"; } } } } } //check that fun values are consistent on common edges dofs auto hostBasisCoeffsLI = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), basisCoeffsLI); { bool areDifferent(false); auto numEdgeDOFs = basisPtr->getDofCount(1,0); for(ordinal_type j=0;jgetDofOrdinal(1,edgeIndex[0],j)) - hostBasisCoeffsLI(1,basisPtr->getDofOrdinal(1,edgeIndex[1],j))) > 10*tol; } if(areDifferent) { errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "Function DOFs on the common edge computed using Quad 0 basis functions are not consistent with those computed using Quad 1\n"; *outStream << "Function DOFs for Quad 0 are:"; for(ordinal_type j=0;jgetDofOrdinal(1,edgeIndex[0],j)); *outStream << "\nFunction DOFs for Quad 1 are:"; for(ordinal_type j=0;jgetDofOrdinal(1,edgeIndex[1],j)); *outStream << std::endl; } } //check that fun values at reference points coincide with those computed using basis functions DynRankView ConstructWithLabel(basisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality, dim); DynRankView ConstructWithLabel(transformedBasisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality, dim); DynRankView basisValuesAtDofCoords("inValues", basisCardinality, basisCardinality, dim); basisPtr->getValues(basisValuesAtDofCoords, dofCoords); // modify basis values to account for orientations ots::modifyBasisByOrientation(basisValuesAtDofCoordsOriented, basisValuesAtDofCoords, elemOrts, basisPtr); // transform basis values DynRankView ConstructWithLabel(jacobianAtDofCoords, numCells, basisCardinality, dim, dim); DynRankView ConstructWithLabel(jacobianAtDofCoords_inv, numCells, basisCardinality, dim, dim); ct::setJacobian(jacobianAtDofCoords, dofCoords, physVertexes, cellTopo); ct::setJacobianInv (jacobianAtDofCoords_inv, jacobianAtDofCoords); fst::HCURLtransformVALUE(transformedBasisValuesAtDofCoordsOriented, jacobianAtDofCoords_inv, basisValuesAtDofCoordsOriented); DynRankView ConstructWithLabel(funAtDofCoordsOriented, numCells, basisCardinality, dim); Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &i) { for(ordinal_type j=0; j100*tol) { errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "Function values at reference points differ from those computed using basis functions of Quad " << i << "\n"; *outStream << "Function values at reference points are:\n"; for(ordinal_type j=0; jgetDegree()),targetDerivCubDegree(basisPtr->getDegree()-1); ProjStruct projStruct; projStruct.createHCurlProjectionStruct(basisPtr, targetCubDegree, targetDerivCubDegree); auto evaluationPoints = projStruct.getAllEvalPoints(); auto evaluationCurlPoints = projStruct.getAllDerivEvalPoints(); ordinal_type numPoints = evaluationPoints.extent(0), numCurlPoints = evaluationCurlPoints.extent(0); DynRankView ConstructWithLabel(targetAtEvalPoints, numCells, numPoints, dim); DynRankView ConstructWithLabel(targetCurlAtEvalPoints, numCells, numCurlPoints); DynRankView ConstructWithLabel(hcurlBasisAtEvaluationPoints, numCells, basisCardinality , numPoints, dim); DynRankView ConstructWithLabel(hcurlBasisAtEvaluationPointsNonOriented, basisCardinality , numPoints, dim); basisPtr->getValues(hcurlBasisAtEvaluationPointsNonOriented, evaluationPoints, OPERATOR_VALUE); ots::modifyBasisByOrientation(hcurlBasisAtEvaluationPoints, hcurlBasisAtEvaluationPointsNonOriented, elemOrts, basisPtr); DynRankView ConstructWithLabel(curlOfHCurlBasisAtEvaluationPoints, numCells, basisCardinality , numCurlPoints); if(numCurlPoints>0) { DynRankView ConstructWithLabel(curlOfHCurlBasisAtEvaluationPointsNonOriented, basisCardinality , numCurlPoints); basisPtr->getValues(curlOfHCurlBasisAtEvaluationPointsNonOriented, evaluationCurlPoints, OPERATOR_CURL); ots::modifyBasisByOrientation(curlOfHCurlBasisAtEvaluationPoints, curlOfHCurlBasisAtEvaluationPointsNonOriented, elemOrts, basisPtr); } Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &ic) { for(int i=0;i pow(7, degree-1)*tol) { //heuristic relation on how round-off error depends on degree errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "HCURL_I" << degree << ": The weights recovered with the optimization are different than the one used for generating the functon."<< "\nThe max The infinite norm of the difference between the weights is: " << diffErr << std::endl; } } //compute L2 projection of the Lagrangian interpolation DynRankView ConstructWithLabel(basisCoeffsL2, numCells, basisCardinality); { ordinal_type targetCubDegree(basisPtr->getDegree()); ProjStruct projStruct; projStruct.createL2ProjectionStruct(basisPtr, targetCubDegree); auto evaluationPoints = projStruct.getAllEvalPoints(); ordinal_type numPoints = evaluationPoints.extent(0); DynRankView ConstructWithLabel(targetAtEvalPoints, numCells, numPoints, dim); DynRankView ConstructWithLabel(hcurlBasisAtEvaluationPoints, numCells, basisCardinality , numPoints, dim); DynRankView ConstructWithLabel(hcurlBasisAtEvaluationPointsNonOriented, basisCardinality , numPoints, dim); basisPtr->getValues(hcurlBasisAtEvaluationPointsNonOriented, evaluationPoints, OPERATOR_VALUE); ots::modifyBasisByOrientation(hcurlBasisAtEvaluationPoints, hcurlBasisAtEvaluationPointsNonOriented, elemOrts, basisPtr); Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &ic) { for(int i=0;i pow(7, degree-1)*tol) { //heuristic relation on how round-off error depends on degree errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "HCURL_I" << degree << ": The weights recovered with the L2 optimization are different than the one used for generating the functon."<< "\nThe max The infinite norm of the difference between the weights is: " << diffErr << std::endl; } } //compute Broken L2 projection of the Lagrangian interpolation DynRankView ConstructWithLabel(basisCoeffsL2DG, numCells, basisCardinality); { ordinal_type targetCubDegree(basisPtr->getDegree()); ProjStruct projStruct; projStruct.createL2DGProjectionStruct(basisPtr, targetCubDegree); auto evaluationPoints = projStruct.getAllEvalPoints(); ordinal_type numPoints = evaluationPoints.extent(0); DynRankView ConstructWithLabel(targetAtEvalPoints, numCells, numPoints, dim); DynRankView ConstructWithLabel(hcurlBasisAtEvaluationPoints, numCells, basisCardinality , numPoints, dim); DynRankView ConstructWithLabel(hcurlBasisAtEvaluationPointsNonOriented, basisCardinality , numPoints, dim); basisPtr->getValues(hcurlBasisAtEvaluationPointsNonOriented, evaluationPoints, OPERATOR_VALUE); ots::modifyBasisByOrientation(hcurlBasisAtEvaluationPoints, hcurlBasisAtEvaluationPointsNonOriented, elemOrts, basisPtr); Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &ic) { for(int i=0;i pow(7, degree-1)*tol) { //heuristic relation on how round-off error depends on degree errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "HCURL_I" << degree << ": The weights recovered with the L2DG optimization are different than the one used for generating the functon."<< "\nThe max The infinite norm of the difference between the weights is: " << diffErr << std::endl; } } delete basisPtr; } } } } while(std::next_permutation(&reorder[0]+2, &reorder[0]+4)); //reorder vertices of common side } catch (std::exception &err) { std::cout << " Exeption\n"; *outStream << err.what() << "\n\n"; errorFlag = -1000; } *outStream << "===============================================================================\n" << "| |\n" << "| Test 3 (Orientation - HDIV) |\n" << "| |\n" << "===============================================================================\n"; try { ordinal_type reorder[numTotalVertexes] = {0,1,2,3,4,5}; do { ordinal_type orderback[numTotalVertexes]; for(ordinal_type i=0;i elemOrts("elemOrts", numCells); ots::getOrientation(elemOrts, elemNodes, cellTopo); for (ordinal_type degree=1; degree <= max_degree; degree++) { basis_set.clear(); if(degree==1) basis_set.push_back(new Basis_HDIV_QUAD_I1_FEM()); basis_set.push_back(new typename CG_NBasis::HDIV_QUAD(degree,POINTTYPE_WARPBLEND)); basis_set.push_back(new typename CG_DNBasis::HDIV_QUAD(degree,POINTTYPE_EQUISPACED)); for (auto basisPtr:basis_set) { auto name = basisPtr->getName(); *outStream << " " << name << ": "<< degree << std::endl; ordinal_type basisCardinality = basisPtr->getCardinality(); //compute DofCoords Oriented DynRankView ConstructWithLabel(dofCoords, basisCardinality, dim); DynRankView ConstructWithLabel(physDofCoords, numCells, basisCardinality, dim); DynRankView ConstructWithLabel(funAtDofCoords, numCells, basisCardinality, dim); DynRankView ConstructWithLabel(basisCoeffsLI, numCells, basisCardinality); //compute Lagrangian Interpolation of fun { basisPtr->getDofCoords(dofCoords); //need to transform dofCoeff to physical space (they transform as normals) DynRankView ConstructWithLabel(jacobian, numCells, basisCardinality, dim, dim); DynRankView ConstructWithLabel(jacobian_inv, numCells, basisCardinality, dim, dim); DynRankView ConstructWithLabel(jacobian_det, numCells, basisCardinality); ct::setJacobian(jacobian, dofCoords, physVertexes, cellTopo); ct::setJacobianInv (jacobian_inv, jacobian); ct::setJacobianDet (jacobian_det, jacobian); //Compute physical Dof Coordinates DynRankView ConstructWithLabel(linearBasisValuesAtDofCoord, numNodesPerElem, basisCardinality); Basis_HGRAD_QUAD_C1_FEM linearBasis; linearBasis.getValues(linearBasisValuesAtDofCoord,dofCoords); DynRankView ConstructWithLabel(fwdFunAtDofCoords, numCells, basisCardinality, dim); Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &i) { FunDiv fun; for(ordinal_type j=0; jgetValues(outView, inView); } // modify basis values to account for orientations ots::modifyBasisByOrientation(basisValuesAtDofCoordsOriented, basisValuesAtDofCoords, elemOrts, basisPtr); DynRankView ConstructWithLabel(jacobian, numCells, basisCardinality, dim, dim); DynRankView ConstructWithLabel(jacobian_det, numCells, basisCardinality); ct::setJacobian(jacobian, dofCoordsOriented, physVertexes, cellTopo); ct::setJacobianDet (jacobian_det, jacobian); auto hostBasisValues = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), basisValuesAtDofCoordsOriented); auto hostDofCoeffs = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), dofCoeffs); for(ordinal_type i=0; i 100*tol ) { errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << " Basis function " << k << " of cell " << i << " does not have unit value at its node (" << dofValue <<")\n"; } if ( k!=j && std::abs( dofValue ) > tol ) { errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << " Basis function " << k << " of cell " << i << " does not vanish at node " << j << "(" << dofValue <<")\n"; } } } } } //check that fun values are consistent on common edge dofs auto hostBasisCoeffsLI = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), basisCoeffsLI); { bool areDifferent(false); auto numEdgeDOFs = basisPtr->getDofCount(dim-1,0); for(ordinal_type j=0;jgetDofOrdinal(dim-1,edgeIndex[0],j)) - hostBasisCoeffsLI(1,basisPtr->getDofOrdinal(dim-1,edgeIndex[1],j))) > 10*tol; } if(areDifferent) { errorFlag++; auto hostPhysDofCoords = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), physDofCoords); *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "Function DOFs on common edge computed using Quad 0 basis functions are not consistent with those computed using Quad 1\n"; *outStream << "Function DOFs for Quad 0 are:"; for(ordinal_type j=0;jgetDofOrdinal(dim-1,edgeIndex[0],j)) << " | (" << hostPhysDofCoords(0,basisPtr->getDofOrdinal(dim-1,edgeIndex[0],j),0) << "," << hostPhysDofCoords(0,basisPtr->getDofOrdinal(dim-1,edgeIndex[0],j),1) << ") ||"; *outStream << "\nFunction DOFs for Quad 1 are:"; for(ordinal_type j=0;jgetDofOrdinal(dim-1,edgeIndex[1],j))<< " | (" << hostPhysDofCoords(1,basisPtr->getDofOrdinal(dim-1,edgeIndex[1],j),0) << "," << hostPhysDofCoords(1,basisPtr->getDofOrdinal(dim-1,edgeIndex[1],j),1) << ") ||"; *outStream << std::endl; } } //check that fun values at reference points coincide with those computed using basis functions DynRankView ConstructWithLabel(basisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality, dim); DynRankView ConstructWithLabel(transformedBasisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality, dim); DynRankView basisValuesAtDofCoords("inValues", basisCardinality, basisCardinality, dim); basisPtr->getValues(basisValuesAtDofCoords, dofCoords); // modify basis values to account for orientations ots::modifyBasisByOrientation(basisValuesAtDofCoordsOriented, basisValuesAtDofCoords, elemOrts, basisPtr); // transform basis values DynRankView ConstructWithLabel(jacobianAtDofCoords, numCells, basisCardinality, dim, dim); DynRankView ConstructWithLabel(jacobianAtDofCoords_det, numCells, basisCardinality); ct::setJacobian(jacobianAtDofCoords, dofCoords, physVertexes, cellTopo); ct::setJacobianDet (jacobianAtDofCoords_det, jacobianAtDofCoords); fst::HDIVtransformVALUE(transformedBasisValuesAtDofCoordsOriented, jacobianAtDofCoords, jacobianAtDofCoords_det, basisValuesAtDofCoordsOriented); DynRankView ConstructWithLabel(funAtDofCoordsOriented, numCells, basisCardinality, dim); Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &i) { for(ordinal_type j=0; j100*tol) { errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "Function values at reference points differ from those computed using basis functions of Quad " << i << "\n"; *outStream << "Function values at reference points are:\n"; for(ordinal_type j=0; jgetDegree()),targetDerivCubDegree(basisPtr->getDegree()-1); ProjStruct projStruct; projStruct.createHDivProjectionStruct(basisPtr, targetCubDegree, targetDerivCubDegree); auto evaluationPoints = projStruct.getAllEvalPoints(); auto evaluationDivPoints = projStruct.getAllDerivEvalPoints(); ordinal_type numPoints = evaluationPoints.extent(0), numDivPoints = evaluationDivPoints.extent(0); DynRankView ConstructWithLabel(targetAtEvalPoints, numCells, numPoints, dim); DynRankView ConstructWithLabel(targetDivAtEvalPoints, numCells, numDivPoints); DynRankView ConstructWithLabel(hdivBasisAtEvaluationPoints, numCells, basisCardinality , numPoints, dim); DynRankView ConstructWithLabel(hdivBasisAtEvaluationPointsNonOriented, basisCardinality , numPoints, dim); basisPtr->getValues(hdivBasisAtEvaluationPointsNonOriented, evaluationPoints, OPERATOR_VALUE); ots::modifyBasisByOrientation(hdivBasisAtEvaluationPoints, hdivBasisAtEvaluationPointsNonOriented, elemOrts, basisPtr); DynRankView ConstructWithLabel(divOfHDivBasisAtEvaluationPoints, numCells, basisCardinality , numDivPoints); if(numDivPoints>0) { DynRankView ConstructWithLabel(divOfHDivBasisAtEvaluationPointsNonOriented, basisCardinality , numDivPoints); basisPtr->getValues(divOfHDivBasisAtEvaluationPointsNonOriented, evaluationDivPoints, OPERATOR_DIV); ots::modifyBasisByOrientation(divOfHDivBasisAtEvaluationPoints, divOfHDivBasisAtEvaluationPointsNonOriented, elemOrts, basisPtr); } Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &ic) { for(int i=0;i pow(7, degree-1)*tol) { //heuristic relation on how round-off error depends on degree errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "HDIV_I" << degree << ": The weights recovered with the optimization are different than the one used for generating the functon."<< "\nThe max The infinite norm of the difference between the weights is: " << diffErr << std::endl; } } //compute L2 projection interpolation of the Lagrangian interpolation DynRankView ConstructWithLabel(basisCoeffsL2, numCells, basisCardinality); { ordinal_type targetCubDegree(basisPtr->getDegree()); ProjStruct projStruct; projStruct.createL2ProjectionStruct(basisPtr, targetCubDegree); auto evaluationPoints = projStruct.getAllEvalPoints(); ordinal_type numPoints = evaluationPoints.extent(0); DynRankView ConstructWithLabel(targetAtEvalPoints, numCells, numPoints, dim); DynRankView ConstructWithLabel(hdivBasisAtEvaluationPoints, numCells, basisCardinality , numPoints, dim); DynRankView ConstructWithLabel(hdivBasisAtEvaluationPointsNonOriented, basisCardinality , numPoints, dim); basisPtr->getValues(hdivBasisAtEvaluationPointsNonOriented, evaluationPoints, OPERATOR_VALUE); ots::modifyBasisByOrientation(hdivBasisAtEvaluationPoints, hdivBasisAtEvaluationPointsNonOriented, elemOrts, basisPtr); Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &ic) { for(int i=0;i pow(7, degree-1)*tol) { //heuristic relation on how round-off error depends on degree errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "HDIV_I" << degree << ": The weights recovered with the L2 optimization are different than the one used for generating the function."<< "\nThe max The infinite norm of the difference between the weights is: " << diffErr << std::endl; } } //compute L2 Discontinuous projection interpolation of the Lagrangian interpolation DynRankView ConstructWithLabel(basisCoeffsL2DG, numCells, basisCardinality); { ordinal_type targetCubDegree(basisPtr->getDegree()); ProjStruct projStruct; projStruct.createL2DGProjectionStruct(basisPtr, targetCubDegree); auto evaluationPoints = projStruct.getAllEvalPoints(); ordinal_type numPoints = evaluationPoints.extent(0); DynRankView ConstructWithLabel(targetAtEvalPoints, numCells, numPoints, dim); DynRankView ConstructWithLabel(hdivBasisAtEvaluationPoints, numCells, basisCardinality , numPoints, dim); DynRankView ConstructWithLabel(hdivBasisAtEvaluationPointsNonOriented, basisCardinality , numPoints, dim); basisPtr->getValues(hdivBasisAtEvaluationPointsNonOriented, evaluationPoints, OPERATOR_VALUE); ots::modifyBasisByOrientation(hdivBasisAtEvaluationPoints, hdivBasisAtEvaluationPointsNonOriented, elemOrts, basisPtr); Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &ic) { for(int i=0;i pow(7, degree-1)*tol) { //heuristic relation on how round-off error depends on degree errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "HDIV_I" << degree << ": The weights recovered with the L2DG optimization are different than the one used for generating the function."<< "\nThe max The infinite norm of the difference between the weights is: " << diffErr << std::endl; } } delete basisPtr; } } } } while(std::next_permutation(&reorder[0]+2, &reorder[0]+4)); //reorder vertices of common side } catch (std::exception &err) { std::cout << " Exeption\n"; *outStream << err.what() << "\n\n"; errorFlag = -1000; } *outStream << "===============================================================================\n" << "| |\n" << "| Test 4 (Orientation - HVOL) |\n" << "| |\n" << "===============================================================================\n"; try { ValueType vertices[numTotalVertexes][dim]; ordinal_type cells[numCells][numElemVertexes]; for(ordinal_type i=0; i elemOrts("elemOrts", numCells); ots::getOrientation(elemOrts, elemNodes, cellTopo); for (ordinal_type degree=1; degree <= max_degree; degree++) { basis_set.clear(); if(degree==1) basis_set.push_back(new Basis_HVOL_C0_FEM(cellTopo)); basis_set.push_back(new typename CG_NBasis::HVOL_QUAD(degree,POINTTYPE_EQUISPACED)); basis_set.push_back(new typename CG_DNBasis::HVOL_QUAD(degree,POINTTYPE_WARPBLEND)); for (auto basisPtr:basis_set) { auto name = basisPtr->getName(); *outStream << " " << name << ": " << degree << std::endl; ordinal_type basisCardinality = basisPtr->getCardinality(); //compute DofCoords Oriented DynRankView ConstructWithLabel(dofCoords, basisCardinality, dim); DynRankView ConstructWithLabel(physDofCoords, numCells, basisCardinality, dim); DynRankView ConstructWithLabel(funAtDofCoords, numCells, basisCardinality); DynRankView ConstructWithLabel(basisCoeffsLI, numCells, basisCardinality); //compute Lagrangian Interpolation of fun { basisPtr->getDofCoords(dofCoords); //need to transform dofCoeff to physical space (they transform as normals) DynRankView ConstructWithLabel(jacobian, numCells, basisCardinality, dim, dim); DynRankView ConstructWithLabel(jacobian_det, numCells, basisCardinality); ct::setJacobian(jacobian, dofCoords, physVertexes, cellTopo); ct::setJacobianDet (jacobian_det, jacobian); //Compute physical Dof Coordinates DynRankView ConstructWithLabel(linearBasisValuesAtDofCoord, numNodesPerElem, basisCardinality); Basis_HGRAD_QUAD_C1_FEM linearBasis; linearBasis.getValues(linearBasisValuesAtDofCoord, dofCoords); DynRankView ConstructWithLabel(fwdFunAtDofCoords, numCells, basisCardinality); Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &i) { Fun fun; for(ordinal_type j=0; jgetValues(outView, inView); } // modify basis values to account for orientations ots::modifyBasisByOrientation(basisValuesAtDofCoordsOriented, basisValuesAtDofCoords, elemOrts, basisPtr); auto hostBasisValues = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), basisValuesAtDofCoordsOriented); auto hostDofCoeffsPhys = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), dofCoeffsPhys); for(ordinal_type i=0; i 100*tol ) { errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << " Basis function " << k << " of cell " << i << " does not have unit value at its node (" << dofValue <<")\n"; } if ( k!=j && std::abs( dofValue ) > tol ) { errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << " Basis function " << k << " of cell " << i << " does not vanish at node " << j << "(" << dofValue <<")\n"; } } } } } //check that fun values at reference points coincide with those computed using basis functions DynRankView ConstructWithLabel(basisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality); DynRankView ConstructWithLabel(transformedBasisValuesAtDofCoordsOriented, numCells, basisCardinality, basisCardinality); DynRankView basisValuesAtDofCoords("inValues", basisCardinality, basisCardinality); basisPtr->getValues(basisValuesAtDofCoords, dofCoords); // modify basis values to account for orientations ots::modifyBasisByOrientation(basisValuesAtDofCoordsOriented, basisValuesAtDofCoords, elemOrts, basisPtr); // transform basis values DynRankView ConstructWithLabel(jacobian, numCells, basisCardinality, dim, dim); DynRankView ConstructWithLabel(jacobian_det, numCells, basisCardinality); ct::setJacobian(jacobian, dofCoords, physVertexes, cellTopo); ct::setJacobianDet (jacobian_det, jacobian); fst::HVOLtransformVALUE(transformedBasisValuesAtDofCoordsOriented, jacobian_det, basisValuesAtDofCoordsOriented); DynRankView ConstructWithLabel(funAtDofCoordsOriented, numCells, basisCardinality); Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &i) { for(ordinal_type j=0; j100*tol) { errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "Function values at reference points differ from those computed using basis functions of Quad " << i << "\n"; *outStream << "Function values at reference points are:\n"; for(ordinal_type j=0; jgetDegree()); ProjStruct projStruct; projStruct.createHVolProjectionStruct(basisPtr, targetCubDegree); auto evaluationPoints = projStruct.getAllEvalPoints(); ordinal_type numPoints = evaluationPoints.extent(0); DynRankView ConstructWithLabel(targetAtEvalPoints, numCells, numPoints); DynRankView ConstructWithLabel(hvolBasisAtEvaluationPoints, numCells, basisCardinality , numPoints); DynRankView ConstructWithLabel(hvolBasisAtEvaluationPointsNonOriented, basisCardinality , numPoints); basisPtr->getValues(hvolBasisAtEvaluationPointsNonOriented, evaluationPoints, OPERATOR_VALUE); ots::modifyBasisByOrientation(hvolBasisAtEvaluationPoints, hvolBasisAtEvaluationPointsNonOriented, elemOrts, basisPtr); Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &ic) { for(int i=0;i pow(16, degree)*tol) { //heuristic relation on how round-off error depends on degree errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "HVOL_C" << degree << ": The weights recovered with the optimization are different than the one used for generating the functon."<< "\nThe max The infinite norm of the difference between the weights is: " << diffErr << std::endl; } } //compute L2 projection of the Lagrangian interpolation DynRankView ConstructWithLabel(basisCoeffsL2, numCells, basisCardinality); { ordinal_type targetCubDegree(basisPtr->getDegree()); ProjStruct projStruct; projStruct.createL2ProjectionStruct(basisPtr, targetCubDegree); auto evaluationPoints = projStruct.getAllEvalPoints(); ordinal_type numPoints = evaluationPoints.extent(0); DynRankView ConstructWithLabel(targetAtEvalPoints, numCells, numPoints); DynRankView ConstructWithLabel(hvolBasisAtEvaluationPoints, numCells, basisCardinality , numPoints); DynRankView ConstructWithLabel(hvolBasisAtEvaluationPointsNonOriented, basisCardinality , numPoints); basisPtr->getValues(hvolBasisAtEvaluationPointsNonOriented, evaluationPoints, OPERATOR_VALUE); ots::modifyBasisByOrientation(hvolBasisAtEvaluationPoints, hvolBasisAtEvaluationPointsNonOriented, elemOrts, basisPtr); Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &ic) { for(int i=0;i pow(16, degree)*tol) { //heuristic relation on how round-off error depends on degree errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "HVOL_C" << degree << ": The weights recovered with the L2 optimization are different than the one used for generating the functon."<< "\nThe max The infinite norm of the difference between the weights is: " << diffErr << std::endl; } } //compute L2DG projection of the Lagrangian interpolation DynRankView ConstructWithLabel(basisCoeffsL2DG, numCells, basisCardinality); { ordinal_type targetCubDegree(basisPtr->getDegree()); ProjStruct projStruct; projStruct.createL2DGProjectionStruct(basisPtr, targetCubDegree); auto evaluationPoints = projStruct.getAllEvalPoints(); ordinal_type numPoints = evaluationPoints.extent(0); DynRankView ConstructWithLabel(targetAtEvalPoints, numCells, numPoints); DynRankView ConstructWithLabel(hvolBasisAtEvaluationPoints, numCells, basisCardinality , numPoints); DynRankView ConstructWithLabel(hvolBasisAtEvaluationPointsNonOriented, basisCardinality , numPoints); basisPtr->getValues(hvolBasisAtEvaluationPointsNonOriented, evaluationPoints, OPERATOR_VALUE); ots::modifyBasisByOrientation(hvolBasisAtEvaluationPoints, hvolBasisAtEvaluationPointsNonOriented, elemOrts, basisPtr); Kokkos::parallel_for(Kokkos::RangePolicy(0,numCells), KOKKOS_LAMBDA (const int &ic) { for(int i=0;i pow(16, degree)*tol) { //heuristic relation on how round-off error depends on degree errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "HVOL_C" << degree << ": The weights recovered with the L2DG optimization are different than the one used for generating the functon."<< "\nThe max The infinite norm of the difference between the weights is: " << diffErr << std::endl; } } delete basisPtr; } } } catch (std::exception &err) { std::cout << " Exeption\n"; *outStream << err.what() << "\n\n"; errorFlag = -1000; } if (errorFlag != 0) std::cout << "End Result: TEST FAILED = " << errorFlag << "\n"; else std::cout << "End Result: TEST PASSED\n"; // reset format state of std::cout std::cout.copyfmt(oldFormatState); return errorFlag; } } }