// @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 Tetrahedral elements The test considers two tetrahedra in the physical space sharing a common face. In order to test significant configurations, we consider 4 mappings of the reference tetrahedron to the first (physical) tetrahedron, so that the common face is mapped from all the 4 faces of the reference tetrahedron. Then, for each of the mappings, the global ids of the vertices of the common face are permuted (6 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 tetrahera. \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_TET_C1_FEM.hpp" #include "Intrepid2_HGRAD_TET_C2_FEM.hpp" #include "Intrepid2_HGRAD_TET_Cn_FEM.hpp" #include "Intrepid2_HVOL_TET_Cn_FEM.hpp" #include "Intrepid2_HCURL_TET_In_FEM.hpp" #include "Intrepid2_PointTools.hpp" #include "Intrepid2_CellTools.hpp" #include "Intrepid2_FunctionSpaceTools.hpp" #include "Intrepid2_LagrangianInterpolation.hpp" //this allows to reduce cost of the tests. //undefine when debugging/developing #define RANDOMLY_PICK_ELEM_PERMUTATION #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 InterpolationProjectionTet(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 DynRankViewIntHost = Kokkos::DynRankView; int errorFlag = 0; const ValueType tol = tolerence(); bool pickTest = false; int elemPermutation=0, sharedSidePermutation=0; #ifdef RANDOMLY_PICK_ELEM_PERMUTATION pickTest = true; /* initialize random seed: */ std::srand (std::time(NULL)); int configuration = std::rand() % 24; elemPermutation = configuration % 4; sharedSidePermutation = configuration/4; *outStream << "Randomly picked configuration (tet premutation, shared face permutation): (" << elemPermutation << ", " <; using faceType = 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 = 3; constexpr ordinal_type numCells = 2; constexpr ordinal_type numElemVertexes = 4; constexpr ordinal_type numTotalVertexes = 5; ValueType vertices_orig[numTotalVertexes][dim] = {{0,0,0},{1,0,0},{0,1,0},{0,0,1},{1,1,1}}; ordinal_type cells_orig[numCells][numElemVertexes] = {{0,1,2,3},{1,2,3,4}}; //common face is {1,2,3} ordinal_type cells_rotated[numCells][numElemVertexes]; faceType common_face = {{1,2,3}}; std::set common_edges; common_edges.insert(edgeType({{1,2}})); common_edges.insert(edgeType({{1,3}})); common_edges.insert(edgeType({{2,3}})); 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}; int sharedSideCount = 0; do { if((sharedSideCount++ != sharedSidePermutation) && pickTest) continue; 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_TET_C1_FEM()); if(degree==2) basis_set.push_back(new Basis_HGRAD_TET_C2_FEM()); //basis_set.push_back(new typename CG_NBasis::HGRAD_TET(degree)); basis_set.push_back(new typename CG_DNBasis::HGRAD_TET(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); //Compute physical Dof Coordinates DynRankView ConstructWithLabel(linearBasisValuesAtDofCoords, numNodesPerElem, basisCardinality); Basis_HGRAD_TET_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 face dofs auto hostBasisCoeffsLI = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), basisCoeffsLI); { bool areDifferent(false); auto numFaceDOFs = basisPtr->getDofCount(2,0); for(ordinal_type j=0;jgetDofOrdinal(2,faceIndex[0],j)) - hostBasisCoeffsLI(1,basisPtr->getDofOrdinal(2,faceIndex[1],j))) > 10*tol; } if(areDifferent) { auto hostPhysDofCoords = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), physDofCoords); errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "Function DOFs on common face computed using Tet 0 basis functions are not consistent with those computed using Tet 1\n"; *outStream << "Function DOFs for Tet 0 are:"; for(ordinal_type j=0;jgetDofOrdinal(2,faceIndex[0],j)) << " | (" << hostPhysDofCoords(0,basisPtr->getDofOrdinal(2,faceIndex[0],j),0) << "," << hostPhysDofCoords(0,basisPtr->getDofOrdinal(2,faceIndex[0],j),1) << ", " << hostPhysDofCoords(0,basisPtr->getDofOrdinal(2,faceIndex[0],j),2) << ") ||"; *outStream << "\nFunction DOFs for Tet 1 are:"; for(ordinal_type j=0;jgetDofOrdinal(2,faceIndex[1],j))<< " | (" << hostPhysDofCoords(1,basisPtr->getDofOrdinal(2,faceIndex[1],j),0) << "," << hostPhysDofCoords(1,basisPtr->getDofOrdinal(2,faceIndex[1],j),1) << ", " << hostPhysDofCoords(1,basisPtr->getDofOrdinal(2,faceIndex[1],j),2) << ") ||"; *outStream << std::endl; } } //check that fun values are consistent on common edges dofs { bool areDifferent(false); auto numEdgeDOFs = basisPtr->getDofCount(1,0); for(std::size_t iEdge=0;iEdgegetDofOrdinal(1,edgeIndexes[0][iEdge],j)) - hostBasisCoeffsLI(1,basisPtr->getDofOrdinal(1,edgeIndexes[1][iEdge],j))) > 10*tol; } if(areDifferent) { errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "Function DOFs on common edge " << iEdge << " computed using Tet 0 basis functions are not consistent with those computed using Tet 1\n"; *outStream << "Function DOFs for Tet 0 are:"; for(ordinal_type j=0;jgetDofOrdinal(1,edgeIndexes[0][iEdge],j)); *outStream << "\nFunction DOFs for Tet 1 are:"; for(ordinal_type j=0;jgetDofOrdinal(1,edgeIndexes[1][iEdge],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 Tet " << 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 DG 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 1e4*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]+1, &reorder[0]+4)); //reorder vertices of common face } 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}; int sharedSideCount = 0; do { if((sharedSideCount++ != sharedSidePermutation) && pickTest) continue; 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_TET_I1_FEM()); //basis_set.push_back(new typename CG_NBasis::HCURL_TET(degree)); basis_set.push_back(new typename CG_DNBasis::HCURL_TET(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); //Compute physical Dof Coordinates DynRankView ConstructWithLabel(jacobian, numCells, basisCardinality, dim, dim); ct::setJacobian(jacobian, dofCoords, physVertexes, cellTopo); Basis_HGRAD_TET_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(std::size_t iEdge=0;iEdgegetDofOrdinal(1,edgeIndexes[0][iEdge],j)) - hostBasisCoeffsLI(1,basisPtr->getDofOrdinal(1,edgeIndexes[1][iEdge],j))) > 10*tol; } if(areDifferent) { errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "Function DOFs on common edge " << iEdge << " computed using Tet 0 basis functions are not consistent with those computed using Tet 1\n"; *outStream << "Function DOFs for Tet 0 are:"; for(ordinal_type j=0;jgetDofOrdinal(1,edgeIndexes[0][iEdge],j)); *outStream << "\nFunction DOFs for Tet 1 are:"; for(ordinal_type j=0;jgetDofOrdinal(1,edgeIndexes[1][iEdge],j)); *outStream << std::endl; } } } //check that fun values are consistent on common face dofs { bool areDifferent(false); auto numFaceDOFs = basisPtr->getDofCount(2,0); for(ordinal_type j=0;jgetDofOrdinal(2,faceIndex[0],j)) - hostBasisCoeffsLI(1,basisPtr->getDofOrdinal(2,faceIndex[1],j))) > 10*tol; } if(areDifferent) { auto hostPhysDofCoords = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), physDofCoords); errorFlag++; *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n"; *outStream << "Function DOFs on common face computed using Tet 0 basis functions are not consistent with those computed using Tet 1\n"; *outStream << "Function DOFs for Tet 0 are:"; for(ordinal_type j=0;jgetDofOrdinal(2,faceIndex[0],j)) << " | (" << hostPhysDofCoords(0,basisPtr->getDofOrdinal(2,faceIndex[0],j),0) << "," << hostPhysDofCoords(0,basisPtr->getDofOrdinal(2,faceIndex[0],j),1) << ", " << hostPhysDofCoords(0,basisPtr->getDofOrdinal(2,faceIndex[0],j),2) << ") ||"; *outStream << "\nFunction DOFs for Tet 1 are:"; for(ordinal_type j=0;jgetDofOrdinal(2,faceIndex[1],j))<< " | (" << hostPhysDofCoords(1,basisPtr->getDofOrdinal(2,faceIndex[1],j),0) << "," << hostPhysDofCoords(1,basisPtr->getDofOrdinal(2,faceIndex[1],j),1) << ", " << hostPhysDofCoords(1,basisPtr->getDofOrdinal(2,faceIndex[1],j),2) << ") ||"; *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 Tet " << 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, 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); DynRankView ConstructWithLabel(curlOfHCurlBasisAtEvaluationPoints, numCells, basisCardinality , numCurlPoints, dim); if(numCurlPoints>0) { DynRankView ConstructWithLabel(curlOfHCurlBasisAtEvaluationPointsNonOriented, basisCardinality , numCurlPoints, dim); 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 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, 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 1e4*tol) { 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]+1, &reorder[0]+4)); //reorder vertices of common face } 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}; int sharedSideCount = 0; do { if((sharedSideCount++ != sharedSidePermutation) && pickTest) continue; 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_TET_I1_FEM()); //basis_set.push_back(new typename CG_NBasis::HDIV_TET(degree,POINTTYPE_WARPBLEND)); basis_set.push_back(new typename CG_DNBasis::HDIV_TET(degree)); 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_TET_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 face dofs auto hostBasisCoeffsLI = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), basisCoeffsLI); { bool areDifferent(false); auto numFaceDOFs = basisPtr->getDofCount(2,0); for(ordinal_type j=0;jgetDofOrdinal(2,faceIndex[0],j)) - hostBasisCoeffsLI(1,basisPtr->getDofOrdinal(2,faceIndex[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 face computed using Tet 0 basis functions are not consistent with those computed using Tet 1\n"; *outStream << "Function DOFs for Tet 0 are:"; for(ordinal_type j=0;jgetDofOrdinal(2,faceIndex[0],j)) << " | (" << hostPhysDofCoords(0,basisPtr->getDofOrdinal(2,faceIndex[0],j),0) << "," << hostPhysDofCoords(0,basisPtr->getDofOrdinal(2,faceIndex[0],j),1) << ", " << hostPhysDofCoords(0,basisPtr->getDofOrdinal(2,faceIndex[0],j),2) << ") ||"; *outStream << "\nFunction DOFs for Tet 1 are:"; for(ordinal_type j=0;jgetDofOrdinal(2,faceIndex[1],j))<< " | (" << hostPhysDofCoords(1,basisPtr->getDofOrdinal(2,faceIndex[1],j),0) << "," << hostPhysDofCoords(1,basisPtr->getDofOrdinal(2,faceIndex[1],j),1) << ", " << hostPhysDofCoords(1,basisPtr->getDofOrdinal(2,faceIndex[1],j),2) << ") ||"; *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 Tet " << 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 DG L2 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]+1, &reorder[0]+4)); //reorder vertices of common face } 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_TET(degree)); basis_set.push_back(new typename CG_DNBasis::HVOL_TET(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_TET_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 Tet " << 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(7, degree-1)*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(7, degree-1)*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 DG 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(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(20, 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; } } }