From c6b83a62b6e608e801943c86f17998d2f539cc1a Mon Sep 17 00:00:00 2001 From: Christophe Bourcier Date: Wed, 19 Dec 2018 13:50:53 +0100 Subject: [PATCH] Add reading of record 8 of sauv file (ascii and XDR) for Castem 17 --- resources/CMakeLists.txt | 2 + resources/castem17_result_ascii.sauv | 109 +++++++++++++++++++++++++++ resources/castem17_result_xdr.sauv | Bin 0 -> 2700 bytes src/MEDLoader/SauvReader.cxx | 34 +++++++++ src/MEDLoader/SauvReader.hxx | 1 + src/MEDLoader/Swig/SauvLoaderTest.py | 43 +++++++++++ 6 files changed, 189 insertions(+) create mode 100644 resources/castem17_result_ascii.sauv create mode 100644 resources/castem17_result_xdr.sauv 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 0000000000000000000000000000000000000000..27ac55b136deb740061f46aa4a58d22adabc9570 GIT binary patch literal 2700 zcmbW3O>PrG5QPT_e*qyRF3_x4uu04T@MPR=TCx*+GDfyH5k!$-!H*Dv3uetpkbo1w z_sqQDjATe?rP8mft6o>VZpSH#V!J92n>Y^hL0xEUVGmZQD6X~hP3BwJ)po6UyTzKW zwAeA?=wrj#JcQW-TZT}BYj6#o)mQ_@M)=E7D)(YjCVovq2$LKFTcIYd$@`)orsi-q zX`Y3Ust_{F8RiUghB?EWVa_mTm@~|iDao+qmE}k;20zDGQ`64zrK6^;Rp0eAq8;0TW3$&hxa_<0-!#Y?+0eG(-lG)Yu5 z29LpGaH8*o0Anm6P(mPSv(kum5(3d(7!xv4qx zff52?B!LkKBdNEXqR$k4rfd4>-RVu;!0uu@alff!3}OGEIm$abyY1X-=O>dKE4IVo zLEU6Pn`^DbqqnIydk4FY`ON}XSm($tJCq|Xou#^Ux8m2C{@mOK`)tK)Ut_%nuf?H# z)$1Wn#X4SVpQUr<{~M?FWQz3=zTcXC|2qc~RgY@6&gxfvt5)eC)7o{rX4R!Tkx3iX zCGC9oijz-y!q!o|@{99dn(Azw)78}Vvh~*y*mZy6(%J4)=ga4J<+^pAYnRXUyAI{M zclD%Rtd;w>X8-C>HHhmT<{^G@$~<)6z87&T#=7fF*XABovwYeUkM9h)!kRs_=Q`xm zdVOf^K6I{!de)xfwHA->*>6I%xCX`E;!A6?%V!?!{B>#!(w;rP}2cdy@m496c%PQv>aA3~g02V;F5U1W&s_F14-f9e&!+kf-r^y~iV*LMEV z&fm`bCy!o!;-`Op{(QDxeRUN@f5Y6KC!GSO;hr_ibdP=)(#m)5H?jUk^#-J&d=D`V z>)Z#+&W--L)x{T2zyFTil<)m6W7pr!@9uBPcig6Y?|1XN>rHX?dv@MM*N*e-e9!jx q?btAP_nqhPP5X}P?vtm#4bMjW=QcVjXU)O5Z1Qv#kMya${P+b(^z}CY literal 0 HcmV?d00001 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 -- 2.39.2