From bbc39cc2f05ecdbe0e9256846599dc882f872563 Mon Sep 17 00:00:00 2001 From: Anida Khizar Date: Fri, 17 Mar 2023 14:46:53 +0100 Subject: [PATCH] Fix partitionner --- .../MEDPARTITIONER_MeshCollection.cxx | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx index 0f748cb6e..cc4aed453 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx @@ -151,7 +151,7 @@ MEDPARTITIONER::MeshCollection::MeshCollection(MeshCollection& initialCollection this->getMesh(), initialCollection.getCellFamilyIds(), "cellFamily"); - castIntField(initialCollection.getFaceMesh(), + castIntField(initialCollection.getFaceMesh(), this->getFaceMesh(), initialCollection.getFaceFamilyIds(), "faceFamily"); @@ -489,6 +489,8 @@ void MEDPARTITIONER::MeshCollection::castFaceMeshes(MeshCollection& initialColle //initial face mesh known : in my domain if (meshesCastFrom[iold] != 0) { +// std::cerr << "NUMBER OF FACES = " << meshesCastFrom[iold]->getNumberOfCells() << std::endl; +// WriteUMesh("OrigMesh.med",meshesCastFrom[iold],true); for (mcIdType ielem=0; ielemgetNumberOfCells(); ielem++) { vector nodes; @@ -520,6 +522,7 @@ void MEDPARTITIONER::MeshCollection::castFaceMeshes(MeshCollection& initialColle for (map::iterator iter=faces.begin(); iter!=faces.end(); iter++) { +// std::cerr << "TREATING FACE " << iter->first << " " << boundaryElem->findIdFirstEqual(iter->first) << std::endl; if (iter->second==ToIdType(nodes.size())) //cvw eligible but may be have to be face of a cell of this->getMesh()[inew]? //it is not sure here... @@ -591,13 +594,16 @@ void MEDPARTITIONER::MeshCollection::castFaceMeshes(MeshCollection& initialColle meshesCastTo.resize(nbNewDomain); for (int inew=0; inew myMeshes; + vector myMeshes; for (int iold=0; ioldgetNumberOfCells()>0) + { myMeshes.push_back(umesh); +// WriteUMesh("mesh_"+std::to_string(inew)+".med",umesh,true); + } } MEDCoupling::MEDCouplingUMesh *bndMesh = 0; @@ -608,12 +614,25 @@ void MEDPARTITIONER::MeshCollection::castFaceMeshes(MeshCollection& initialColle bndMesh = ((MEDCoupling::MEDCouplingUMesh *)_mesh[inew]->buildBoundaryMesh(/*keepCoords=*/true)); if (bndMesh->getNumberOfCells()>0) - myMeshes.push_back( bndMesh ); + { +// WriteUMesh("boundary_mesh_"+std::to_string(inew)+".med",bndMesh,true); + myMeshes.push_back( bndMesh ); + } } +// for(int loc_mesh = 0;loc_mesh < myMeshes.size(); loc_mesh++) +// WriteUMesh("mesh_"+std::to_string(inew)+"_"+std::to_string(loc_mesh)+".med",myMeshes[loc_mesh],true); + if (myMeshes.size()>0) { - meshesCastTo[inew]=MEDCoupling::MEDCouplingUMesh::MergeUMeshes(myMeshes); + // Need to merge faces that are both in the initial set of faces and in the boundary mesh + // which is the last element in myMeshes: + for (int iold2 = 0; iold2 < nbOldDomain-1; iold2++) + myMeshes[iold2]->tryToShareSameCoordsPermute(*bndMesh, 1.e-10); + vector myMeshes_c; + for (auto & e: myMeshes) myMeshes_c.push_back(e); + meshesCastTo[inew]=MEDCoupling::MEDCouplingUMesh::MergeUMeshesOnSameCoords(myMeshes_c); + MCAuto tmp = meshesCastTo[inew]->zipConnectivityTraducer(2); meshesCastTo[inew]->sortCellsInMEDFileFrmt()->decrRef(); } else -- 2.39.2