2 # Copyright (C) 2012-2014 CEA/DEN, EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 from MEDLoader import MEDLoader
24 filename = "madnex_field.med"
25 filepath = os.path.join(os.path.abspath(os.path.dirname(__file__)),filename)
27 meshName="my_field_RG"
32 # Load as an unstructured mesh
33 meshDimRelToMax = 0 # 0 = no restriction
34 umesh = MEDLoader.ReadUMeshFromFile(filepath,meshName,meshDimRelToMax)
35 print "umesh is structured: %s"%umesh.isStructured()
37 # Load as a structured mesh explicitly
39 from MEDLoader import MEDFileCMesh
40 medfile = MEDFileCMesh.New(filepath,meshName)
41 cmesh = medfile.getMesh()
42 # Note that the getMesh method is a short way to the method:
43 #cmesh = medfile.getGenMeshAtLevel(0,False)
44 print "cmesh is structured: %s"%cmesh.isStructured()
47 # Load and let MEDLoader decide what is nature of the mesh
49 from MEDLoader import MEDFileMesh
50 medfile = MEDFileMesh.New(filepath,meshName)
51 print medfile.advancedRepr()
52 meshDimRelToMax = 0 # 0 = no restriction
53 mesh = medfile.getGenMeshAtLevel(meshDimRelToMax)
54 print "mesh is structured: %s"%mesh.isStructured()
58 # Write the mesh to another file
60 outputfilepath="output.med"
62 medfile.write(outputfilepath,mode)
65 # test to reload the mesh
66 medfile = MEDFileCMesh.New(outputfilepath,meshName)
67 cmesh = medfile.getMesh()
68 print "cmesh is structured: %s"%cmesh.isStructured()
70 # Q: Is it possible to know if a mesh is structured or unstructured
71 # without loading the mesh.