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.
This commit is contained in:
Christophe Bourcier 2023-10-03 16:48:51 +02:00
parent 6c60849534
commit 1c972ebcce

View File

@ -675,6 +675,8 @@ namespace
for ( int iN = 0; iN < nbNodesInGroup; ++iN ) for ( int iN = 0; iN < nbNodesInGroup; ++iN )
{ {
n = aMeshDS->FindNode( nodeIDs[iN] ); n = aMeshDS->FindNode( nodeIDs[iN] );
if (!n)
continue;
// check nodes of elements of theElemType around n // check nodes of elements of theElemType around n
SMDS_ElemIteratorPtr elOfTypeIt = n->GetInverseElementIterator( anElemType ); SMDS_ElemIteratorPtr elOfTypeIt = n->GetInverseElementIterator( anElemType );
while ( elOfTypeIt->more() ) while ( elOfTypeIt->more() )
@ -1286,21 +1288,24 @@ Driver_Mesh::Status DriverCGNS_Read::Perform()
} }
else // unstructured zone 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 // ids are ids of all nodes, not stored element by element
// so we can't use findElement // so we can't use findElement
// => Use findElements adapted from CreateDimGroup instead // => Use findElements adapted from CreateDimGroup instead
findElements(ids, myMesh, elemType, groupDS); 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 else
{ {
MESSAGE(" BC not on vertices");
if ( zone._elemIdShift ) if ( zone._elemIdShift )
for ( size_t i = 0; i < ids.size(); ++i ) for ( size_t i = 0; i < ids.size(); ++i )
ids[i] += zone._elemIdShift; 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 ) for ( cgsize_t i = ids[0]; i <= ids[1]; ++i )
if ( const SMDS_MeshElement* e = myMesh->FindElement( i )) if ( const SMDS_MeshElement* e = myMesh->FindElement( i ))