Salome HOME
f94723a45ca1a32781a6ee14e26b29e45de24b4b
[modules/paravis.git] / src / Plugins / MEDReader / Test / testMEDReader9.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2016  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 # Author : Anthony Geay
21
22 from MEDLoader import *
23
24 """ This test is a non regression test. Test that ExtractGroup adapt to the current mesh of MEDReader. A MED file containing 2 fields on a 2 different meshes.
25 This test checks that the MeshName follows.
26 """
27
28 fname="testMEDReader9.med"
29 #########
30 m1=MEDCouplingUMesh("m1",2) ; m1.setCoords(DataArrayDouble([(0.,0.),(1.,0.),(0.,1.)])) ; m1.allocateCells() ; m1.insertNextCell(NORM_TRI3,[0,1,2])
31 m2=MEDCouplingUMesh("m2",2) ; m2.setCoords(DataArrayDouble([(0.,0.),(1.,0.),(0.,1.),(1.,1.)])) ; m2.allocateCells() ; m2.insertNextCell(NORM_QUAD4,[0,1,3,2])
32 mm1=MEDFileUMesh() ; mm2=MEDFileUMesh()
33 mm1.setMeshAtLevel(0,m1) ; mm2.setMeshAtLevel(0,m2)
34 ms=MEDFileMeshes() ; ms.pushMesh(mm1) ; ms.pushMesh(mm2)
35 f1=MEDCouplingFieldDouble(ON_CELLS) ; f1.setName("f1") ; f1.setMesh(m1) ; f1.setArray(DataArrayDouble([1.111]))
36 f2=MEDCouplingFieldDouble(ON_CELLS) ; f2.setName("f2") ; f2.setMesh(m2) ; f2.setArray(DataArrayDouble([2.2222]))
37 ff1=MEDFileField1TS() ; ff2=MEDFileField1TS()
38 ff1.setFieldNoProfileSBT(f1) ; ff2.setFieldNoProfileSBT(f2)
39 ms.write(fname,2)
40 ff1.write(fname,0)
41 ff2.write(fname,0)
42 ################### MED write is done -> Go to MEDReader
43 from paraview.simple import *
44
45 myMedReader=MEDReader(FileName=fname)
46 myMedReader.AllArrays=['TS0/m1/ComSup0/f1@@][@@P0']
47 #myMedReader.UpdatePipelineInformation()
48 ExtractGroup1=ExtractGroup(Input=myMedReader)
49 #ExtractGroup1.UpdatePipelineInformation()
50 assert(ExtractGroup1.GetProperty("MeshName")[0]=="m1")
51 myMedReader.AllArrays=['TS0/m2/ComSup0/f2@@][@@P0']
52 #myMedReader.UpdatePipeline()
53 ExtractGroup2=ExtractGroup(Input=myMedReader)
54 #ExtractGroup2.UpdatePipelineInformation()
55 assert(ExtractGroup2.GetProperty("MeshName")[0]=="m2")