Salome HOME
564736527e032bba426984e4695aa0dde3860d20
[modules/med.git] / doc / tut / medloader / tutorial.py
1 #!/usr/bin/env python3
2 # Copyright (C) 2012-2021  CEA/DEN, EDF R&D
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 # This script illustrates the basic features of MEDLoader
22 # (gboulant, 17 nov 2012)
23 import os
24 filename = "timeseries.med"
25 filepath = os.path.join(os.path.abspath(os.path.dirname(__file__)),filename)
26
27 # _T1A
28 from MEDLoader import MEDLoader
29 meshNames = MEDLoader.GetMeshNames(filepath)
30 # _T1B
31 meshName=meshNames[0]
32 # _T2A
33 fieldNames = MEDLoader.GetAllFieldNamesOnMesh(filepath,meshName)
34 # _T2B
35 fieldName=fieldNames[0]
36 # _T3A
37 listOfTypes = MEDLoader.GetTypesOfField(filepath,meshName,fieldName)
38 # _T3B
39 typeOfDiscretization=listOfTypes[0]
40 # _T4A
41 fieldIterations = MEDLoader.GetFieldIterations(typeOfDiscretization,
42                                                filepath,
43                                                meshName,
44                                                fieldName)
45 # _T4B
46
47 iteration = fieldIterations[0]
48 iterationNumber = iteration[0]
49 iterationOrder  = iteration[1]
50
51 dimrestriction = 0
52 # _T5A
53 mesh = MEDLoader.ReadUMeshFromFile(filepath, meshName, dimrestriction)
54 # _T5B
55 # _T6A
56 field = MEDLoader.ReadField(typeOfDiscretization,
57                             filepath, meshName, dimrestriction,
58                             fieldName, iterationNumber, iterationOrder)
59 # _T6B