Salome HOME
Copyrights update 2015.
[modules/paravis.git] / src / Plugins / MEDReader / Test / testMEDReader12.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2015  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 non regression test to check that ExtractGroup filter works well on non unstructured meshes."""
25
26 fname="testMEDReader12.med"
27 outImgName="testMEDReader12.png"
28 #
29 p=DataArrayDouble([0.6075913659107736,0.581430790304825,0.581430790304825,0.581430790304825,0.581430790304825,0.5814307903048253,0.581430790304825,0.581430790304825,0.581430790304825,0.581430790304825,0.581430790304825,0.581430790304825,0.581430790304825,0.581430790304825,0.581430790304825,0.581430790304825,0.581430790304825,0.6075913659107737,0.581430790304825,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.553526176325147,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.4734426322438601,0.4734426322438599,0.5535261763251467,0.4734426322438599,0.4734426322438599,0.5535261763251467,0.4734426322438599,0.4734426322438599,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.4734426322438602,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.553526176325147,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.5814307903048253,0.553526176325147,0.4734426322438601,0.4734426322438602,0.553526176325147,0.4734426322438603,0.4734426322438602,0.553526176325147,0.4734426322438602,0.4734426322438602,0.553526176325147,0.4734426322438602,0.4734426322438602,0.553526176325147,0.4734426322438602,0.4734426322438602,0.553526176325147,0.5814307903048255,0.581430790304825,0.5535261763251467,0.4734426322438599,0.47344263224385996,0.5535261763251467,0.4734426322438602,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.553526176325147,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.4734426322438599,0.47344263224385996,0.5535261763251467,0.4734426322438602,0.47344263224385996,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.4734426322438599,0.47344263224385996,0.5535261763251467,0.4734426322438602,0.47344263224385996,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.553526176325147,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.4734426322438599,0.47344263224385996,0.5535261763251467,0.4734426322438602,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.4734426322438599,0.47344263224385996,0.5535261763251467,0.4734426322438602,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.553526176325147,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.4734426322438602,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.4734426322438602,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.553526176325147,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.6075913659107737,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048255,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.6075913659107739,0.6075913659107737,0.581430790304825,0.581430790304825,0.581430790304825,0.581430790304825,0.5814307903048254,0.581430790304825,0.581430790304825,0.581430790304825,0.581430790304825,0.581430790304825,0.581430790304825,0.581430790304825,0.581430790304825,0.581430790304825,0.581430790304825,0.581430790304825,0.6075913659107737,0.581430790304825,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.553526176325147,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.47344263224386013,0.4734426322438599,0.5535261763251467,0.4734426322438599,0.4734426322438599,0.5535261763251467,0.4734426322438599,0.4734426322438599,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.4734426322438602,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.553526176325147,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.5814307903048254,0.553526176325147,0.47344263224386013,0.4734426322438602,0.553526176325147,0.47344263224386035,0.4734426322438602,0.553526176325147,0.4734426322438602,0.4734426322438602,0.553526176325147,0.4734426322438602,0.4734426322438602,0.553526176325147,0.4734426322438602,0.4734426322438602,0.553526176325147,0.5814307903048255,0.581430790304825,0.5535261763251467,0.4734426322438599,0.47344263224385996,0.5535261763251467,0.4734426322438602,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.553526176325147,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.4734426322438599,0.47344263224385996,0.5535261763251467,0.4734426322438602,0.47344263224385996,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.4734426322438599,0.47344263224385996,0.5535261763251467,0.4734426322438602,0.47344263224385996,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.553526176325147,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.4734426322438599,0.47344263224385996,0.5535261763251467,0.4734426322438602,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.4734426322438599,0.47344263224385996,0.5535261763251467,0.4734426322438602,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.553526176325147,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.4734426322438602,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.4734426322438602,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.47344263224385996,0.47344263224385996,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.581430790304825,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.553526176325147,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5535261763251467,0.5814307903048253,0.6075913659107737,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048255,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.5814307903048253,0.6075913659107739])
30 p.setInfoOnComponents(["- [-]"])
31 #
32 famIds=DataArrayInt([-1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-1,-2,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-2,-2,-3,-3,-3,-3,-4,-4,-3,-4,-4,-3,-4,-4,-3,-3,-3,-3,-2,-2,-3,-3,-4,-4,-4,-4,-3,-4,-4,-3,-4,-4,-4,-4,-3,-3,-2,-2,-3,-3,-4,-4,-3,-3,-3,-3,-3,-3,-3,-3,-4,-4,-3,-3,-2,-2,-3,-4,-4,-3,-4,-4,-3,-4,-4,-3,-4,-4,-3,-4,-4,-3,-2,-2,-3,-4,-4,-3,-4,-4,-3,-4,-4,-3,-4,-4,-3,-4,-4,-3,-2,-2,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-2,-2,-3,-4,-4,-3,-4,-4,-3,-3,-3,-3,-4,-4,-3,-4,-4,-3,-2,-2,-3,-4,-4,-3,-4,-4,-3,-3,-3,-3,-4,-4,-3,-4,-4,-3,-2,-2,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-2,-2,-3,-4,-4,-3,-4,-4,-3,-4,-4,-3,-4,-4,-3,-4,-4,-3,-2,-2,-3,-4,-4,-3,-4,-4,-3,-4,-4,-3,-4,-4,-3,-4,-4,-3,-2,-2,-3,-3,-4,-4,-3,-3,-3,-3,-3,-3,-3,-3,-4,-4,-3,-3,-2,-2,-3,-3,-4,-4,-4,-4,-3,-4,-4,-3,-4,-4,-4,-4,-3,-3,-2,-2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-2,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-2,-1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-1])
33 #
34 arrX=DataArrayDouble([0.,0.00672,0.01932,0.03192,0.04452,0.05712,0.06972,0.08232,0.09492,0.10752,0.12012,0.13272,0.14532,0.15792,0.17052,0.18312,0.19572,0.20832,0.21504])
35 arrY=DataArrayDouble([0.,0.00672,0.01932,0.03192,0.04452,0.05712,0.06972,0.08232,0.09492,0.10752,0.12012,0.13272,0.14532,0.15792,0.17052,0.18312,0.19572,0.20832,0.21504])
36 arrZ=DataArrayDouble([4.6025,4.695,4.805])
37 #
38 cm=MEDCouplingCMesh("Maillage_THYC") ; cm.setCoords(arrX,arrY,arrZ)
39 mm=MEDFileCMesh() ; mm.setMesh(cm)
40 mm.setFamilyFieldArr(0,famIds)
41 mm.setFamilyId("FAMILLE -1",-1)
42 mm.setFamilyId("FAMILLE -2",-2)
43 mm.setFamilyId("FAMILLE -3",-3)
44 mm.setFamilyId("FAMILLE -4",-4)
45 mm.write(fname,2)
46 f=MEDCouplingFieldDouble(ON_CELLS) ; f.setMesh(cm) ; f.setTime(0.,-1,0)
47 f.setName("POROSITE") ; f.setArray(p)
48 f1ts=MEDFileField1TS()
49 f1ts.setFieldNoProfileSBT(f)
50 f1ts.write(fname,0)
51 ################### MED write is done -> Go to MEDReader
52 from paraview.simple import *
53
54 testMEDReader12_med = MEDReader( FileName=fname )
55 testMEDReader12_med.AllArrays = ['TS0/Maillage_THYC/ComSup0/POROSITE@@][@@P0']
56
57 RenderView1 = GetRenderView()
58 RenderView1.CenterOfRotation = [0.10751999914646149, 0.10751999914646149, 4.703749895095825]
59
60 DataRepresentation1 = Show()
61 DataRepresentation1.Representation = 'Outline'
62 DataRepresentation1.ScaleFactor = 0.021504000000000002
63 DataRepresentation1.EdgeColor = [0.0, 0.0, 0.5000076295109483]
64 DataRepresentation1.SelectionCellFieldDataArrayName = 'FamilyIdCell'
65
66 RenderView1.CameraPosition = [0.10751999914646149, 0.10751999914646149, 5.409578268564619]
67 RenderView1.CameraFocalPoint = [0.10751999914646149, 0.10751999914646149, 4.703749895095825]
68 RenderView1.CameraClippingRange = [0.4972827225809383, 0.9700468818440346]
69 RenderView1.CameraParallelScale = 0.18268182562745858
70
71 ExtractGroup1 = ExtractGroup(Input=testMEDReader12_med)
72 ExtractGroup1.UpdatePipelineInformation()
73 ExtractGroup1.AllGroups = ['FAM_FAMILLE -2@@][@@-2', 'FAM_FAMILLE -4@@][@@-4']
74
75 DataRepresentation2 = Show()
76 DataRepresentation2.EdgeColor = [0.0, 0.0, 0.5000076295109483]
77 DataRepresentation2.SelectionCellFieldDataArrayName = 'FamilyIdCell'
78 DataRepresentation2.ScalarOpacityUnitDistance = 0.053416489858379865
79 DataRepresentation2.ExtractedBlockIndex = 1
80 DataRepresentation2.ScaleFactor = 0.021503999829292297
81
82 DataRepresentation1.Visibility = 0
83
84 a1_POROSITE_PVLookupTable = GetLookupTableForArray( "POROSITE", 1, RGBPoints=[0.4734426322438599, 0.23, 0.299, 0.754, 0.5274367112743427, 0.865, 0.865, 0.865, 0.5814307903048255, 0.706, 0.016, 0.15], VectorMode='Magnitude', NanColor=[0.25, 0.0, 0.0], ColorSpace='Diverging', ScalarRangeInitialized=1.0 )
85
86 a1_POROSITE_PiecewiseFunction = CreatePiecewiseFunction( Points=[0.4734426322438599, 0.0, 0.5, 0.0, 0.5814307903048255, 1.0, 0.5, 0.0] )
87
88 DataRepresentation2.ScalarOpacityFunction = a1_POROSITE_PiecewiseFunction
89 DataRepresentation2.ColorArrayName = ('CELLS', 'POROSITE')
90 DataRepresentation2.LookupTable = a1_POROSITE_PVLookupTable
91
92 Render()
93 RenderView1.ViewSize =[300,300]
94 WriteImage(outImgName)