From 3c7d932660d23b6cf26a9768b228e2c5c4190cda Mon Sep 17 00:00:00 2001 From: cconopoima Date: Tue, 28 May 2024 14:24:17 +0100 Subject: [PATCH] [bos #40649][CEA] include support to export when cgns is compile with option DCGNS_ENABLE_64BIT:BOOL=ON --- src/DriverCGNS/DriverStructuredCGNS_Write.cxx | 14 +++- src/SMESHUtils/SMESH_RegularGrid.cxx | 80 ++----------------- src/SMESHUtils/SMESH_RegularGrid.hxx | 27 ++++--- src/SMESHUtils/SMESH_RegularGridTemplate.hxx | 68 ++++++++++++++++ test/SMESH_RegularGridTest.cxx | 30 +++---- 5 files changed, 117 insertions(+), 102 deletions(-) diff --git a/src/DriverCGNS/DriverStructuredCGNS_Write.cxx b/src/DriverCGNS/DriverStructuredCGNS_Write.cxx index 80e0b4006..2273eeae0 100644 --- a/src/DriverCGNS/DriverStructuredCGNS_Write.cxx +++ b/src/DriverCGNS/DriverStructuredCGNS_Write.cxx @@ -290,12 +290,16 @@ Driver_Mesh::Status DriverStructuredCGNS_Write::Perform() grid->GetFaceInterfaces(myMesh->GetTheGrid(neighbourSolid).get(), interface); if ( !interface.empty() ) { + std::vector interfacecgns( 12 ); + for (size_t i = 0; i < 12; i++) + interfacecgns[i] = cgsize_t(interface[i+1]); + int iConn; std::string neigbourZoneName = GetGroupName(myMesh->ShapeToIndex(neighbourSolid),meshDim); neigbourZoneName = neigbourZoneName.empty() ? "ZONESOLID" + std::to_string(myMesh->ShapeToIndex(neighbourSolid)) : neigbourZoneName; std::string interfaceName = zoneName + "_" + neigbourZoneName + "_" + std::to_string(interface[0]); if(cg_1to1_write(_fn, iBase, iZone, interfaceName.c_str(), neigbourZoneName.c_str(), - &interface[1], &interface[7], &interface[13], &iConn) != CG_OK) return addMessage(cg_get_error(), /*fatal = */true); + &interfacecgns[0], &interfacecgns[6], &interface[13], &iConn) != CG_OK) return addMessage(cg_get_error(), /*fatal = */true); } } @@ -398,13 +402,17 @@ Driver_Mesh::Status DriverStructuredCGNS_Write::Perform() grid->GetEdgeInterfaces(myMesh->GetTheGrid(neighbourFace).get(), interface); if ( !interface.empty() ) - { + { + std::vector interfacecgns( 8 ); + for (size_t i = 0; i < 8; i++) + interfacecgns[i] = cgsize_t(interface[i+1]); + int iConn; std::string neigbourZoneName = GetGroupName(myMesh->ShapeToIndex(neighbourFace),meshDim); neigbourZoneName = neigbourZoneName.empty() ? "ZONEFACE" + std::to_string(myMesh->ShapeToIndex(neighbourFace)) : neigbourZoneName; std::string interfaceName = zoneName + "_" + neigbourZoneName + "_" + std::to_string(interface[0]); if(cg_1to1_write(_fn, iBase, iZone, interfaceName.c_str(), neigbourZoneName.c_str(), - &interface[1], &interface[5], &interface[9], &iConn) != CG_OK) return addMessage(cg_get_error(), /*fatal = */true); + &interfacecgns[0], &interfacecgns[4], &interface[9], &iConn) != CG_OK) return addMessage(cg_get_error(), /*fatal = */true); } } diff --git a/src/SMESHUtils/SMESH_RegularGrid.cxx b/src/SMESHUtils/SMESH_RegularGrid.cxx index 60ea49bfc..b362656b8 100644 --- a/src/SMESHUtils/SMESH_RegularGrid.cxx +++ b/src/SMESHUtils/SMESH_RegularGrid.cxx @@ -82,33 +82,12 @@ std::tuple SMESH_RegularGrid::GetIJK(const int index) const std::vector SMESH_RegularGrid::getEdgeIndexLimitsInverted( const EdgeType edge ) const { - auto limits = getEdgeIndexLimits( edge ); + auto limits = getEdgeIndexLimits( edge ); std::swap(limits[0],limits[2]); std::swap(limits[1],limits[3]); return limits; } -std::vector SMESH_RegularGrid::getEdgeIndexLimits( const EdgeType edge ) const -{ - switch ( edge ) { - case EdgeType::BOTTOM: - return std::vector{1,1,mnx,1}; - break; - case EdgeType::RIGHT: - return std::vector{mnx,1,mnx,mny}; - break; - case EdgeType::TOP: - return std::vector{mnx,mny,1,mny}; - break; - case EdgeType::LEFT: - return std::vector{1,mny,1,1}; - break; - default: - return std::vector{1,1,mnx,1}; - break; - } -} - std::vector SMESH_RegularGrid::getFaceIndexLimits( const int start, const int end ) const { auto startIJK = GetIJK(start); @@ -133,33 +112,6 @@ std::vector SMESH_RegularGrid::getEdgeIndexLimits( const int start, const i return std::vector{iStart+1,jStart+1,iEnd+1,jEnd+1}; } -std::vector SMESH_RegularGrid::getFaceIndexLimits( const FaceType face ) const -{ - switch ( face ) { - case FaceType::B_BOTTOM: - return std::vector{1,1,1,mnx,mny,1}; /*V0-V2*/ - break; - case FaceType::B_RIGHT: - return std::vector{mnx,1,1,mnx,mny,mnz}; /*V1-V6*/ - break; - case FaceType::B_BACK: - return std::vector{1,mny,1,mnx,mny,mnz}; /*V3-V6*/ - break; - case FaceType::B_LEFT: - return std::vector{1,1,1,1,mny,mnz}; /*V0-V7*/ - break; - case FaceType::B_FRONT: - return std::vector{1,1,1,mnx,1,mnz}; /*V0-V5*/ - break; - case FaceType::B_TOP: - return std::vector{1,1,mnz,mnx,mny,mnz}; /*V4-V6*/ - break; - default: - return std::vector{1,1,1,mnx,mny,1}; - break; - } -} - int SMESH_RegularGrid::getEdgeSize( const EdgeType edge ) const { switch ( edge ) { @@ -199,22 +151,6 @@ int SMESH_RegularGrid::getFaceSize( const FaceType edge ) const } -void SMESH_RegularGrid::getAllEdgeIndexLimits(std::vector>& allRanges) -{ - this->foreachGridSide( [&]( EdgeType edge ) - { - allRanges.push_back( getEdgeIndexLimits(edge) ); - }); -} - -void SMESH_RegularGrid::getAllFaceIndexLimits(std::vector>& allRanges) -{ - this->foreachGridFace( [&]( FaceType face ) - { - allRanges.push_back( getFaceIndexLimits(face) ); - }); -} - std::vector SMESH_RegularGrid::nodesOfFace( SMESH_RegularGrid::FaceType face ) const { size_t faceSize=0; @@ -452,8 +388,8 @@ void SMESH_RegularGrid::GetCommontInterface( FaceType face, SMESH_RegularGrid * trueCorner[2] && trueCorner[3] ) /*Face to Face interface 100% conform*/ { - interfaceRange = this->getFaceIndexLimits( face ); - interfaceDonor = grid->getFaceIndexLimits( gridFace ); + interfaceRange = this->getFaceIndexLimits( face ); + interfaceDonor = grid->getFaceIndexLimits( gridFace ); } else if ( trueCorner[0] || trueCorner[1] || trueCorner[2] || trueCorner[3] ) /*Partial Face to Face. Only one intersection then all the other 3 vertex are: 2 in the edges 1 inside the face*/ @@ -468,7 +404,7 @@ void SMESH_RegularGrid::GetCommontInterface( FaceType face, SMESH_RegularGrid * { if ( nodeToSearch->IsEqual( *sidePoint, tol ) ) { - interfaceRange = this->getFaceIndexLimits( face ); + interfaceRange = this->getFaceIndexLimits( face ); auto startIndex = foundTrueColum(0,trueTable) ? std::get<0>(neighboorVertex) : foundTrueColum(2,trueTable) ? std::get<2>(neighboorVertex) : @@ -501,7 +437,7 @@ void SMESH_RegularGrid::GetCommontInterface( FaceType face, SMESH_RegularGrid * this->getFaceIndexLimits( startIndex, nodeIndex) : this->getFaceIndexLimits( nodeIndex, startIndex ); - interfaceDonor = grid->getFaceIndexLimits( gridFace ); + interfaceDonor = grid->getFaceIndexLimits( gridFace ); return; } }); @@ -542,7 +478,7 @@ void SMESH_RegularGrid::GetCommontInterface( EdgeType edge, SMESH_RegularGrid * if ( (trueTable[0] || trueTable[1] ) && /*Case start-end vertex are coincident in both edges trivial*/ (trueTable[2] ||trueTable[3] ) ) { - interfaceRange = this->getEdgeIndexLimits( edge ); + interfaceRange = this->getEdgeIndexLimits( edge ); interfaceDonor = grid->getEdgeIndexLimitsInverted( gridEdge ); } else if ( trueTable[0] || /*Case start OR end vertex are coincident in both edges*/ @@ -559,7 +495,7 @@ void SMESH_RegularGrid::GetCommontInterface( EdgeType edge, SMESH_RegularGrid * { if ( nodeToSearch->IsEqual( *sidePoint, tol ) ) { - interfaceRange = this->getEdgeIndexLimits( edge ); + interfaceRange = this->getEdgeIndexLimits( edge ); auto startIndex = (trueTable[0] || trueTable[2]) ? neighboorVertex.first : neighboorVertex.second; interfaceDonor = startIndex < nodeIndex ? grid->getEdgeIndexLimits( startIndex, nodeIndex ) : @@ -658,7 +594,7 @@ void SMESH_RegularGrid::GetCommontInterface( EdgeType edge, SMESH_RegularGrid * if ( startIndex != -1 && endIndex != -1 ) { - interfaceRange = this->getEdgeIndexLimits( edge ); + interfaceRange = this->getEdgeIndexLimits( edge ); interfaceDonor = grid->getEdgeIndexLimits( startIndex, endIndex ); } } diff --git a/src/SMESHUtils/SMESH_RegularGrid.hxx b/src/SMESHUtils/SMESH_RegularGrid.hxx index 2a437ecf6..8b5bfc8ac 100644 --- a/src/SMESHUtils/SMESH_RegularGrid.hxx +++ b/src/SMESHUtils/SMESH_RegularGrid.hxx @@ -27,14 +27,6 @@ //OCC #include #include - -//STD -#include -#include - -#include "SMESH_Utils.hxx" -#include "SMDS_MeshNode.hxx" - #include #include #include @@ -42,9 +34,16 @@ #include #include #include + +//STD +#include +#include #include #include +#include "SMESH_Utils.hxx" +#include "SMDS_MeshNode.hxx" + class Adaptor3d_Surface; class Adaptor2d_Curve2d; class Adaptor3d_Curve; @@ -219,19 +218,23 @@ namespace SMESHUtils void GetFaceInterfaces( SMESH_RegularGrid * grid, std::vector& interface ); // \brief Fill the allRanges vector with the boundaries of the grid - void getAllEdgeIndexLimits( std::vector>& allRanges ); + template + void getAllEdgeIndexLimits( std::vector>& allRanges ); // \brief Fill the allRanges vector with the boundaries of the grid - void getAllFaceIndexLimits( std::vector>& allRanges ); + template + void getAllFaceIndexLimits( std::vector>& allRanges ); // \brief Get limits of the edge in the order (ibegin,jbegin,iend,jend)+1 because index in CGNS are not zero based - std::vector getEdgeIndexLimits( const EdgeType edge ) const; + template + std::vector getEdgeIndexLimits( const EdgeType edge ) const; // \brief Get limits of the edge in the order (iend,jend,ibegin,jbegin)+1 because index in CGNS are not zero based std::vector getEdgeIndexLimitsInverted( const EdgeType edge ) const; // \brief Get limits of the face in the order (ibegin,jbegin,kbegin,iend,jend,kend)+1 because index in CGNS are not zero based - std::vector getFaceIndexLimits( SMESH_RegularGrid::FaceType face ) const; + template + std::vector getFaceIndexLimits( SMESH_RegularGrid::FaceType face ) const; // \brief Return the faceType to which the passed geometrical face belows to SMESH_RegularGrid::FaceType getFaceTypeByGeomFace( TopoDS_Shape shapeFace ) const; diff --git a/src/SMESHUtils/SMESH_RegularGridTemplate.hxx b/src/SMESHUtils/SMESH_RegularGridTemplate.hxx index 64972decc..f96c9c3d2 100644 --- a/src/SMESHUtils/SMESH_RegularGridTemplate.hxx +++ b/src/SMESHUtils/SMESH_RegularGridTemplate.hxx @@ -57,6 +57,74 @@ namespace SMESHUtils for (auto node : nodesOfFace(face)) function(myCoordinates[node],node); } + + template + std::vector SMESH_RegularGrid::getEdgeIndexLimits( const EdgeType edge ) const + { + switch ( edge ) { + case EdgeType::BOTTOM: + return std::vector{1,1,mnx,1}; + break; + case EdgeType::RIGHT: + return std::vector{mnx,1,mnx,mny}; + break; + case EdgeType::TOP: + return std::vector{mnx,mny,1,mny}; + break; + case EdgeType::LEFT: + return std::vector{1,mny,1,1}; + break; + default: + return std::vector{1,1,mnx,1}; + break; + } + } + + template + std::vector SMESH_RegularGrid::getFaceIndexLimits( const FaceType face ) const + { + switch ( face ) { + case FaceType::B_BOTTOM: + return std::vector{1,1,1,mnx,mny,1}; /*V0-V2*/ + break; + case FaceType::B_RIGHT: + return std::vector{mnx,1,1,mnx,mny,mnz}; /*V1-V6*/ + break; + case FaceType::B_BACK: + return std::vector{1,mny,1,mnx,mny,mnz}; /*V3-V6*/ + break; + case FaceType::B_LEFT: + return std::vector{1,1,1,1,mny,mnz}; /*V0-V7*/ + break; + case FaceType::B_FRONT: + return std::vector{1,1,1,mnx,1,mnz}; /*V0-V5*/ + break; + case FaceType::B_TOP: + return std::vector{1,1,mnz,mnx,mny,mnz}; /*V4-V6*/ + break; + default: + return std::vector{1,1,1,mnx,mny,1}; + break; + } + } + + template + void SMESH_RegularGrid::getAllEdgeIndexLimits(std::vector>& allRanges) + { + this->foreachGridSide( [&]( EdgeType edge ) + { + allRanges.push_back( getEdgeIndexLimits(edge) ); + }); + } + + template + void SMESH_RegularGrid::getAllFaceIndexLimits(std::vector>& allRanges) + { + this->foreachGridFace( [&]( FaceType face ) + { + allRanges.push_back( getFaceIndexLimits(face) ); + }); + } } diff --git a/test/SMESH_RegularGridTest.cxx b/test/SMESH_RegularGridTest.cxx index 8d3fd930f..38d0d4b07 100644 --- a/test/SMESH_RegularGridTest.cxx +++ b/test/SMESH_RegularGridTest.cxx @@ -93,7 +93,7 @@ bool testGetCommontInterface1D() std::vector interface; /* interface at right */ regularGrid0->GetEdgeInterfaces( regularGrid1.get(), interface ); - std::vector expectedRange = regularGrid0->getEdgeIndexLimits(SMESHUtils::SMESH_RegularGrid::RIGHT); + std::vector expectedRange = regularGrid0->getEdgeIndexLimits(SMESHUtils::SMESH_RegularGrid::RIGHT); std::vector expectedDonorRange = regularGrid1->getEdgeIndexLimitsInverted(SMESHUtils::SMESH_RegularGrid::LEFT); if ( interface.size() != 1+mny*2+2 ) @@ -189,19 +189,19 @@ bool testGetCommontInterface2D() regularGrid0->GetFaceInterfaces( regularGrid5.get(), interface[4] ); regularGrid0->GetFaceInterfaces( regularGrid6.get(), interface[5] ); - expectedRange[0] = regularGrid0->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_BOTTOM); - expectedRange[1] = regularGrid0->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_RIGHT); - expectedRange[2] = regularGrid0->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_BACK); - expectedRange[3] = regularGrid0->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_LEFT); - expectedRange[4] = regularGrid0->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_FRONT); - expectedRange[5] = regularGrid0->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_TOP); + expectedRange[0] = regularGrid0->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_BOTTOM); + expectedRange[1] = regularGrid0->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_RIGHT); + expectedRange[2] = regularGrid0->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_BACK); + expectedRange[3] = regularGrid0->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_LEFT); + expectedRange[4] = regularGrid0->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_FRONT); + expectedRange[5] = regularGrid0->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_TOP); - expectedDonorRange[0] = regularGrid1->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_TOP); - expectedDonorRange[1] = regularGrid2->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_LEFT); - expectedDonorRange[2] = regularGrid3->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_FRONT ); - expectedDonorRange[3] = regularGrid4->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_RIGHT); - expectedDonorRange[4] = regularGrid5->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_BACK); - expectedDonorRange[5] = regularGrid6->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_BOTTOM); + expectedDonorRange[0] = regularGrid1->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_TOP); + expectedDonorRange[1] = regularGrid2->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_LEFT); + expectedDonorRange[2] = regularGrid3->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_FRONT ); + expectedDonorRange[3] = regularGrid4->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_RIGHT); + expectedDonorRange[4] = regularGrid5->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_BACK); + expectedDonorRange[5] = regularGrid6->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_BOTTOM); int interfaceSize = 1+6*2+3; for ( auto itf : interface ) @@ -285,8 +285,8 @@ bool testGetPartialInterface2D() expectedRange[0] = std::vector({4,1,2,5,1,3}); expectedRange[1] = std::vector({1,4,1,1,2,2}); - expectedDonorRange[0] = regularGrid1->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_FRONT); - expectedDonorRange[1] = regularGrid2->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_LEFT); + expectedDonorRange[0] = regularGrid1->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_FRONT); + expectedDonorRange[1] = regularGrid2->getFaceIndexLimits(SMESHUtils::SMESH_RegularGrid::B_LEFT); int interfaceSize = 1+6*2+3; for ( auto itf : interface )