Salome HOME
Copyright update 2022
[modules/paravis.git] / src / Plugins / MEDReader / plugin / Test / testMEDReader18.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2015-2022  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
23 from medcoupling import *
24 from paraview.simple import *
25 from MEDReaderHelper import WriteInTmpDir,RetriveBaseLine
26
27 def GenerateCase():
28     """Non regression test for bug EDF11343. Extract group on groups mixing cells entities and node entities."""
29     fname="testMEDReader18.med"
30     arr1=DataArrayDouble(5) ; arr1.iota()
31     arr2=DataArrayDouble([0,1])
32     m=MEDCouplingCMesh() ; m.setCoords(arr1,arr2)
33     m.setName("mesh")
34     m=m.buildUnstructured()
35     #
36     mm=MEDFileUMesh()
37     mm[0]=m
38     #
39     grp0=DataArrayInt([1,2]) ; grp0.setName("grp0")
40     grp1=DataArrayInt([3,4,8,9]) ; grp1.setName("grp1")
41     #
42     mm.addGroup(0,grp0)
43     mm.addGroup(1,grp1)
44     #
45     mm.write(fname,2)
46     return fname
47
48 @WriteInTmpDir
49 def test():
50   fname = GenerateCase()
51   reader=MEDReader(FileName=fname)
52   reader.AllArrays=['TS0/mesh/ComSup0/mesh@@][@@P0']
53   ExtractGroup1 = ExtractGroup(Input=reader)
54   ExtractGroup1.AllGroups=["GRP_grp0","GRP_grp1"]
55   #ExtractGroup1.UpdatePipelineInformation()
56   res=servermanager.Fetch(ExtractGroup1,0)
57   assert(res.GetNumberOfBlocks()==2)
58   assert(res.GetBlock(1).GetNumberOfCells()==1)
59   assert(res.GetBlock(0).GetNumberOfCells()==2)
60   pass
61
62 if __name__ == "__main__":
63     test()
64     pass
65
66