diff --git a/UnitTest_PZ/TestMesh/TestHDiv.cpp b/UnitTest_PZ/TestMesh/TestHDiv.cpp index b2233507c..33981075b 100644 --- a/UnitTest_PZ/TestMesh/TestHDiv.cpp +++ b/UnitTest_PZ/TestMesh/TestHDiv.cpp @@ -62,7 +62,7 @@ #include "pzgeotetrahedra.h" #include "pzgeoelrefless.h" #include "pzlog.h" - +#include #include "TPZVTKGeoMesh.h" @@ -80,6 +80,7 @@ static TPZLogger logger("pz.mesh.testhdiv"); #include #include #include +#include static int tetraedra_2[6][4]= { @@ -140,7 +141,7 @@ static TPZAutoPointer HDivMesh, PressureMesh; static void CheckDRhamFacePermutations(MElementType Etype); static void CheckDRhamPermutations(MElementType Etype); -template +template static void CheckShapeOrder(int order); static void RotateGeomesh(TPZGeoMesh *gmesh, REAL CounterClockwiseAngle, int &Axis); @@ -164,78 +165,85 @@ static void ExactPressure(const TPZVec &x, TPZVec &pres, TPZFMatrix static void CheckDRham(TPZCompEl *cel); /// run a problem simulating a bilinear solution for the given element type +template static void RunBilinear(MElementType eltype,HDivFamily hdivfam); /// verify is the shape functions have continuity -static void VerifySideShapeContinuity(MElementType eltype); +template +static void VerifySideShapeContinuity(); /// verify if the pressure space is compatible with the flux space -static void VerifyDRhamCompatibility(MElementType eltype); +template +static void VerifyDRhamCompatibility(); /// Check that the Div of the vector functions can be represented -TEST_CASE("bilinearsolution_check","[hdiv_mesh_tests]") +TEMPLATE_TEST_CASE("bilinearsolution_check", "[hdiv_mesh_tests]", + (pzshape::TPZShapeTriang), + (pzshape::TPZShapeQuad), + (pzshape::TPZShapeTetra), + (pzshape::TPZShapeCube), + (pzshape::TPZShapePrism)) { - HDivFamily hdivfam = GENERATE(HDivFamily::EHDivStandard,HDivFamily::EHDivConstant); - std::cout << "Initializing solution check\n"; - RunBilinear(ECube,hdivfam); - RunBilinear(ETetraedro,hdivfam); - RunBilinear(ETriangle,hdivfam); - RunBilinear(EQuadrilateral,hdivfam); - RunBilinear(EPrisma,hdivfam); - std::cout << "Leaving solution check\n"; + HDivFamily hdivfam = GENERATE(HDivFamily::EHDivStandard, HDivFamily::EHDivConstant); + std::unordered_map hdivfamstr = {{HDivFamily::EHDivStandard, "HDivStandard"}, + {HDivFamily::EHDivConstant, "HDivConstant"}}; + SECTION(hdivfamstr.at(hdivfam)) + { + std::cout << "Initializing solution check\n"; + RunBilinear(hdivfam); + std::cout << "Leaving solution check\n"; + } } -TEST_CASE("Vectors_are_external","[hdiv_mesh_tests]") +TEMPLATE_TEST_CASE("Vectors_are_external", "[hdiv_mesh_tests]", + (pzshape::TPZShapeCube), + (pzshape::TPZShapeTetra), + (pzshape::TPZShapeTriang), + (pzshape::TPZShapeQuad)) { - CheckOutsideDirections(); - CheckOutsideDirections(); - CheckOutsideDirections(); - CheckOutsideDirections(); + CheckOutsideDirections(); } - -TEST_CASE("sideshape_continuity","[hdiv_mesh_tests]") +TEMPLATE_TEST_CASE("sideshape_continuity", "[hdiv_mesh_tests]", + (pzshape::TPZShapeTetra), + (pzshape::TPZShapePrism), + (pzshape::TPZShapeCube), + (pzshape::TPZShapeQuad), + (pzshape::TPZShapeTriang)) { std::cout << "Initializing sideshape_continuity check\n"; -// VerifySideShapeContinuity(EPiramide); - VerifySideShapeContinuity(ETetraedro); - VerifySideShapeContinuity(EPrisma); - VerifySideShapeContinuity(ECube); - VerifySideShapeContinuity(EQuadrilateral); - VerifySideShapeContinuity(ETriangle); + VerifySideShapeContinuity(); std::cout << "Leaving sideshape_continuity check\n"; } - - -TEST_CASE("shape_order","[hdiv_mesh_tests]") + +TEMPLATE_TEST_CASE("shape_order", "[hdiv_mesh_tests]", + (pzshape::TPZShapeTetra), + (pzshape::TPZShapeQuad), + (pzshape::TPZShapeTriang), + (pzshape::TPZShapeCube), + (pzshape::TPZShapePrism)) { std::cout << "Initializing shape_order check\n"; -// CheckShapeOrder(5); - CheckShapeOrder(5); - CheckShapeOrder(5); - CheckShapeOrder(5); - CheckShapeOrder(5); - CheckShapeOrder(5); + CheckShapeOrder(5); std::cout << "Leaving shape_order check\n"; } - /// Check that the Div of the vector functions can be represented -TEST_CASE("drham_check","[hdiv_mesh_tests]") +TEMPLATE_TEST_CASE("drham_check", "[hdiv_mesh_tests]", + (pzshape::TPZShapeTetra), + (pzshape::TPZShapePrism), + (pzshape::TPZShapeCube), + (pzshape::TPZShapeQuad), + (pzshape::TPZShapeTriang)) { std::cout << "Initializing DRham consistency check\n"; -// VerifyDRhamCompatibility(EPiramide); - VerifyDRhamCompatibility(ETetraedro); - VerifyDRhamCompatibility(EPrisma); - VerifyDRhamCompatibility(ECube); - VerifyDRhamCompatibility(EQuadrilateral); - VerifyDRhamCompatibility(ETriangle); + VerifyDRhamCompatibility(); std::cout << "Leaving DRham consistency check\n"; } -TEST_CASE("drham_permute_check","[hdiv_mesh_tests]") +TEST_CASE("drham_permute_check", "[hdiv_mesh_tests]") { std::cout << "Initializing DRham consistency under permutation check\n"; // CheckDRhamFacePermutations(EPiramide); @@ -244,10 +252,9 @@ TEST_CASE("drham_permute_check","[hdiv_mesh_tests]") CheckDRhamFacePermutations(ECube); CheckDRhamPermutations(EQuadrilateral); CheckDRhamPermutations(ETriangle); -// std::cout << "Leaving DRham consistency under permutation check\n"; + std::cout << "Leaving DRham consistency under permutation check\n"; } - static TPZAutoPointer GenerateMesh( TPZVec &meshvec, MElementType eltype, int nelem, int fluxorder, int ndiv, HDivFamily hdivfam) { int dimmodel = 2; @@ -256,7 +263,7 @@ static TPZAutoPointer GenerateMesh( TPZVec &meshvec x0[2] = -1.; x1[2] = -1.; TPZGenGrid2D grid(nx,x0,x1); - if (eltype == ETriangle|| eltype == EPrisma ) { + if (eltype == ETriangle || eltype == EPrisma ) { grid.SetElementType(MMeshType::ETriangular); } TPZGeoMesh* gmesh = new TPZGeoMesh; @@ -266,7 +273,7 @@ static TPZAutoPointer GenerateMesh( TPZVec &meshvec grid.SetBC(gmesh, 6, -1); grid.SetBC(gmesh, 7, -1); - if(eltype==ETriangle||eltype==EPrisma||eltype==ECube||eltype==EQuadrilateral ) + if(eltype==ETriangle || eltype==EPrisma || eltype==ECube || eltype==EQuadrilateral) { for(int D = 0; D < ndiv; D++) { @@ -398,6 +405,7 @@ static TPZAutoPointer GenerateMesh( TPZVec &meshvec PressureMesh->SetDefaultOrder(fluxorder); } else if (hdivfam == HDivFamily::EHDivConstant) { PressureMesh->SetAllCreateFunctionsDiscontinuous(); + PressureMesh->ApproxSpace().CreateDisconnectedElements(true); PressureMesh->SetDefaultOrder(0); } else { DebugStop(); @@ -1090,16 +1098,16 @@ static int VerifyProjection(TPZCompEl *cel, TPZFMatrix &multiplier) } -template +template void CheckShapeOrder(int order) { - TPZManVector orders(tshape::NSides-tshape::NCornerNodes,order); - TPZManVector origids(tshape::NCornerNodes,0); - const int nshape = tshape::NShapeF(orders); - const int nsides = tshape::NSides; - const int ncorner = tshape::NCornerNodes; + TPZManVector orders(TSHAPE::NSides-TSHAPE::NCornerNodes,order); + TPZManVector origids(TSHAPE::NCornerNodes,0); + const int nshape = TSHAPE::NShapeF(orders); + const int nsides = TSHAPE::NSides; + const int ncorner = TSHAPE::NCornerNodes; const int numlegendre = (order+5) < 10 ? 10 : (order+5); - const int dimension = tshape::Dimension; + const int dimension = TSHAPE::Dimension; int numpermwrong = 0; // set up the original ids @@ -1109,7 +1117,7 @@ void CheckShapeOrder(int order) // set up the permutations of the type TPZManVector > permutation; - MElementType thistype = tshape::Type(); + MElementType thistype = TSHAPE::Type(); TPZRefPatternTools::GetElTypePermutations(thistype, permutation); const int nperm = permutation.size(); @@ -1119,7 +1127,7 @@ void CheckShapeOrder(int order) for (int iperm = 0; iperm ids(tshape::NCornerNodes,0); + TPZManVector ids(TSHAPE::NCornerNodes,0); for (int id = 0; id sides; - TPZShapeH1 h1; + TPZShapeH1 h1; TPZShapeData data; h1.Initialize(ids, orders, data); h1.ShapeOrders(shapeorders, data); @@ -1139,7 +1147,7 @@ void CheckShapeOrder(int order) int shapecounter = 0; for (int is=0; is lowerdimensionsides; - tshape::LowerDimensionSides(is, lowerdimensionsides); + TSHAPE::LowerDimensionSides(is, lowerdimensionsides); int firstshape = 0; for (int i=0; i sidecenterel(dimension),sidecenter(sidedim),point(sidedim); TPZFNMatrix<9> jac(2,1); - tshape::CenterPoint(is, sidecenterel); + TSHAPE::CenterPoint(is, sidecenterel); // if(sidetype==EPrisma && is>19){continue;} ///??????? // else{tshape::MapToSide(is, sidecenterel, sidecenter, jac);} - tshape::MapToSide(is, sidecenterel, sidecenter, jac); + TSHAPE::MapToSide(is, sidecenterel, sidecenter, jac); for (int i=0; i philegendre(numlegendre,1,0.); TPZFNMatrix<200,REAL> dphi(sidedim,nsideshape+firstshape), dphilegendre(1,numlegendre,0.), phi(nsideshape+firstshape,1,0.); - TPZSideShapeH1 h1(is); + TPZSideShapeH1 h1(is); TPZShapeData data; h1.Initialize(ids, orders, data); h1.Shape(point, data); @@ -1522,8 +1530,10 @@ void CheckDRhamPermutations(MElementType eltype) } /// run a problem simulating a bilinear solution for the given element type -void RunBilinear(MElementType eltype, HDivFamily hdivfam) +template +void RunBilinear(HDivFamily hdivfam) { + auto eltype = TSHAPE::Type(); if (eltype == EPrisma && hdivfam == HDivFamily::EHDivConstant) return; // Approximation space not implemented for this topology int nelx = 1; @@ -1637,7 +1647,7 @@ void RunBilinear(MElementType eltype, HDivFamily hdivfam) for(int i = 0; iElementVec()[i]; TPZGeoEl *gel = cel->Reference(); - if(gel->Dimension()Dimension()) continue; + if(gel->Dimension() < cmesh->Dimension()) continue; int ns = gel->NSides(); int dim = gel->Dimension(); TPZIntPoints *rule = gel->CreateSideIntegrationRule(ns-1, 4);//3 @@ -1701,8 +1711,10 @@ void RunBilinear(MElementType eltype, HDivFamily hdivfam) } /// verify is the shape functions have continuity -void VerifySideShapeContinuity(MElementType eltype) +template +void VerifySideShapeContinuity() { + MElementType eltype = TSHAPE::Type(); int64_t permcount = 0; TPZVec meshvec(2); TPZAutoPointer cmesh = GenerateMesh(meshvec,eltype); @@ -1786,9 +1798,11 @@ void VerifySideShapeContinuity(MElementType eltype) } /// verify if the pressure space is compatible with the flux space -void VerifyDRhamCompatibility(MElementType eltype) +template +void VerifyDRhamCompatibility() { // generate a mesh + MElementType eltype = TSHAPE::Type(); TPZVec meshvec(2); int nelem =2; int fluxorder = gfluxorder;