mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-26 09:20:34 +05:00
Fix export structured CGNS when there is a group on several volumes that leads to duplicate name in 1to1 connectivity
TODO: do not put _1 if there is only one group with this name
This commit is contained in:
parent
8db3567826
commit
1841c623c3
@ -81,7 +81,48 @@ std::string DriverStructuredCGNS_Write::GetGroupName( const int shapeToIndex, in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return std::string("");
|
// else by convention, create a group called ZONESOLID or ZONEFACE
|
||||||
|
std::string emptyZoneName("ZONE");
|
||||||
|
if (dim == 3)
|
||||||
|
emptyZoneName += "SOLID";
|
||||||
|
else
|
||||||
|
emptyZoneName += "FACE";
|
||||||
|
return emptyZoneName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DriverStructuredCGNS_Write::GetGroupNamesMap( const TopoDS_Shape& shape, int dim, std::map<unsigned int, std::string>& groupNameMapById )
|
||||||
|
{
|
||||||
|
// get all zone names
|
||||||
|
// get a unique name for each zone name
|
||||||
|
// std::map<unsigned int, std::string> groupNameMapById;
|
||||||
|
std::map<std::string, int> countGroupName;
|
||||||
|
TopAbs_ShapeEnum exploreType;
|
||||||
|
if (dim == 3)
|
||||||
|
exploreType = TopAbs_SOLID;
|
||||||
|
else
|
||||||
|
exploreType = TopAbs_FACE;
|
||||||
|
for ( TopExp_Explorer fEx( shape, exploreType ); fEx.More(); fEx.Next() )
|
||||||
|
{
|
||||||
|
unsigned int solidId;
|
||||||
|
if (dim == 3)
|
||||||
|
{
|
||||||
|
auto currentSolid = TopoDS::Solid(fEx.Current());
|
||||||
|
solidId = myMesh->ShapeToIndex(currentSolid);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto currentSolid = TopoDS::Face(fEx.Current());
|
||||||
|
solidId = myMesh->ShapeToIndex(currentSolid);
|
||||||
|
}
|
||||||
|
std::string zoneName = GetGroupName(solidId, dim);
|
||||||
|
// update the frequency count
|
||||||
|
countGroupName[zoneName]++;
|
||||||
|
int count = countGroupName[zoneName];
|
||||||
|
// Append frequency count to end of the string
|
||||||
|
zoneName += "_"+std::to_string(count);
|
||||||
|
// store the name
|
||||||
|
groupNameMapById[solidId] = zoneName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DriverStructuredCGNS_Write::CheckForGroupNameOnFaceInterfaces( const SMESHUtils::SMESH_RegularGrid* grid, std::vector<std::string>& boundaryNames )
|
void DriverStructuredCGNS_Write::CheckForGroupNameOnFaceInterfaces( const SMESHUtils::SMESH_RegularGrid* grid, std::vector<std::string>& boundaryNames )
|
||||||
@ -196,7 +237,10 @@ Driver_Mesh::Status DriverStructuredCGNS_Write::Perform()
|
|||||||
|
|
||||||
if ( meshDim == 3 )
|
if ( meshDim == 3 )
|
||||||
{
|
{
|
||||||
std::set<std::string> zNames;
|
// get a map of unique names for each solid
|
||||||
|
std::map<unsigned int, std::string> groupNameMapById;
|
||||||
|
GetGroupNamesMap(shape, meshDim, groupNameMapById);
|
||||||
|
// Fill the cgns info for each solid
|
||||||
for ( TopExp_Explorer fEx( shape, TopAbs_SOLID ); fEx.More(); fEx.Next() )
|
for ( TopExp_Explorer fEx( shape, TopAbs_SOLID ); fEx.More(); fEx.Next() )
|
||||||
{
|
{
|
||||||
TopoDS_Solid currentSolid = TopoDS::Solid(fEx.Current());
|
TopoDS_Solid currentSolid = TopoDS::Solid(fEx.Current());
|
||||||
@ -210,11 +254,8 @@ Driver_Mesh::Status DriverStructuredCGNS_Write::Perform()
|
|||||||
|
|
||||||
cgsize_t size[9] = {imax, jmax, kmax, imax - 1, jmax - 1, kmax - 1, 0, 0, 0};
|
cgsize_t size[9] = {imax, jmax, kmax, imax - 1, jmax - 1, kmax - 1, 0, 0, 0};
|
||||||
|
|
||||||
std::string zoneName = GetGroupName(myMesh->ShapeToIndex(currentSolid),meshDim);
|
unsigned int currentSolidId = myMesh->ShapeToIndex(currentSolid);
|
||||||
zoneName = zoneName.empty() ? "ZONESOLID" + std::to_string(myMesh->ShapeToIndex(currentSolid)) : zoneName;
|
std::string zoneName = groupNameMapById[currentSolidId];
|
||||||
if ( zNames.count(zoneName) != 0 )
|
|
||||||
zoneName = zoneName + "_" + std::to_string(myMesh->ShapeToIndex(currentSolid));
|
|
||||||
zNames.insert( zoneName );
|
|
||||||
// write Zone
|
// write Zone
|
||||||
int iZone;
|
int iZone;
|
||||||
if(cg_zone_write(_fn, iBase, zoneName.c_str(), size,
|
if(cg_zone_write(_fn, iBase, zoneName.c_str(), size,
|
||||||
@ -312,9 +353,10 @@ Driver_Mesh::Status DriverStructuredCGNS_Write::Perform()
|
|||||||
interfacecgns[i] = cgsize_t(interface[i+1]);
|
interfacecgns[i] = cgsize_t(interface[i+1]);
|
||||||
|
|
||||||
int iConn;
|
int iConn;
|
||||||
std::string neigbourZoneName = GetGroupName(myMesh->ShapeToIndex(neighbourSolid),meshDim);
|
unsigned int neighbourSolidId = myMesh->ShapeToIndex(neighbourSolid);
|
||||||
neigbourZoneName = neigbourZoneName.empty() ? "ZONESOLID" + std::to_string(myMesh->ShapeToIndex(neighbourSolid)) : neigbourZoneName;
|
std::string neigbourZoneName = groupNameMapById[neighbourSolidId];
|
||||||
std::string interfaceName = zoneName + "_" + neigbourZoneName + "_" + std::to_string(interface[0]);
|
// interfaceName must be unique (it should be by construction)
|
||||||
|
std::string interfaceName = zoneName + "_" + neigbourZoneName;
|
||||||
if(cg_1to1_write(_fn, iBase, iZone, interfaceName.c_str(), neigbourZoneName.c_str(),
|
if(cg_1to1_write(_fn, iBase, iZone, interfaceName.c_str(), neigbourZoneName.c_str(),
|
||||||
&interfacecgns[0], &interfacecgns[6], &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);
|
||||||
}
|
}
|
||||||
@ -326,7 +368,9 @@ Driver_Mesh::Status DriverStructuredCGNS_Write::Perform()
|
|||||||
}
|
}
|
||||||
else if ( meshDim == 2 )
|
else if ( meshDim == 2 )
|
||||||
{
|
{
|
||||||
std::set<std::string> zNames;
|
// get a map of unique names for each face
|
||||||
|
std::map<unsigned int, std::string> groupNameMapById;
|
||||||
|
GetGroupNamesMap(shape, meshDim, groupNameMapById);
|
||||||
for ( TopExp_Explorer fEx( shape, TopAbs_FACE ); fEx.More(); fEx.Next() )
|
for ( TopExp_Explorer fEx( shape, TopAbs_FACE ); fEx.More(); fEx.Next() )
|
||||||
{
|
{
|
||||||
TopoDS_Face currentFace = TopoDS::Face(fEx.Current());
|
TopoDS_Face currentFace = TopoDS::Face(fEx.Current());
|
||||||
@ -339,12 +383,9 @@ Driver_Mesh::Status DriverStructuredCGNS_Write::Perform()
|
|||||||
int iZone;
|
int iZone;
|
||||||
cgsize_t size[6] = {imax, jmax, imax - 1, jmax - 1, 0, 0};
|
cgsize_t size[6] = {imax, jmax, imax - 1, jmax - 1, 0, 0};
|
||||||
|
|
||||||
std::string zoneName = GetGroupName(myMesh->ShapeToIndex(currentFace),meshDim);
|
unsigned int currentFaceId = myMesh->ShapeToIndex(currentFace);
|
||||||
zoneName = zoneName.empty() ? "ZONEFACE" + std::to_string(myMesh->ShapeToIndex(currentFace)) : zoneName;
|
std::string zoneName = groupNameMapById[currentFaceId];
|
||||||
|
|
||||||
if ( zNames.count(zoneName) != 0 )
|
|
||||||
zoneName = zoneName + "_" + std::to_string(myMesh->ShapeToIndex(currentFace));
|
|
||||||
zNames.insert( zoneName );
|
|
||||||
// write Zone
|
// write Zone
|
||||||
if(cg_zone_write(_fn, iBase, zoneName.c_str(), size,
|
if(cg_zone_write(_fn, iBase, zoneName.c_str(), size,
|
||||||
CGNS_ENUMV(Structured), &iZone) != CG_OK)
|
CGNS_ENUMV(Structured), &iZone) != CG_OK)
|
||||||
@ -442,9 +483,9 @@ Driver_Mesh::Status DriverStructuredCGNS_Write::Perform()
|
|||||||
interfacecgns[i] = cgsize_t(interface[i+1]);
|
interfacecgns[i] = cgsize_t(interface[i+1]);
|
||||||
|
|
||||||
int iConn;
|
int iConn;
|
||||||
std::string neigbourZoneName = GetGroupName(myMesh->ShapeToIndex(neighbourFace),meshDim);
|
unsigned int neighbourFaceId = myMesh->ShapeToIndex(neighbourFace);
|
||||||
neigbourZoneName = neigbourZoneName.empty() ? "ZONEFACE" + std::to_string(myMesh->ShapeToIndex(neighbourFace)) : neigbourZoneName;
|
std::string neigbourZoneName = groupNameMapById[neighbourFaceId];
|
||||||
std::string interfaceName = zoneName + "_" + neigbourZoneName + "_" + std::to_string(interface[0]);
|
std::string interfaceName = zoneName + "_" + neigbourZoneName;
|
||||||
if(cg_1to1_write(_fn, iBase, iZone, interfaceName.c_str(), neigbourZoneName.c_str(),
|
if(cg_1to1_write(_fn, iBase, iZone, interfaceName.c_str(), neigbourZoneName.c_str(),
|
||||||
&interfacecgns[0], &interfacecgns[4], &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);
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
// occt
|
// occt
|
||||||
#include <TopoDS.hxx>
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
|
||||||
// smesh
|
// smesh
|
||||||
#include "SMESH_DriverCGNS.hxx"
|
#include "SMESH_DriverCGNS.hxx"
|
||||||
@ -65,6 +66,11 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int _fn; //!< file index
|
int _fn; //!< file index
|
||||||
|
/*!
|
||||||
|
* \brief Get the map between a solid (or face) id and its unique name.
|
||||||
|
* Add a suffix if needed to avoid duplicate group name.
|
||||||
|
*/
|
||||||
|
void GetGroupNamesMap( const TopoDS_Shape& shape, int dim, std::map<unsigned int, std::string>& groupNameMapById );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user