Salome HOME
Merge branch 'abn/rearch'
[modules/paravis.git] / src / Plugins / MEDReader / Test / testMEDReader2.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2014  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 fname="testMEDReader2.med"
25 outImgName="testMEDReader2.png"
26
27 """ This use case is a mesh containing a large number of orphan cells (cells having no field lying on them)
28 """
29 #########
30 arrX=DataArrayDouble(7) ; arrX.iota()
31 arrY=DataArrayDouble(7) ; arrY.iota()
32 arrZ=DataArrayDouble(7) ; arrZ.iota()
33 m=MEDCouplingCMesh()
34 m.setCoords(arrX,arrY,arrZ)
35 m=m.buildUnstructured() ; m.setName("mesh")
36 tmp=m[3*36:4*36]
37 tmp=tmp.buildDescendingConnectivity()[0]
38 nodeIds=tmp.findNodesOnPlane([0.,0.,3.],[0.,0.,1.],1e-12)
39 cellIds=tmp.getCellIdsLyingOnNodes(nodeIds,True)
40 m1=tmp[cellIds]
41 mm=MEDFileUMesh()
42 mm.setMeshAtLevel(0,m)
43 mm.setMeshAtLevel(-1,m1)
44 mm.write(fname,2)
45 #
46 pfl=DataArrayInt([7,8,9,10,13,14,15,16,19,20,21,22,25,26,27,28]) ; pfl.setName("pfl")
47 f=MEDCouplingFieldDouble(ON_CELLS) ; f.setName("ACellField")
48 arr=DataArrayDouble(16) ; arr.iota()
49 arr2=arr.deepCpy() ; arr2.reverse()
50 arr=DataArrayDouble.Meld(arr,arr2) ; arr.setInfoOnComponents(["aa","bbb"])
51 f.setArray(arr)
52 f1ts=MEDFileField1TS()
53 f1ts.setFieldProfile(f,mm,-1,pfl)
54 f1ts.write(fname,0)
55
56 ################### MED write is done -> Go to MEDReader
57
58 from paraview.simple import *
59
60
61
62 testMEDReader1=MEDReader(FileName=fname)
63 testMEDReader1.AllArrays=['TS0/mesh/ComSup0/ACellField@@][@@P0']
64 testMEDReader2=MEDReader(FileName=fname)
65 testMEDReader2.AllArrays=['TS0/mesh/ComSup1/mesh@@][@@P0']
66 GroupDatasets1=GroupDatasets(Input=[testMEDReader1,testMEDReader2])
67
68 Clip1 = Clip(ClipType="Plane")
69 Clip1.Input=GroupDatasets1
70 Clip1.Scalars=['FamilyIdCell']
71 Clip1.ClipType.Origin=[3.0, 3.0, 3.0]
72 Clip1.InsideOut=1
73 Clip1.ClipType.Normal=[0.9255623174457069, 0.0027407477590518157, 0.378585373233375]
74 Clip1.Scalars=['CELLS']
75
76 DataRepresentation4 = Show()
77 DataRepresentation4.EdgeColor = [0.0, 0.0, 0.5000076295109483]
78 DataRepresentation4.SelectionCellFieldDataArrayName = 'ACellField'
79 DataRepresentation4.ScalarOpacityUnitDistance = 1.61104723630366
80 DataRepresentation4.ExtractedBlockIndex = 2
81 DataRepresentation4.ScaleFactor = 0.6000000000000001
82 DataRepresentation4.Visibility = 1
83 DataRepresentation4.Representation = 'Wireframe'
84
85 ExtractBlock1 = ExtractBlock()
86 ExtractBlock1.BlockIndices=[1, 2]
87 ExtractBlock1.Input=Clip1
88
89 DataRepresentation5 = Show()
90 DataRepresentation5.EdgeColor = [0.0, 0.0, 0.5000076295109483]
91 DataRepresentation5.SelectionCellFieldDataArrayName = 'FamilyIdCell'
92 DataRepresentation5.ScaleFactor = 0.6
93 a2_ACellField_PVLookupTable=GetLookupTableForArray( "ACellField", 2, RGBPoints=[10.63014581273465, 0.23, 0.299, 0.754, 15.0, 0.706, 0.016, 0.15], VectorMode='Magnitude', NanColor=[0.25, 0.0, 0.0], ColorSpace='Diverging', ScalarRangeInitialized=1.0, AllowDuplicateScalars=1 )
94 a2_ACellField_PiecewiseFunction=CreatePiecewiseFunction( Points=[0.0, 0.0, 0.5, 0.0, 1.0, 1.0, 0.5, 0.0] )
95 a2_ACellField_PVLookupTable.ScalarOpacityFunction = a2_ACellField_PiecewiseFunction
96 DataRepresentation5.ScalarOpacityFunction = a2_ACellField_PiecewiseFunction
97 DataRepresentation5.LookupTable = a2_ACellField_PVLookupTable
98 DataRepresentation5.ColorArrayName = ("CELLS", "ACellField")
99
100 RenderView1 = GetRenderView()
101 RenderView1.CenterOfRotation = [3.0, 3.0, 3.0]
102 RenderView1.CameraViewUp = [-0.03886073885859842, 0.48373409998193495, 0.8743518533691291]
103 RenderView1.CameraPosition = [7.351939549758929, -5.688193007926853, 8.000155023042788]
104 RenderView1.CameraClippingRange = [0.026023957813772633, 26.023957813772633]
105 RenderView1.CameraFocalPoint = [2.9999999999999996, 2.9999999999999987, 2.9999999999999982]
106
107 RenderView1.ViewSize =[300,300]
108 WriteImage(outImgName)
109
110