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).
7 # (gboulant, nov. 2012)
8 from MEDLoader import *
9 from MEDCoupling import *
12 filename = "timeseries.med"
13 filepath = os.path.join(os.path.abspath(os.path.dirname(__file__)),filename)
15 rmedfilename = filepath
18 meshname = "Grid_80x80"
20 dimrestriction = 0 # no restriction
21 msource = MEDLoader.ReadUMeshFromFile(rmedfilename,meshname,dimrestriction)
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.
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.
33 msource.simplexize(policy)
35 # Load the field data at iteration 0
38 fieldOnNodes = MEDLoader.ReadField(ON_NODES,rmedfilename,
39 meshname,dimrestriction,
40 fieldname,iteration,order)
43 fieldOnNodes.setMesh(msource)
45 # Get the value of field at coordinates x,y
48 fieldValue = fieldOnNodes.getValueOn([x,y])