From: Christophe Bourcier Date: Fri, 12 Jan 2018 10:28:09 +0000 (+0100) Subject: Fix bug when reading Castem sauv file with more than 1 million nodes X-Git-Tag: V9_0_0~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b37f156348ff1f1627595a01d915f3be831be650;p=tools%2Fmedcoupling.git Fix bug when reading Castem sauv file with more than 1 million nodes --- diff --git a/src/MEDLoader/SauvReader.cxx b/src/MEDLoader/SauvReader.cxx index 38c0651eb..83db0a35e 100644 --- a/src/MEDLoader/SauvReader.cxx +++ b/src/MEDLoader/SauvReader.cxx @@ -220,7 +220,7 @@ void SauvReader::readRecord7() int SauvReader::readPileNumber(int& nbNamedObjects, int& nbObjects) { - // FORMAT(' PILE NUMERO',I4,'NBRE ObjectS NOMMES',I8,'NBRE ObjectS',I8) + // FORMAT(' PILE NUMERO',I4,'NBRE OBJETS NOMMES',I8,'NBRE OBJETS',I8) int pileNumber; if ( !isASCII() ) { @@ -233,7 +233,7 @@ int SauvReader::readPileNumber(int& nbNamedObjects, int& nbObjects) { char* line; getNextLine(line); - const char *s1 = " PILE NUMERO", *s2 = "NBRE ObjectS NOMMES", *s3 = "NBRE ObjectS"; + const char *s1 = " PILE NUMERO", *s2 = "NBRE OBJETS NOMMES", *s3 = "NBRE OBJETS"; if ( ! GIBI_EQUAL( line, s1 ) ) THROW_IK_EXCEPTION("Could not read the pile number " << lineNb() ); line = line + strlen(s1); diff --git a/src/MEDLoader/Swig/SauvLoaderTest.py b/src/MEDLoader/Swig/SauvLoaderTest.py index 5b2559385..44c1ef682 100644 --- a/src/MEDLoader/Swig/SauvLoaderTest.py +++ b/src/MEDLoader/Swig/SauvLoaderTest.py @@ -248,6 +248,58 @@ class SauvLoaderTest(unittest.TestCase): os.remove(sauvFile) pass + def testSauvReaderOnBigMesh(self): + # create a box with 1 million cells + mesh_dim = 3 + nb_segs = [100, 100, 100] + box_sizes = [1., 1., 1.] + compo_names = ["x", "y", "z"] + box_steps = [box_sizes[i]/nb_segs[i] for i in xrange(mesh_dim)] + mesh = MEDCouplingCMesh.New("Mesh_box") + + # axes coords + axes_arrays = [] + for i in xrange(mesh_dim): + axe_coords = [j*box_steps[i] for j in xrange(nb_segs[i]+1)] + + axe_arr = DataArrayDouble.New(axe_coords) + axe_arr.setInfoOnComponent(0,compo_names[i]) + + axes_arrays.append(axe_arr) + + mesh.setCoords(*axes_arrays) + umesh = mesh.buildUnstructured() + + m=MEDFileUMesh.New() + m.setMeshAtLevel(0,umesh) + + # MED file data + ms=MEDFileMeshes.New() + ms.setMeshAtPos(0,m) + meddata=MEDFileData.New() + meddata.setMeshes(ms) + + # write to SAUV + sauvFile = "box.sauv" + sw=SauvWriter(); + sw.setMEDFileDS(meddata); + sw.write(sauvFile); + + # read SAUV + sr=SauvReader(sauvFile); + d2=sr.loadInMEDFileDS(); + mm = d2.getMeshes() + m = mm.getMeshAtPos(0) + + # check + coords = m.getCoords() + nb_coords_values = coords.getNbOfElems() + nb_coords_values_expected = mesh_dim*((nb_segs[0]+1)*(nb_segs[1]+1)*(nb_segs[2]+1)) + self.assertEqual(nb_coords_values, nb_coords_values_expected) + + os.remove( sauvFile ) + pass + @unittest.skipUnless(HasXDR(),"requires XDR") def testMissingGroups(self): """test for issue 0021749: [CEA 601] Some missing groups in mesh after reading a SAUV file with SauvReader."""