]> SALOME platform Git repositories - modules/med.git/blob - src/MEDOP/tut/medloader/testamel.py
Salome HOME
Add documentation for users and basic tutotial script examples (associated to the...
[modules/med.git] / src / MEDOP / tut / medloader / testamel.py
1 #  -*- coding: iso-8859-1 -*-
2 # This illustrates the use of getValueOn in the case of hexahedron
3 # meshes (for which a temporary limitation implies the usage of the
4 # method simplexize that split the hexahedron into simplex,
5 # i.e. triangles and tetrahedrons).
6 #
7 # (gboulant, nov. 2012)
8 from MEDLoader import *
9 from MEDCoupling import *
10
11 import os
12 filename = "timeseries.med"
13 filepath = os.path.join(os.path.abspath(os.path.dirname(__file__)),filename)
14
15 rmedfilename = filepath
16
17 # Load the meshe data
18 meshname = "Grid_80x80"
19 fieldname = "Pulse"
20 dimrestriction = 0 # no restriction
21 msource = MEDLoader.ReadUMeshFromFile(rmedfilename,meshname,dimrestriction)
22
23 # WARN: In the current version of MEDCoupling, the getValueOn works
24 # only with simplex cells (triangles, tetrahedron). This is not a
25 # technical problem, but a question of specification of the
26 # interpolation to be performed in the case of other cells, in
27 # particular in the case of hexahedron meshes.
28 #
29 # A temporary solution (with good numerical results) is to split
30 # hexahedrons into simplex (before the association of the mesh to the
31 # field) using the method simplexize.
32 policy = 0
33 msource.simplexize(policy)
34
35 # Load the field data at iteration 0
36 iteration = 0
37 order = -1
38 fieldOnNodes = MEDLoader.ReadField(ON_NODES,rmedfilename,
39                                    meshname,dimrestriction,
40                                    fieldname,iteration,order)
41
42
43 fieldOnNodes.setMesh(msource)
44
45 # Get the value of field at coordinates x,y
46 x=0.5
47 y=0.5
48 fieldValue = fieldOnNodes.getValueOn([x,y])
49 print fieldValue