1 # -*- coding: iso-8859-1 -*-
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 # This illustrates the use of getValueOn in the case of hexahedron
22 # meshes (for which a temporary limitation implies the usage of the
23 # method simplexize that split the hexahedron into simplex,
24 # i.e. triangles and tetrahedrons).
26 # (gboulant, nov. 2012)
27 from MEDLoader import *
28 from MEDCoupling import *
31 filename = "timeseries.med"
32 filepath = os.path.join(os.path.abspath(os.path.dirname(__file__)),filename)
34 rmedfilename = filepath
37 meshname = "Grid_80x80"
39 dimrestriction = 0 # no restriction
40 msource = MEDLoader.ReadUMeshFromFile(rmedfilename,meshname,dimrestriction)
42 # WARN: In the current version of MEDCoupling, the getValueOn works
43 # only with simplex cells (triangles, tetrahedron). This is not a
44 # technical problem, but a question of specification of the
45 # interpolation to be performed in the case of other cells, in
46 # particular in the case of hexahedron meshes.
48 # A temporary solution (with good numerical results) is to split
49 # hexahedrons into simplex (before the association of the mesh to the
50 # field) using the method simplexize.
52 msource.simplexize(policy)
54 # Load the field data at iteration 0
57 fieldOnNodes = MEDLoader.ReadField(ON_NODES,rmedfilename,
58 meshname,dimrestriction,
59 fieldname,iteration,order)
62 fieldOnNodes.setMesh(msource)
64 # Get the value of field at coordinates x,y
67 fieldValue = fieldOnNodes.getValueOn([x,y])