1 # -*- coding: iso-8859-1 -*-
2 # Script de visualisation rosette et contrainte normale/tangeantielle
6 # MEDFILE : Fichier de resultat MED
7 # MAILLAGE : Nom du maillage
8 # GROUPE_FACE : Liste groupes de face de post-traitement
9 # COEFF_T1T2 : facteur scale rosette
10 # COEFF_TN : facteur scale normale/cisaillement
12 # T1 : Nom du champ SIRO_ELEM_T1
13 # T2 : Nom du champ SIRO_ELEM_T2
14 # T : Nom du champ SIRO_ELEM_SIGT
15 # N : Nom du champ SIRO_ELEM_SIGN
17 # ROSETTE : True/False
19 from paraview.simple import *
22 dataRoot = os.getenv('PARAVIEW_DATA_ROOT', "")
23 MEDFILE = dataRoot+'/rosette_am.med'
25 GROUPE_FACE = ['SURF_AM',]
29 T='RESUNL__SIRO_ELEM_TANGENT_Vector'
30 N='RESUNL__SIRO_ELEM_NORMAL_Vector'
31 T1 = 'RESUNL__SIRO_ELEM_T1_Vector'
32 T2 = 'RESUNL__SIRO_ELEM_T2_Vector'
36 # Fin données utilisateurs
40 #%==================== Importing MED file====================%
42 print ("**** Importing MED file")
44 myResult0 = MEDReader(FileNames=[MEDFILE])
45 if myResult0 is None : raise "Erreur de fichier MED"
47 # Imposition VectorsProperty à faire
48 myResult0.VectorsProperty=1
50 NB_ORDRE = myResult0.GetPropertyValue('TimestepValues')
52 #extraction groupes et visualisation du maillage
54 for g in GROUPE_FACE :
55 listeg.append('GRP_'+g)
57 myResult = ExtractGroup()
58 myResult.AllGroups=listeg
59 #myResult.Groups = listeg
62 CellCenters1 = CellCenters()
63 if len(NB_ORDRE) > 1 :
64 animation = GetAnimationScene()
65 #animation.AnimationTime = NB_ORDRE[2]
66 view2 = GetRenderView()
69 #%====================Displaying rosette====================%
74 print ("**** Displaying rosette")
76 view2.Background=[1.0,1.0,1.0]
77 SetActiveSource(myResult)
80 Display0.Representation = 'Wireframe'
81 Display0.AmbientColor=[0.0,0.0,0.0]
83 SetActiveSource(CellCenters1)
85 Glyph1.OrientationArray = ['POINTS', T1]
86 Glyph1.GlyphType ='Line'
87 Glyph1.GlyphMode = 'All Points'
89 pd1 = Glyph1.PointData
91 for i in range(len(pd1)):
92 if pd1.values()[i-1].GetName()== T1 :
94 NB_CMP = pd1.values()[i-1].GetNumberOfComponents()
95 NOM_CMP = pd1.values()[i-1].GetComponentName(NB_CMP)
96 RANGE_CMP = pd1.values()[i-1].GetRange(NB_CMP-1)
97 MAX_CMP = max(abs(RANGE_CMP[0]),abs(RANGE_CMP[1]))
98 if RANGE_CMP[0] < 0.0 :
102 if RANGE_CMP[1] > 0.0 :
109 Glyph1.ScaleArray = ['POINTS', T1]
110 Glyph1.VectorScaleMode = 'Scale by Magnitude'
111 Glyph1.ScaleFactor = COEFF_T1T2
115 PVLookupTable1 = GetLookupTableForArray( T1, NB_CMP, VectorMode = 'Component',VectorComponent=NB_CMP-1, NumberOfTableValues=2, RGBPoints=[-MAX_CMP, 0.0, 0.0, 1.0, MAX_CMP, 1.0, 0.0, 0.0], AutomaticRescaleRangeMode=-1, ScalarRangeInitialized = 1.0)
117 scalarbar1 = CreateScalarBar(Title =T1, ComponentTitle = NOM_CMP, LookupTable=PVLookupTable1, TitleFontSize=12 , LabelFontSize=12, TitleColor=[0.0,0.0,0.0],LabelColor=[0.0,0.0,0.0])
119 view2.Representations.append(scalarbar1)
120 Display1.ColorArrayName = T1
121 Display1.LookupTable = PVLookupTable1
122 Display1.Representation = 'Surface'
124 SetActiveSource(CellCenters1)
126 Glyph2.OrientationArray = ['POINTS', T2]
127 Glyph2.GlyphType ='Line'
128 Glyph2.ScaleArray = ['POINTS', T2]
129 Glyph2.VectorScaleMode = 'Scale by Magnitude'
130 Glyph2.ScaleFactor = COEFF_T1T2
132 Glyph2.GlyphMode = 'All Points'
134 pd2 = Glyph2.PointData
136 for i in range(len(pd2)):
137 if pd2.values()[i-1].GetName()== T2 :
138 NB_CMP = pd2.values()[i-1].GetNumberOfComponents()
139 NOM_CMP = pd2.values()[i-1].GetComponentName(NB_CMP-1)
140 RANGE_CMP = pd2.values()[i-1].GetRange(NB_CMP-1)
141 MAX_CMP = max(abs(RANGE_CMP[0]),abs(RANGE_CMP[1]))
142 if RANGE_CMP[0] < 0.0 :
143 C_MAX = max(C_MAX,-RANGE_CMP[0])
144 if RANGE_CMP[1] > 0.0 :
145 T_MAX = max(T_MAX,RANGE_CMP[1])
149 PVLookupTable2 = GetLookupTableForArray( T2, NB_CMP, VectorMode = 'Component',VectorComponent=NB_CMP-1, NumberOfTableValues=2, RGBPoints=[-MAX_CMP, 0.0, 0.0, 1.0, MAX_CMP, 1.0, 0.0, 0.0], AutomaticRescaleRangeMode=-1)
150 scalarbar2 = CreateScalarBar(Title =T2, ComponentTitle = NOM_CMP, LookupTable=PVLookupTable2, TitleFontSize=12 , LabelFontSize=12,TitleColor=[0.0,0.0,0.0],LabelColor=[0.0,0.0,0.0])
151 #view2.Representations.append(scalarbar2)
152 Display2.ColorArrayName = T2
153 Display2.LookupTable = PVLookupTable2
154 Display2.Representation = 'Surface'
157 Texte = 'COMPRESSION MAX = '+str(C_MAX)+' MPa \nTRACTION MAX = '+str(T_MAX)+' Mpa'
160 DisplayT.FontSize = 12
161 DisplayT.Color=[0.0, 0.0, 0.0]
164 view2.CameraPosition = [-524.450475200065, -34.2470779418945, 572.968383789062]
165 view2.CameraFocalPoint = [9.7492516040802, -34.2470779418945, 572.968383789062]
166 view2.CameraViewUp = [0.0, 0.0, 1.0]
171 baselineIndex = sys.argv.index('-B')+1
172 baselinePath = sys.argv[baselineIndex]
174 print ("Could not get baseline directory. Test failed.")
175 baseline_file = os.path.join(baselinePath, "TestDataAnalysis.png")
176 from paraview.vtk.test import Testing
177 from paraview.vtk.util.misc import vtkGetTempDir
178 Testing.VTK_TEMP_DIR = vtkGetTempDir()
179 Testing.compareImage(view2.GetRenderWindow(), baseline_file, threshold=10)