1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2014 CEA/DEN, EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Author : Anthony Geay
22 from MEDLoader import *
24 fname="testMEDReader3.med"
25 outImgName="testMEDReader3.png"
27 """ This test checks that invalid double time (not in [-1e299:1e299])
28 leads MEDReader to takes iteration numbers instead of double time to discriminate timesteps each other
33 m=MEDCouplingUMesh("mesh",2)
34 coords=DataArrayDouble([(0.,0.,0.),(1.,0.,0.),(1.,1.,0.),(0.,1.,0.)],4,3)
37 m.insertNextCell(NORM_QUAD4,[0,3,2,1])
39 mm.setMeshAtLevel(0,m)
41 fmts=MEDFileFieldMultiTS()
43 f=MEDCouplingFieldDouble(ON_NODES) ; f.setName("ANodeField")
44 f.setTime(1.7976931348623157e+308,1,1) ; f.setMesh(m)
45 arr=DataArrayDouble([0.,4.,4.,4.]) ; arr.setInfoOnComponent(0,"aaa")
47 f1ts=MEDFileField1TS()
48 f1ts.setFieldNoProfileSBT(f)
49 fmts.pushBackTimeStep(f1ts)
51 f.setTime(1.7976931348623157e+308,2,2)
52 arr=DataArrayDouble([1.,4.,4.,4.]) ; arr.setInfoOnComponent(0,"aaa")
54 f1ts=MEDFileField1TS()
55 f1ts.setFieldNoProfileSBT(f)
56 fmts.pushBackTimeStep(f1ts)
58 f.setTime(1.7976931348623157e+308,3,3)
59 arr=DataArrayDouble([2.,4.,4.,4.]) ; arr.setInfoOnComponent(0,"aaa")
61 f1ts=MEDFileField1TS()
62 f1ts.setFieldNoProfileSBT(f)
63 fmts.pushBackTimeStep(f1ts)
65 f.setTime(1.7976931348623157e+308,4,6)
66 arr=DataArrayDouble([3.,4.,4.,4.]) ; arr.setInfoOnComponent(0,"aaa")
68 f1ts=MEDFileField1TS()
69 f1ts.setFieldNoProfileSBT(f)
70 fmts.pushBackTimeStep(f1ts)
72 f.setTime(1.7976931348623157e+308,5,7)
73 arr=DataArrayDouble([4.,4.,4.,4.]) ; arr.setInfoOnComponent(0,"aaa")
75 f1ts=MEDFileField1TS()
76 f1ts.setFieldNoProfileSBT(f)
77 fmts.pushBackTimeStep(f1ts)
81 ################### MED write is done -> Go to MEDReader
83 from paraview.simple import *
85 AnimationScene1=GetAnimationScene()
86 AnimationScene1.PlayMode='Snap To TimeSteps'
87 AnimationScene1.EndTime = 2.0
88 AnimationScene1.AnimationTime = 1.0
89 AnimationScene1.StartTime = 1.0
91 testMEDReader3=MEDReader(FileName=fname)
92 testMEDReader3.AllArrays=['TS0/mesh/ComSup0/ANodeField@@][@@P1']
94 assert(list(testMEDReader3.TimestepValues)==[1.,2.,3.,4.,5.]) ## <- the test is here - double time steps are too big use dt.
96 RenderView1=GetRenderView()
97 RenderView1.ViewTime=3.0
98 RenderView1.CameraPosition=[0.5,0.5,5.7320508075688776]
99 RenderView1.CameraClippingRange=[2.704730299493189,2.7730315696824106]
100 RenderView1.ViewSize=[300,300]
102 DataRepresentation2=Show()
103 DataRepresentation2.EdgeColor=[0.0, 0.0, 0.5000076295109483]
104 DataRepresentation2.SelectionPointFieldDataArrayName='ANodeField'
105 DataRepresentation2.SelectionCellFieldDataArrayName='FamilyIdCell'
106 DataRepresentation2.ScalarOpacityUnitDistance=1.4142135623730951
107 DataRepresentation2.ExtractedBlockIndex=1
108 DataRepresentation2.ScaleFactor=0.1
110 a1_ANodeField_PVLookupTable=GetLookupTableForArray("ANodeField",1,RGBPoints=[0.0,0.23,0.299,0.754,4.0,0.706,0.016,0.15],VectorMode='Magnitude',NanColor=[0.25,0.0,0.0],
111 ColorSpace='Diverging',ScalarRangeInitialized=1.0,AllowDuplicateScalars=1)
112 a1_ANodeField_PiecewiseFunction=CreatePiecewiseFunction(Points=[0.0,0.0,0.5,0.0,1.0,1.0,0.5,0.0])
113 a1_ANodeField_PVLookupTable.ScalarOpacityFunction=a1_ANodeField_PiecewiseFunction
115 DataRepresentation2.ScalarOpacityFunction=a1_ANodeField_PiecewiseFunction
116 DataRepresentation2.ColorArrayName='ANodeField'
117 DataRepresentation2.LookupTable=a1_ANodeField_PVLookupTable
119 WriteImage(outImgName)