]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Add reading of record 8 of sauv file (ascii and XDR) for Castem 17 cbr/upgrade_sauvreader
authorChristophe Bourcier <christophe.bourcier@cea.fr>
Wed, 19 Dec 2018 12:50:53 +0000 (13:50 +0100)
committerChristophe Bourcier <christophe.bourcier@cea.fr>
Wed, 19 Dec 2018 12:50:53 +0000 (13:50 +0100)
resources/CMakeLists.txt
resources/castem17_result_ascii.sauv [new file with mode: 0644]
resources/castem17_result_xdr.sauv [new file with mode: 0644]
src/MEDLoader/SauvReader.cxx
src/MEDLoader/SauvReader.hxx
src/MEDLoader/Swig/SauvLoaderTest.py

index 8934218c5cce30760bcf3da1db6ac57df6191159..dec34a2c8814f03e4bbfa34ec8a9a69d4ae3a9a2 100644 (file)
@@ -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 (file)
index 0000000..7f5f28f
--- /dev/null
@@ -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 (file)
index 0000000..27ac55b
Binary files /dev/null and b/resources/castem17_result_xdr.sauv differ
index 83db0a35ece2df75d75e00dd00738829807626e5..75fd357098c1934d6b056989c774264929ffd66e 100644 (file)
@@ -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
index d6d6ebe03a100c0fba23bc3a7d5ec578150c2724..e2135a4220edf7f8013f9921e4de2645f342248b 100644 (file)
@@ -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<std::string>& objectNames, std::vector<int>& nameIndices);
index f9454b1b183c3fd765b2805dcdbe4b0db599178d..4cdf773ba2dde85d5e4d3c81ca4462d308c89f88 100644 (file)
@@ -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