Salome HOME
[bos #16777] [CEA] generateVectors makes SALOME crash
[modules/paravis.git] / src / Plugins / MEDReader / Test / testMEDReader18.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2015-2019  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 (EDF R&D)
21
22 # Non regression test for bug EDF11343. Extract group on groups mixing cells entities and node entities.
23
24 from MEDLoader import *
25
26 fname="testMEDReader18.med"
27 arr1=DataArrayDouble(5) ; arr1.iota()
28 arr2=DataArrayDouble([0,1])
29 m=MEDCouplingCMesh() ; m.setCoords(arr1,arr2)
30 m.setName("mesh")
31 m=m.buildUnstructured()
32 #
33 mm=MEDFileUMesh()
34 mm[0]=m
35 #
36 grp0=DataArrayInt([1,2]) ; grp0.setName("grp0")
37 grp1=DataArrayInt([3,4,8,9]) ; grp1.setName("grp1")
38 #
39 mm.addGroup(0,grp0)
40 mm.addGroup(1,grp1)
41 #
42 mm.write(fname,2)
43 #####
44 from paraview.simple import *
45
46 reader=MEDReader(FileName=fname)
47 reader.AllArrays=['TS0/mesh/ComSup0/mesh@@][@@P0']
48 ExtractGroup1 = ExtractGroup(Input=reader)
49 ExtractGroup1.AllGroups=["GRP_grp0","GRP_grp1"]
50 #ExtractGroup1.UpdatePipelineInformation()
51 res=servermanager.Fetch(ExtractGroup1,0)
52 assert(res.GetNumberOfBlocks()==2)
53 assert(res.GetBlock(1).GetNumberOfCells()==1)
54 assert(res.GetBlock(0).GetNumberOfCells()==2)