+ use list of pairs instead of map for getVolumesByFace

This commit is contained in:
wmayer 2015-05-09 12:02:25 +02:00
parent fbdfeef2a3
commit 45604b3874
3 changed files with 8 additions and 7 deletions

View File

@ -406,9 +406,9 @@ std::set<long> FemMesh::getSurfaceNodes(long ElemId, short FaceId, float Angle)
/*! That function returns map containing volume ID and face ID. /*! That function returns map containing volume ID and face ID.
*/ */
std::map<int, int> FemMesh::getVolumesByFace(const TopoDS_Face &face) const std::list<std::pair<int, int> > FemMesh::getVolumesByFace(const TopoDS_Face &face) const
{ {
std::map<int, int> result; std::list<std::pair<int, int> > result;
std::set<int> nodes_on_face = getNodesByFace(face); std::set<int> nodes_on_face = getNodesByFace(face);
SMDS_VolumeIteratorPtr vol_iter = myMesh->GetMeshDS()->volumesIterator(); SMDS_VolumeIteratorPtr vol_iter = myMesh->GetMeshDS()->volumesIterator();
@ -430,13 +430,14 @@ std::map<int, int> FemMesh::getVolumesByFace(const TopoDS_Face &face) const
std::set_intersection(nodes_on_face.begin(), nodes_on_face.end(), face_nodes.begin(), face_nodes.end(), std::set_intersection(nodes_on_face.begin(), nodes_on_face.end(), face_nodes.begin(), face_nodes.end(),
std::back_insert_iterator<std::vector<int> >(element_face_nodes)); std::back_insert_iterator<std::vector<int> >(element_face_nodes));
// For curved faces it is possible that a volume contributes more than one face
if (element_face_nodes.size() == numNodes) { if (element_face_nodes.size() == numNodes) {
result[vol->GetID()] = face->GetID(); result.push_back(std::make_pair(vol->GetID(), face->GetID()));
break;
} }
} }
} }
result.sort();
return result; return result;
} }

View File

@ -96,7 +96,7 @@ public:
/// retrieving node IDs by element ID /// retrieving node IDs by element ID
std::set<int> getElementNodes(int id) const; std::set<int> getElementNodes(int id) const;
/// retrieving volume IDs and face IDs number by face /// retrieving volume IDs and face IDs number by face
std::map<int, int> getVolumesByFace(const TopoDS_Face &face) const; std::list<std::pair<int, int> > getVolumesByFace(const TopoDS_Face &face) const;
/// retrieving volume IDs and CalculiX face number by face /// retrieving volume IDs and CalculiX face number by face
std::map<int, int> getccxVolumesByFace(const TopoDS_Face &face) const; std::map<int, int> getccxVolumesByFace(const TopoDS_Face &face) const;
//@} //@}

View File

@ -530,8 +530,8 @@ PyObject* FemMeshPy::getVolumesByFace(PyObject *args)
const TopoDS_Face& fc = TopoDS::Face(sh); const TopoDS_Face& fc = TopoDS::Face(sh);
Py::List ret; Py::List ret;
std::map<int, int> resultSet = getFemMeshPtr()->getVolumesByFace(fc); std::list<std::pair<int, int> > resultSet = getFemMeshPtr()->getVolumesByFace(fc);
for (std::map<int, int>::const_iterator it = resultSet.begin();it!=resultSet.end();++it) { for (std::list<std::pair<int, int> >::const_iterator it = resultSet.begin();it!=resultSet.end();++it) {
Py::Tuple vol_face(2); Py::Tuple vol_face(2);
vol_face.setItem(0, Py::Int(it->first)); vol_face.setItem(0, Py::Int(it->first));
vol_face.setItem(1, Py::Int(it->second)); vol_face.setItem(1, Py::Int(it->second));