From: Christophe Bourcier Date: Wed, 19 Dec 2018 12:50:53 +0000 (+0100) Subject: Add reading of record 8 of sauv file (ascii and XDR) for Castem 17 X-Git-Tag: V9_3_0a1~42 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c6b83a62b6e608e801943c86f17998d2f539cc1a;p=tools%2Fmedcoupling.git Add reading of record 8 of sauv file (ascii and XDR) for Castem 17 --- diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 8934218c5..dec34a2c8 100644 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -89,6 +89,8 @@ SET(MED_other_FILES portico_3subs.sauv agitateur.med test_MED_MAIL.sauv + castem17_result_xdr.sauv + castem17_result_ascii.sauv ) SET(MED_RESOURCES_FILES ${MED_test_fig_files}) diff --git a/resources/castem17_result_ascii.sauv b/resources/castem17_result_ascii.sauv new file mode 100644 index 000000000..7f5f28fe9 --- /dev/null +++ b/resources/castem17_result_ascii.sauv @@ -0,0 +1,109 @@ + ENREGISTREMENT DE TYPE 4 + NIVEAU 19 NIVEAU ERREUR 0 DIMENSION 3 + DENSITE 0.00000E+00 + ENREGISTREMENT DE TYPE 7 + NOMBRE INFO CASTEM2000 8 + IFOUR 2 NIFOUR 0 IFOMOD 2 ILGNI 10 IIMPI 0 IOSPI 0 ISOTYP 1 + NSDPGE 0 + ENREGISTREMENT DE TYPE 8 + 4 64 + UX UY UZ RX RY RZ UR UT RT LX ALFABETAFBETP PI T RR TIN + FTSUPTH FC IUX IUY IUZ IRX IRY IRZ IUR IUT IRT PQ TP IP IPI AX AY + AZ B1X B1Y B1Z C1X C1Y C1Z D1X D1Y D1Z E1X E1Y E1Z B2X B2Y B2Z C2X C + 2Y C2Z D2X D2Y D2Z E2X E2Y E2Z PG PC VEL + 4 64 + FX FY FZ MX MY MZ FR FT MT FLX FALFFBETBETAFP FPI Q MR QIN + FQSUPFLUXED IFX IFY IFZ IMX IMY IMZ IFR IFT IMT FPQ FTP IFP IFPIFAX FA + Y FAZ FB1XFB1YFB1ZFC1XFC1YFC1ZFD1XFD1YFD1ZFE1XFE1YFE1ZFB2XFB2YFB2ZFC2XF + C2YFC2ZFD2XFD2YFD2ZFE2XFE2YFE2ZQG QC QEL + ENREGISTREMENT DE TYPE 2 + PILE NUMERO 1NBRE OBJETS NOMMES 6NBRE OBJETS 12 + ENTREE NOT_I001 NOT_I002 NOT_I003 PIECE SORTIE + 2 4 6 8 10 11 + 1 0 0 1 12 + 0 0 0 0 0 0 0 0 0 0 + 0 0 + 1 2 3 4 5 6 7 8 9 10 + 11 12 + 0 1 0 0 0 + 3 + 8 0 0 4 1 + 0 + 3 4 2 1 + 0 1 0 0 0 + 5 + 2 0 0 2 16 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 + 3 8 8 10 10 9 4 7 7 9 + 3 4 1 5 5 11 11 12 2 6 + 6 12 1 2 3 1 10 11 4 2 + 9 12 + 0 1 0 0 0 + 7 + 8 0 0 4 8 + 0 0 0 0 0 0 0 0 + 3 8 7 4 8 10 9 7 11 5 + 6 12 5 1 2 6 3 1 5 8 + 8 5 11 10 2 4 7 6 6 7 + 9 12 + 0 1 0 0 0 + 9 + 14 0 0 8 2 + 0 0 + 10 9 7 8 11 12 6 5 8 7 + 4 3 5 6 2 1 + 0 1 0 0 0 + 9 + 0 1 0 0 0 + 12 + 8 0 0 4 1 + 0 + 9 10 11 12 + ENREGISTREMENT DE TYPE 2 + PILE NUMERO 2NBRE OBJETS NOMMES 1NBRE OBJETS 1 + TEMP1 + 1 + 1 1 2 2 + -1 12 1 + SCAL + 0 + SCAL AIRE chp oint cre e pa r EX COMP + + 1 0 + 2.38461538461538E+02 2.38461538461539E+02 2.38461538461539E+02 + 2.38461538461538E+02 1.69230769230769E+02 1.69230769230769E+02 + 1.69230769230769E+02 1.69230769230769E+02 1.00000000000000E+02 + 1.00000000000000E+02 1.00000000000000E+02 1.00000000000000E+02 + ENREGISTREMENT DE TYPE 2 + PILE NUMERO 32NBRE OBJETS NOMMES 0NBRE OBJETS 12 + 12 + 6 8 2 4 11 12 10 9 3 1 + 5 7 + ENREGISTREMENT DE TYPE 2 + PILE NUMERO 33NBRE OBJETS NOMMES 0NBRE OBJETS 1 + 64 + 0.00000000000000E+00 0.00000000000000E+00 2.00000000000000E+00 + 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 + 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 + 1.00000000000000E+00 2.00000000000000E+00 0.00000000000000E+00 + 0.00000000000000E+00 1.00000000000000E+00 0.00000000000000E+00 + 0.00000000000000E+00 1.00000000000000E+00 0.00000000000000E+00 + 2.00000000000000E+00 0.00000000000000E+00 1.00000000000000E+00 + 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 + 1.00000000000000E+00 1.00000000000000E+00 2.00000000000000E+00 + 0.00000000000000E+00 1.00000000000000E+00 1.00000000000000E+00 + 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 + 0.00000000000000E+00 1.00000000000000E+00 0.00000000000000E+00 + 0.00000000000000E+00 1.00000000000000E+00 1.00000000000000E+00 + 0.00000000000000E+00 1.00000000000000E+00 0.00000000000000E+00 + 1.00000000000000E+00 0.00000000000000E+00 1.00000000000000E+00 + 1.00000000000000E+00 1.00000000000000E+00 0.00000000000000E+00 + 0.00000000000000E+00 1.00000000000000E+00 2.00000000000000E+00 + 0.00000000000000E+00 0.00000000000000E+00 0.00000000000000E+00 + 2.00000000000000E+00 0.00000000000000E+00 1.00000000000000E+00 + 0.00000000000000E+00 2.00000000000000E+00 0.00000000000000E+00 + 1.00000000000000E+00 1.00000000000000E+00 2.00000000000000E+00 + 0.00000000000000E+00 + ENREGISTREMENT DE TYPE 5 +LABEL_AUTOMATIQUE_1 diff --git a/resources/castem17_result_xdr.sauv b/resources/castem17_result_xdr.sauv new file mode 100644 index 000000000..27ac55b13 Binary files /dev/null and b/resources/castem17_result_xdr.sauv differ diff --git a/src/MEDLoader/SauvReader.cxx b/src/MEDLoader/SauvReader.cxx index 83db0a35e..75fd35709 100644 --- a/src/MEDLoader/SauvReader.cxx +++ b/src/MEDLoader/SauvReader.cxx @@ -139,6 +139,8 @@ MEDCoupling::MEDFileData * SauvReader::loadInMEDFileDS() readRecord4(); else if (recordNumber == 7 ) readRecord7(); + else if (recordNumber == 8 ) + readRecord8(); else if (recordNumber == 5 ) break; // stop reading else @@ -212,6 +214,38 @@ void SauvReader::readRecord7() } } +//================================================================================ +/*! + * \brief Reads "ENREGISTREMENT DE TYPE 8" + */ +//================================================================================ + +void SauvReader::readRecord8() +{ + // This record is useless (a constant table) + // => we skip it + int info; + int nbIntToSkip; + if ( !isASCII() ) + { + getInt(); + info = getInt(); + int i = 0; + if (info == 3) { + // castem >= 18 + // 1 more line + nbIntToSkip = 145; + } + else + nbIntToSkip = 141; + + while (i <= nbIntToSkip) { + getInt(); + i ++; + } + } +} + //================================================================================ /*! * \brief Reads the pile number, nb of objects and nb named of objects diff --git a/src/MEDLoader/SauvReader.hxx b/src/MEDLoader/SauvReader.hxx index d6d6ebe03..e2135a422 100644 --- a/src/MEDLoader/SauvReader.hxx +++ b/src/MEDLoader/SauvReader.hxx @@ -56,6 +56,7 @@ class SauvReader : public MEDCoupling::RefCountObject void readRecord2(); void readRecord4(); void readRecord7(); + void readRecord8(); int readPileNumber(int& nbNamedObjects, int& nbObjects); void read_PILE_SOUS_MAILLAGE(const int nbObjects, std::vector& objectNames, std::vector& nameIndices); diff --git a/src/MEDLoader/Swig/SauvLoaderTest.py b/src/MEDLoader/Swig/SauvLoaderTest.py index f9454b1b1..4cdf773ba 100644 --- a/src/MEDLoader/Swig/SauvLoaderTest.py +++ b/src/MEDLoader/Swig/SauvLoaderTest.py @@ -322,6 +322,49 @@ class SauvLoaderTest(unittest.TestCase): self.assertTrue(ids1.isEqual(ids2)) pass + @unittest.skipUnless(HasXDR(),"requires XDR") + def testReadSauvXDRCastem17(self): + """test reading Castem17 XDR sauv with 'ENREGISTREMENT DE TYPE 8'""" + sauvFile = os.path.join(self.__getResourcesDirectory(),"castem17_result_xdr.sauv") + self.assertTrue( os.access( sauvFile, os.F_OK)) + sr=SauvReader.New(sauvFile) + mfd2=sr.loadInMEDFileDS() + mfMesh=mfd2.getMeshes()[0] + umesh0 = mfMesh.getMeshAtLevel(0) + # + self.assertEqual(2,umesh0.getNumberOfCellsWithType( NORM_HEXA8 )) + self.assertEqual(12,umesh0.getNumberOfNodes()) + # + mfField=mfd2.getFields().getFieldWithName("TEMP1") + iterations = mfField.getIterations() + field0 = mfField.getFieldOnMeshAtLevel(ON_NODES, iterations[0][0],iterations[0][1],umesh0) + fieldArray = field0.getArray() + expectedValues = [238.46153846153845]*4 + [169.23076923076923]*4 + [100]*4 + expectedArray = DataArrayDouble(expectedValues) + self.assertTrue( fieldArray.isEqualWithoutConsideringStr( expectedArray, 1e-12 )) + pass + + def testReadSauvAsciiCastem17(self): + """test reading Castem17 ascii sauv with 'ENREGISTREMENT DE TYPE 8'""" + sauvFile = os.path.join(self.__getResourcesDirectory(),"castem17_result_ascii.sauv") + self.assertTrue( os.access( sauvFile, os.F_OK)) + sr=SauvReader.New(sauvFile) + mfd2=sr.loadInMEDFileDS() + mfMesh=mfd2.getMeshes()[0] + umesh0 = mfMesh.getMeshAtLevel(0) + # + self.assertEqual(2,umesh0.getNumberOfCellsWithType( NORM_HEXA8 )) + self.assertEqual(12,umesh0.getNumberOfNodes()) + # + mfField=mfd2.getFields().getFieldWithName("TEMP1") + iterations = mfField.getIterations() + field0 = mfField.getFieldOnMeshAtLevel(ON_NODES, iterations[0][0],iterations[0][1],umesh0) + fieldArray = field0.getArray() + expectedValues = [238.46153846153845]*4 + [169.23076923076923]*4 + [100]*4 + expectedArray = DataArrayDouble(expectedValues) + self.assertTrue( fieldArray.isEqualWithoutConsideringStr( expectedArray, 1e-12 )) + pass + def testGaussPt(self): """issue 22321: [CEA 933] Bug when reading a sauve file containing field on Gauss Pt. The problem was that a field ON_GAUSS_PT was created but no Gauss Localization