From: Christophe Bourcier Date: Tue, 3 Oct 2023 14:48:51 +0000 (+0200) Subject: Fix in case the mesh is unstructured and BC is on ElementRange. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fcbr%2Ffix_cgns_reader_BC;p=modules%2Fsmesh.git Fix in case the mesh is unstructured and BC is on ElementRange. Case of backstep5_4levdn_u.cgns TODO: check if unstructured and BC is on PointRange works. --- diff --git a/src/DriverCGNS/DriverCGNS_Read.cxx b/src/DriverCGNS/DriverCGNS_Read.cxx index 8f8c9faf2..a8e334657 100644 --- a/src/DriverCGNS/DriverCGNS_Read.cxx +++ b/src/DriverCGNS/DriverCGNS_Read.cxx @@ -675,6 +675,8 @@ namespace for ( int iN = 0; iN < nbNodesInGroup; ++iN ) { n = aMeshDS->FindNode( nodeIDs[iN] ); + if (!n) + continue; // check nodes of elements of theElemType around n SMDS_ElemIteratorPtr elOfTypeIt = n->GetInverseElementIterator( anElemType ); while ( elOfTypeIt->more() ) @@ -1286,21 +1288,24 @@ Driver_Mesh::Status DriverCGNS_Read::Perform() } else // unstructured zone { - if (location == CGNS_ENUMV( Vertex )) + MESSAGE(" group on unstructured zone. "); + if (location == CGNS_ENUMV( Vertex ) && psType != CGNS_ENUMV( ElementRange )) { + MESSAGE(" BC on vertices"); // ids are ids of all nodes, not stored element by element // so we can't use findElement // => Use findElements adapted from CreateDimGroup instead findElements(ids, myMesh, elemType, groupDS); - MESSAGE(" group on unstructured zone. " << groupDS.Extent() << " elements have been added to " << groupName); + MESSAGE(" " << groupDS.Extent() << " elements have been added to " << groupName); } else { + MESSAGE(" BC not on vertices"); if ( zone._elemIdShift ) for ( size_t i = 0; i < ids.size(); ++i ) ids[i] += zone._elemIdShift; - if ( psType == CGNS_ENUMV( PointRange ) && ids.size() == 2 ) + if ( (psType == CGNS_ENUMV( PointRange ) || psType == CGNS_ENUMV( ElementRange )) && ids.size() == 2 ) { for ( cgsize_t i = ids[0]; i <= ids[1]; ++i ) if ( const SMDS_MeshElement* e = myMesh->FindElement( i ))