From: jfa Date: Wed, 17 Nov 2021 13:27:38 +0000 (+0300) Subject: [bos #26432] [CEA 26431] import/export SAUV removal X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fjfa%2F26432_rm_sauv;p=tools%2Fmedcoupling.git [bos #26432] [CEA 26431] import/export SAUV removal --- diff --git a/doc/developer/doxygen/doxfiles/reference/misc/tools.dox b/doc/developer/doxygen/doxfiles/reference/misc/tools.dox index 3c69b6709..ed99f3afa 100644 --- a/doc/developer/doxygen/doxfiles/reference/misc/tools.dox +++ b/doc/developer/doxygen/doxfiles/reference/misc/tools.dox @@ -74,27 +74,4 @@ It can be used in this way : renumber MEDFile_in MeshName Method[BOOST/METIS] MEDFile_out \endcode -\section sauv2med sauv2med tool - -The sauv2med tool enable conversion from a Cast3m \a sauv file into a -MED file. It is a python script that encapsulates the read/write -drivers provided by the MEDLoader library. - -Calling -\code -sauv2med myfile.sauv -\endcode -generates a \a med file named \a myfile.sauv.med - -\section med2sauv med2sauv tool - -med2sauv operator is the operator that is inverse of sauv2med. Its -behaviour is symmetrical. - -Calling -\code -med2sauv myfile.med -\endcode -generates a \a sauv file named \a myfile.med.sauv - */ diff --git a/src/MEDLoader/Swig/CMakeLists.txt b/src/MEDLoader/Swig/CMakeLists.txt index d9e3beec2..36be2c718 100644 --- a/src/MEDLoader/Swig/CMakeLists.txt +++ b/src/MEDLoader/Swig/CMakeLists.txt @@ -101,10 +101,6 @@ INSTALL(FILES ${ALL_TESTS} MEDLoaderDataForTest.py MEDLoaderTest1.py MEDLoaderTe INSTALL(FILES CaseIO.py CaseReader.py CaseWriter.py VTKReader.py DESTINATION ${MEDCOUPLING_INSTALL_PYTHON}) -INSTALL(FILES medutilities.py DESTINATION ${MEDCOUPLING_INSTALL_PYTHON}) - -INSTALL(FILES med2sauv PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${MEDCOUPLING_INSTALL_BINS} ) -INSTALL(FILES sauv2med PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${MEDCOUPLING_INSTALL_BINS} ) INSTALL(FILES case2med PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${MEDCOUPLING_INSTALL_BINS} ) INSTALL(FILES med2case PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${MEDCOUPLING_INSTALL_BINS} ) INSTALL(FILES ConvertMEDFileTo33.py ConvertMEDFileTo30.py PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${MEDCOUPLING_INSTALL_BINS} ) @@ -145,7 +141,6 @@ SET(MEDLOADER_TEST_FILES CaseWriter.py VTKReader.py MEDLoaderSplitter.py - medutilities.py ) INSTALL(FILES ${MEDLOADER_TEST_FILES} DESTINATION ${TEST_INSTALL_DIRECTORY}) diff --git a/src/MEDLoader/Swig/SauvLoaderTest.py b/src/MEDLoader/Swig/SauvLoaderTest.py deleted file mode 100644 index f461953fc..000000000 --- a/src/MEDLoader/Swig/SauvLoaderTest.py +++ /dev/null @@ -1,504 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2021 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# Author : Edward AGAPOV (eap) - -from MEDLoader import * -import unittest, os -from MEDLoaderDataForTest import MEDLoaderDataForTest,WriteInTmpDir - -class SauvLoaderTest(unittest.TestCase): - - def __getResourcesDirectory(self): - med_root_dir = os.getenv("MEDCOUPLING_ROOT_DIR") - if med_root_dir: - pth = os.path.join( os.getenv("MEDCOUPLING_ROOT_DIR"), "share","resources","med") - if os.path.exists(pth): - return pth - current_dir = os.path.dirname(os.path.realpath(__file__)) - pth = os.path.join(current_dir, "..", "..", "..", "resources") - if not os.path.exists(pth): - raise Exception("SauvLoaderTest: Unable to get resource directory") - return pth - pass - - @WriteInTmpDir - def testSauv2Med(self): - # get a file containing all types of readable piles - sauvFile = os.path.join( self.__getResourcesDirectory(),"allPillesTest.sauv") - self.assertTrue( os.access( sauvFile, os.F_OK)) - - # read SAUV and write MED - medFile = "SauvLoaderTest.med" - sr=SauvReader(sauvFile); - d2=sr.loadInMEDFileDS(); - d2.write(medFile,0); - - # check - self.assertEqual(1,d2.getNumberOfMeshes()) - self.assertEqual(8+97,d2.getNumberOfFields()) - mm = d2.getMeshes() - m = mm.getMeshAtPos(0) - self.assertEqual(17,len(m.getGroupsNames())) - - os.remove( medFile ) - pass - - @WriteInTmpDir - def testMed2Sauv(self): - # read pointe.med - medFile = os.path.join(self.__getResourcesDirectory(),"pointe.med") - self.assertTrue( os.access( medFile, os.F_OK)) - pointeMed = MEDFileData.New( medFile ) - - # add 3 faces to pointeMed - pointeMedMesh = pointeMed.getMeshes().getMeshAtPos(0) - pointeM1D = MEDCouplingUMesh.New() - pointeM1D.setCoords( pointeMedMesh.getCoords() ) - pointeM1D.setMeshDimension( 2 ) - pointeM1D.allocateCells( 3 ) - pointeM1D.insertNextCell( NORM_TRI3, 3, [0,1,2]) - pointeM1D.insertNextCell( NORM_TRI3, 3, [0,1,3]) - pointeM1D.insertNextCell( NORM_QUAD4, 4, [10,11,12,13]) - pointeM1D.finishInsertingCells() - pointeMedMesh.setMeshAtLevel( -1, pointeM1D ) - pointeMed.getMeshes().setMeshAtPos( 0, pointeMedMesh ) - - # add a field on 2 faces to pointeMed - ff1=MEDFileFieldMultiTS.New() - f1=MEDCouplingFieldDouble.New(ON_GAUSS_NE,ONE_TIME) - #f1.setMesh( pointeM1D ) - f1.setName("Field on 2 faces") - d=DataArrayDouble.New() - d.alloc(3+4,2) - d.setInfoOnComponent(0,"sigX [MPa]") - d.setInfoOnComponent(1,"sigY [GPa]") - d.setValues([311,312,321,322,331,332,411,412,421,422,431,432,441,442],3+4,2) - f1.setArray(d) - da=DataArrayInt.New() - da.setValues([0,2],2,1) - da.setName("sup2") - ff1.appendFieldProfile(f1,pointeMedMesh,-1,da) - pointeMed.getFields().pushField( ff1 ) - - #remove fieldnodeint - pointeFields = pointeMed.getFields() - for i in range(pointeFields.getNumberOfFields()): - if pointeFields.getFieldAtPos(i).getName() == "fieldnodeint": - pointeFields.destroyFieldAtPos( i ) - break - - # write pointeMed to SAUV - sauvFile = "SauvLoaderTest.sauv" - sw=SauvWriter(); - sw.setMEDFileDS(pointeMed); - sw.write(sauvFile); - - # read SAUV and check - sr=SauvReader.New(sauvFile); - d2=sr.loadInMEDFileDS(); - self.assertEqual(1,d2.getNumberOfMeshes()) - self.assertEqual(4,d2.getNumberOfFields()) - m = d2.getMeshes().getMeshAtPos(0) - self.assertEqual("maa1",m.getName()) - self.assertEqual(6,len(m.getGroupsNames())) - self.assertEqual(3,m.getMeshDimension()) - groups = m.getGroupsNames() - self.assertTrue( "groupe1" in groups ) - self.assertTrue( "groupe2" in groups ) - self.assertTrue( "groupe3" in groups ) - self.assertTrue( "groupe4" in groups ) - self.assertTrue( "groupe5" in groups ) - self.assertTrue( "maa1" in groups ) - self.assertEqual(16,m.getSizeAtLevel(0)) - um0 = m.getMeshAtLevel(0) - self.assertEqual(12, um0.getNumberOfCellsWithType( NORM_TETRA4 )) - self.assertEqual(2, um0.getNumberOfCellsWithType( NORM_PYRA5 )) - self.assertEqual(2, um0.getNumberOfCellsWithType( NORM_HEXA8 )) - um1 = m.getMeshAtLevel(-1) - #self.assertEqual(2, um1.getNumberOfCellsWithType( NORM_TRI3 )) - self.assertEqual(1, um1.getNumberOfCellsWithType( NORM_TRI3 )) - pointeUM0 = pointeMedMesh.getMeshAtLevel(0) - self.assertTrue(m.getCoords().isEqualWithoutConsideringStr(pointeMedMesh.getCoords(),1e-12)) - self.assertEqual( um0.getMeasureField(False).accumulate(0), - pointeUM0.getMeasureField(False).accumulate(0),1e-12) - # check fields - # fieldnodedouble - fieldnodedoubleTS1 = pointeMed.getFields().getFieldWithName("fieldnodedouble") - fieldnodedoubleTS2 = d2.getFields().getFieldWithName("fieldnodedouble") - self.assertEqual( fieldnodedoubleTS1.getInfo(), fieldnodedoubleTS2.getInfo()) - self.assertEqual( fieldnodedoubleTS1.getNumberOfTS(), fieldnodedoubleTS2.getNumberOfTS()) - io1 = fieldnodedoubleTS1.getIterations() - io2 = fieldnodedoubleTS2.getIterations() - for i in range(fieldnodedoubleTS1.getNumberOfTS()): - fnd1 = fieldnodedoubleTS1.getFieldOnMeshAtLevel(ON_NODES, io1[i][0],io1[i][1],pointeUM0) - fnd2 = fieldnodedoubleTS2.getFieldOnMeshAtLevel(ON_NODES, io2[i][0],io2[i][1],um0) - self.assertTrue( fnd1.getArray().isEqual( fnd2.getArray(), 1e-12 )) - # fieldcelldoublevector - fieldnodedoubleTS1 = pointeMed.getFields().getFieldWithName("fieldcelldoublevector") - fieldnodedoubleTS2 = d2.getFields().getFieldWithName("fieldcelldoublevector") - self.assertEqual( fieldnodedoubleTS1.getInfo(), fieldnodedoubleTS2.getInfo()) - self.assertEqual( fieldnodedoubleTS1.getNumberOfTS(), fieldnodedoubleTS2.getNumberOfTS()) - io1 = fieldnodedoubleTS1.getIterations() - io2 = fieldnodedoubleTS2.getIterations() - for i in range(fieldnodedoubleTS1.getNumberOfTS()): - fnd1 = fieldnodedoubleTS1.getFieldOnMeshAtLevel(ON_CELLS, io1[i][0],io1[i][1],pointeUM0) - fnd2 = fieldnodedoubleTS2.getFieldOnMeshAtLevel(ON_CELLS, io2[i][0],io2[i][1],um0) - self.assertAlmostEqual( fnd1.accumulate(0), fnd2.accumulate(0) ) - self.assertAlmostEqual( fnd1.accumulate(1), fnd2.accumulate(1) ) - self.assertAlmostEqual( fnd1.accumulate(2), fnd2.accumulate(2) ) - # Field on 2 faces - fieldOnFaces = d2.getFields().getFieldWithName(f1.getName()) - io1 = fieldOnFaces.getIterations() - fof = fieldOnFaces.getFieldOnMeshAtLevel(f1.getTypeOfField(),io1[i][0],io1[i][1],um1) - self.assertTrue( d.isEqual( fof.getArray(), 1e-12 )) - pass - del sr - os.remove( sauvFile ) - pass - - @WriteInTmpDir - def testSauv2MedWONodeFamilyNum(self): - """test for issue 0021673: [CEA 566] Bug in SauvWriter when writing meshes - having no family ids on nodes.""" - - myCoords=DataArrayDouble.New([-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ],9,2) - targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4]; - targetMesh=MEDCouplingUMesh.New("BugInSauvWriter",2); - targetMesh.allocateCells(5); - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[4:7]); - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[7:10]); - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4]); - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[10:14]); - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[14:18]); - targetMesh.finishInsertingCells(); - targetMesh.setCoords(myCoords); - # - m=MEDFileUMesh.New() - m.setMeshAtLevel(0,targetMesh) - # start of bug - fam=DataArrayInt.New(targetMesh.getNumberOfNodes()) - fam[:]=0 - #m.setFamilyFieldArr(1,fam) - #end of bug - - ms=MEDFileMeshes.New() - ms.setMeshAtPos(0,m) - meddata=MEDFileData.New() - meddata.setMeshes(ms) - - medFile = "BugInSauvWriter.sauv" - sw=SauvWriter.New(); - sw.setMEDFileDS(meddata); - sw.write(medFile); - - os.remove( medFile ) - pass - - @WriteInTmpDir - def testSauv2MedOnPipe1D(self): - """test for issue 0021745: [CEA 600] Some missing groups in mesh after reading a SAUV file with SauvReader.""" - sauvFile="Test_sauve_1D.sauv" - # Make a sauve file with a qudratic 1D mesh - m=MEDCouplingUMesh.New("pipe1D",1) - m.allocateCells(2); - targetConn=[0,2,1, 2,4,3] - m.insertNextCell(NORM_SEG3,3,targetConn[0:3]) - m.insertNextCell(NORM_SEG3,3,targetConn[3:6]) - m.finishInsertingCells(); - # coords - coords=[ 0.,1.,2.,4.,5. ]; - c=DataArrayDouble.New() - c.setValues(coords,5,1) - m.setCoords(c) - # MEDFileUMesh - mm=MEDFileUMesh.New() - mm.setName(m.getName()) - mm.setDescription("1D mesh") - mm.setCoords(c) - mm.setMeshAtLevel(0,m); - # MEDFileData - mfd1 = MEDFileData.New() - ms=MEDFileMeshes.New(); ms.setMeshAtPos(0,mm) - mfd1.setMeshes(ms) - # write - sw=SauvWriter.New() - sw.setMEDFileDS(mfd1) - sw.write(sauvFile) - # Check connectivity read from the sauv file - sr = SauvReader.New(sauvFile) - mfd2 = sr.loadInMEDFileDS() - mfMesh = mfd2.getMeshes()[0] - mesh = mfMesh.getMeshAtLevel(0) - self.assertTrue(mesh.getNodalConnectivity().isEqual(m.getNodalConnectivity())) - # - del sr - os.remove(sauvFile) - pass - - @WriteInTmpDir - 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 range(mesh_dim)] - mesh = MEDCouplingCMesh.New("Mesh_box") - - # axes coords - axes_arrays = [] - for i in range(mesh_dim): - axe_coords = [j*box_steps[i] for j in range(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") - @WriteInTmpDir - def testMissingGroups(self): - """test for issue 0021749: [CEA 601] Some missing groups in mesh after reading a SAUV file with SauvReader.""" - sauvFile = os.path.join(self.__getResourcesDirectory(),"BDC-714.sauv") - self.assertTrue( os.access( sauvFile, os.F_OK)) - name_of_group_on_cells='Slice10:ABSORBER' - name_of_group_on_cells2='Slice10:00LR' - sr=SauvReader.New(sauvFile) - mfd2=sr.loadInMEDFileDS() - mfMesh=mfd2.getMeshes()[0] - # - self.assertTrue(name_of_group_on_cells in mfMesh.getGroupsNames()) - self.assertTrue(name_of_group_on_cells2 in mfMesh.getGroupsNames()) - self.assertEqual(270,len(mfMesh.getGroupsNames())) - # - ids1=mfMesh.getGroupArr(0,name_of_group_on_cells) - ids2=mfMesh.getGroupArr(0,name_of_group_on_cells2) - ids1.setName("") - ids2.setName("") - self.assertTrue(ids1.isEqual(ids2)) - pass - - @unittest.skipUnless(HasXDR(),"requires XDR") - @WriteInTmpDir - 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 - - @WriteInTmpDir - 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 - - @WriteInTmpDir - 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 - was defined""" - - # create a MEDFileData with a field ON_GAUSS_PT: 9 Gauss points, on 4 QUAD8 elements - f=MEDCouplingFieldDouble(ON_GAUSS_PT) - m=MEDCouplingUMesh("mesh",2) ; m.allocateCells() - m.insertNextCell(NORM_QUAD8,[0,2,4,6,1,3,5,7]) - m.insertNextCell(NORM_QUAD8,[2,9,11,4,8,10,12,3]) - m.insertNextCell(NORM_QUAD8,[6,4,14,16,5,13,15,17]) - m.insertNextCell(NORM_QUAD8,[4,11,19,14,12,18,20,13]) - m.setCoords(DataArrayDouble([(0,0),(0,0.25),(0,0.5),(0.25,0.5),(0.5,0.5),(0.5,0.25),(0.5,0),(0.25,0),(0,0.75),(0,1),(0.25,1),(0.5,1),(0.5,0.75),(0.75,0.5),(1,0.5),(1,0.25),(1,0),(0.75,0),(0.75,1),(1,1),(1,0.75)],21,2)) - f.setMesh(m) - arr=DataArrayDouble(4*9*2) ; arr.iota() ; arr.rearrange(2) ; arr.setInfoOnComponents(["YOUN []","NU []"]) - f.setArray(arr) - refCoo=[-1,-1,1,-1,1,1,-1,1,0,-1,1,0,0,1,-1,0] - gpCoo=[-0.7,-0.7,0.7,-0.7,0.7,0.7,-0.7,0.7,0,-0.7,0.7,0,0,0.7,-0.7,0,0,0] - wgt=[0.3,0.3,0.3,0.3,0.4,0.4,0.4,0.4,0.7] - f.setGaussLocalizationOnType(NORM_QUAD8,refCoo,gpCoo,wgt) - f.setName("SIGT") - f.checkConsistencyLight() - # - mm=MEDFileUMesh() - mm.setMeshAtLevel(0,m) - mfm = MEDFileMeshes() - mfm.pushMesh( mm ) - ff=MEDFileField1TS() - ff.setFieldNoProfileSBT(f) - mfmts = MEDFileFieldMultiTS() - mfmts.pushBackTimeStep(ff) - mff = MEDFileFields() - mff.pushField( mfmts ) - mfd = MEDFileData.New() - mfd.setFields( mff ) - mfd.setMeshes( mfm ) - - # convert the MED file to a SAUV file - sauvFile = "SauvLoaderTest_testGaussPt.sauv" - sw=SauvWriter.New(); - sw.setMEDFileDS(mfd); - sw.write(sauvFile); - - # convert the SAUV file back to MED - sr=SauvReader.New(sauvFile); - d2=sr.loadInMEDFileDS(); - - self.assertEqual( 1, d2.getNumberOfFields() ) - self.assertEqual( 1, d2.getNumberOfMeshes() ) - mfm2 = d2.getMeshes()[0] - mff2 = d2.getFields()[0] - m2 = mfm2.getMeshAtLevel(0) - f2 = mff2.getTimeStepAtPos(0).getFieldOnMeshAtLevel(f.getTypeOfField(),0,mfm2) - f2.setGaussLocalizationOnType(NORM_QUAD8,refCoo,gpCoo,wgt) # not stored in SAUV - #f2.setOrder( f.getTime()[2] ) # not stored in SAUV - self.assertTrue( m2.isEqual( m, 1e-12 )) - self.assertTrue( f2.isEqual( f, 1e-12, 1e-12 )) - del sr - os.remove( sauvFile ) - pass - - @WriteInTmpDir - def testSauvWriterGroupWithOneFamily(self): - """ - This test checks an option for sauv writing. It is requested here to copy a group from a family if a group is lying on a single family. - """ - import re - mfd=MEDLoaderDataForTest.buildAMEDFileDataWithGroupOnOneFamilyForSauv() - sauvFile = "mesh.sauv" - sw=SauvWriter.New() - sw.setMEDFileDS(mfd) - self.assertTrue(not sw.getCpyGrpIfOnASingleFamilyStatus()) - sw.setCpyGrpIfOnASingleFamilyStatus(True) - self.assertTrue(sw.getCpyGrpIfOnASingleFamilyStatus()) - sw.write(sauvFile) - - f = open(sauvFile) - # String pattern for the header of the sub meshes record ("PILE" number, number of named objects, number of objects) - pattern_pile= re.compile(r'\sPILE\sNUMERO\s+(?P[0-9]+)NBRE\sOBJETS\sNOMMES\s+(?P[0-9]+)NBRE\sOBJETS\s+(?P[0-9]+)') - # String pattern for a sub mesh header (cell type, number of components and three numbers) - pattern_header=re.compile(r'\s+(?P[0-9]+)\s+(?P[0-9]+)\s+[0-9]+\s+[0-9]+\s+[0-9]+') - - nbobjects=0 - line = f.readline() - while(line): - match_pile = pattern_pile.match(line) - if match_pile: - number=int(match_pile.group("number")) - if number == 1: - nbnamed=int(match_pile.group("nbnamed")) - nbobjects=int(match_pile.group("nbobjects")) - break - pass - line=f.readline() - pass - - # Skipping the objects names - f.readline() - # Skipping the objects ids - f.readline() - - # Looking for each sub-mesh header - line = f.readline() - cur_object=0 - while(line and cur_object < nbobjects): - match_header=pattern_header.match(line) - if match_header: - cell_type=int(match_header.group("type")) - nb_subs=int(match_header.group("nbsubs")) - # Looking for a compound object - if cell_type == 0: - # Testing if there is only one component - self.assertTrue(nb_subs > 1) - else: - f.readline() - f.readline() - cur_object = cur_object + 1 - pass - pass - line=f.readline() - pass - f.close() - os.remove(sauvFile) - pass - - pass - -unittest.main() diff --git a/src/MEDLoader/Swig/med2sauv b/src/MEDLoader/Swig/med2sauv deleted file mode 100755 index 17e21f139..000000000 --- a/src/MEDLoader/Swig/med2sauv +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python -# -- -# Copyright (C) 2009-2021 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# Author : Erwan ADAM (CEA) -# -- - -from sys import argv,path -from os.path import dirname,abspath,sep -from medutilities import med2sauv - -d = argv[0] -d = dirname(d) -d = abspath(d+sep+".."+sep+"lib") -if d not in path: - path.insert(0,d) - pass - -med2sauv(*argv[1:]) diff --git a/src/MEDLoader/Swig/medutilities.py b/src/MEDLoader/Swig/medutilities.py deleted file mode 100644 index 84eec5cbc..000000000 --- a/src/MEDLoader/Swig/medutilities.py +++ /dev/null @@ -1,141 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# -- -# Copyright (C) 2009-2021 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# Author : Erwan ADAM (CEA), Anthony GEAY (CEA) -# -- - -from MEDLoader import * - -def my_remove(f): - from os import remove - try: - remove(f) - except OSError: - pass - return - -def convert(file_in, driver_in, driver_out, format=1, file_out=None): - # - print(file_in) - # - if file_out is None: - file_out = file_in - if driver_out == "GIBI": - file_out += ".sauv" - elif driver_out == "MED": - file_out += ".med" - else: - msg = "Driver out %s is unknown"%(driver_out) - raise NotImplementedError(msg) - pass - print(file_out) - # - if driver_in == "GIBI": - sr = SauvReader.New(file_in) - mfd= sr.loadInMEDFileDS() - pass - elif driver_in == "MED": - mfd = MEDFileData(file_in) - pass - else: - raise NotImplementedError("Driver in %s is unknown"%(driver_in)) - # - my_remove(file_out) - # - if driver_out == "GIBI": - sw=SauvWriter.New() - sw.setMEDFileDS(mfd,0);#0 ? - sw.write(file_out) - # - mesh = mfd.getMeshes()[0] - mesh_dim = mesh.getSpaceDimension() - if mesh_dim >= 3: - from sys import platform - if platform in ["win32"]: - f = open(file_out) - content = f.read() - f.close() - content = content.replace("IFOUR -1", "IFOUR 2") - content = content.replace("IFOMOD -1", "IFOMOD 2") - f = open(file_out, "w") - f.write(content) - f.close() - else: - cmd = "sed" - cmd += ' -e "s/IFOUR -1/IFOUR 2/g"' - cmd += ' -e "s/IFOMOD -1/IFOMOD 2/g"' - # cmd += ' -e "s/IECHO 1/IECHO 0/g"' - cmd += ' %s > .dummy'%(file_out) - cmd += ' && ' - cmd += ' mv -f .dummy %s'%(file_out) - from os import system - system(cmd) - pass - pass - # - if format == 0: - from castemlauncher import CastemLauncher - dgibi_stream = "\n" - dgibi_stream += "OPTI REST FORMAT '%s' ;\n"%(file_out) - dgibi_stream += "REST FORMAT;\n" - file_out = file_out.replace('__format__', '') - dgibi_stream += "OPTI SAUV '%s' ;\n"%(file_out) - dgibi_stream += "SAUV ;\n" - cl = CastemLauncher(dgibi_stream) - cl.addTmpFiles(file_out+'__format__', "UTILNOTI", "UTILPROC") - cl.run() - pass - return - elif driver_out == "MED": - mfd.write(file_out,2) - return - else: - raise NotImplementedError("Driver in %s is unknown"%(driver_in)) - -def sauv2med(*argv): - argv = list(argv) - for arg in argv: - convert(arg, "GIBI", "MED") - pass - return - -def med2sauv(*argv): - argv = list(argv) - format = 1 - for arg in argv[:]: - if arg.find('--format') == 0: - argv.remove(arg) - try: - value = arg.split("=")[1] - except IndexError: - usage(1) - pass - try: - value = int(value) - except ValueError: - usage(1) - pass - format = value - pass - pass - for arg in argv: - convert(arg, "MED", "GIBI", format) - pass - return diff --git a/src/MEDLoader/Swig/sauv2med b/src/MEDLoader/Swig/sauv2med deleted file mode 100755 index c136eb7b0..000000000 --- a/src/MEDLoader/Swig/sauv2med +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python -# -- -# Copyright (C) 2009-2021 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# Author : Erwan ADAM (CEA) -# -- - -from sys import argv,path -from os.path import dirname,abspath,sep -from medutilities import sauv2med - -d = argv[0] -d = dirname(d) -d = abspath(d+sep+".."+sep+"lib") -if d not in path: - path.insert(0,d) - pass - -sauv2med(*argv[1:]) diff --git a/src/MEDLoader/Swig/tests.set b/src/MEDLoader/Swig/tests.set index 6b345f617..7473ab01b 100644 --- a/src/MEDLoader/Swig/tests.set +++ b/src/MEDLoader/Swig/tests.set @@ -21,7 +21,6 @@ SET(BASE_TESTS MEDLoaderTest123.py MEDLoaderTest4.py MEDLoaderExamplesTest.py - SauvLoaderTest.py UsersGuideExamplesTest_ML.py ) diff --git a/src/MEDLoader/Test/CMakeLists.txt b/src/MEDLoader/Test/CMakeLists.txt index fa4c53194..26a47248e 100644 --- a/src/MEDLoader/Test/CMakeLists.txt +++ b/src/MEDLoader/Test/CMakeLists.txt @@ -34,24 +34,15 @@ SET(TestMEDLoader_SOURCES MEDLoaderTest.cxx ) -SET(TestSauvLoader_SOURCES - TestSauvLoader.cxx - SauvLoaderTest.cxx - ) - SALOME_ACCUMULATE_ENVIRONMENT(MEDCOUPLING_RESOURCE_DIR "${CMAKE_BINARY_DIR}/resources") SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) ADD_EXECUTABLE(TestMEDLoader ${TestMEDLoader_SOURCES}) TARGET_LINK_LIBRARIES(TestMEDLoader medloader InterpKernelTestUtils ${CPPUNIT_LIBRARIES} ${PLATFORM_LIBS}) -ADD_EXECUTABLE(TestSauvLoader ${TestSauvLoader_SOURCES}) - -TARGET_LINK_LIBRARIES(TestSauvLoader medloader InterpKernelTestUtils ${CPPUNIT_LIBRARIES} ${PLATFORM_LIBS}) - -INSTALL(TARGETS TestMEDLoader TestSauvLoader DESTINATION ${MEDCOUPLING_INSTALL_BINS}) +INSTALL(TARGETS TestMEDLoader DESTINATION ${MEDCOUPLING_INSTALL_BINS}) -SET(BASE_TESTS TestMEDLoader TestSauvLoader) +SET(BASE_TESTS TestMEDLoader) FOREACH(test ${BASE_TESTS}) ADD_TEST(NAME ${test} @@ -62,7 +53,7 @@ ENDFOREACH() # Application tests SET(TEST_INSTALL_DIRECTORY ${MEDCOUPLING_INSTALL_TESTS}/MEDLoader) -INSTALL(TARGETS TestMEDLoader TestSauvLoader DESTINATION ${TEST_INSTALL_DIRECTORY}) +INSTALL(TARGETS TestMEDLoader DESTINATION ${TEST_INSTALL_DIRECTORY}) INSTALL(FILES MCTestLauncher.py DESTINATION ${TEST_INSTALL_DIRECTORY}) INSTALL(FILES CTestTestfileInstall.cmake diff --git a/src/MEDLoader/Test/CTestTestfileInstall.cmake b/src/MEDLoader/Test/CTestTestfileInstall.cmake index 03bdb713b..9ae97882c 100644 --- a/src/MEDLoader/Test/CTestTestfileInstall.cmake +++ b/src/MEDLoader/Test/CTestTestfileInstall.cmake @@ -19,7 +19,6 @@ SET(TEST_NAMES TestMEDLoader - TestSauvLoader ) FOREACH(tfile ${TEST_NAMES})