def displayMaxPressures(self,FEcase,combs,caption,fUnitConv,unitDescription,rgMinMax=None,fileName=None): '''Calculate and display the maximum earth pressures (Z direction) obtained from the group of load combinations passed as paremeter. :param FEcase: finite element problem :param combs: load cases to analyze and compare to obtain the maximum pressures. :param caption: caption text to diaplay. :param fUnitConv: factor to apply to results (unit conversion) :param unitDescription: text to display as unit description. :param rgMinMax: range (vmin,vmax) with the maximum and minimum values of the scalar field (if any) to be represented. All the values less than vmin are displayed in blue and those greater than vmax in red (defaults to None) :param fileName: file name (defaults to None -> screen display) ''' #Init max. pressures nodSet=self.foundationSet.getNodes for n in nodSet: n.setProp('maxSoilPressure',-1e10) #Calculate max. pressures for lc in combs: lcs=QGrph.LoadCaseResults(FEcase) lcs.solve(loadCaseName=combs[lc].name,loadCaseExpr=combs[lc].expr) reac= self.calcPressures() for n in nodSet: prs=n.getProp('soilPressure')[2] if prs > n.getProp('maxSoilPressure'): n.setProp('maxSoilPressure',prs) #Display max. pressures field= fields.ExtrapolatedScalarField(name='maxSoilPressure',functionName='getProp',xcSet=self.foundationSet,component=None,fUnitConv=fUnitConv,rgMinMax=rgMinMax) displaySettings= vtk_FE_graphic.DisplaySettingsFE() field.display(displaySettings,caption= caption+' '+unitDescription,fName=fileName)
def displayDiagram(attributeName,component, setToDispRes,setDisp,caption,scaleFactor= 1.0, fileName= None, defFScale= 0.0): '''Auxiliary function to display results on linear elements. :param attributeName: attribute name(e.g. 'ULS_normalStressesResistance') :param component: result item to display (e.g. 'N', 'My', ...) :param setToDispRes: set of linear elements to which display results :param setToDisplay: set of elements (any type) to be depicted :param scaleFactor: factor of scale to apply to the auto-scaled display (defaults to 1) :param caption: caption to display :param fileName: file to dump the display :param defFScale: factor to apply to current displacement of nodes so that the display position of each node equals to the initial position plus its displacement multiplied by this factor. (Defaults to 0.0, i.e. display of initial/undeformed shape) ''' diagram= cvd.ControlVarDiagram(scaleFactor= scaleFactor,fUnitConv= unitConversionFactor,sets=[setToDispRes],attributeName= attributeName,component= component) diagram.addDiagram() displaySettings= vtk_FE_graphic.DisplaySettingsFE() displaySettings.cameraParameters=cameraParameters displaySettings.setupGrid(setToDisplay) displaySettings.defineMeshScene(None,defFScale,color=setToDisplay.color) displaySettings.appendDiagram(diagram) #Append diagram to the scene. displaySettings.displayScene(caption=caption,fileName=fileName)
def displayElementValueDiagram(self, itemToDisp, setToDisplay=None,caption= None,fileName=None,defFScale=0.0): '''displays the a displacement (uX,uY,...) or a property defined in nodes as a diagram over lines. :param itemToDisp: item to display (uX,uY,...). :param setToDisplay: set of entities (elements of type beam) to be represented :param fileName: name of the file to plot the graphic. Defaults to None, in that case an screen display is generated :param defFScale: factor to apply to current displacement of nodes so that the display position of each node equals to the initial position plus its displacement multiplied by this factor. (Defaults to 0.0, i.e. display of initial/undeformed shape) ''' if(setToDisplay==None): setToDisplay= self.modelSpace.getTotalSet() unitConversionFactor, unitDescription= self.outputStyle.getUnitParameters(itemToDisp) scaleFactor= 1.0 diagram= epd.ElementPropertyDiagram(scaleFactor= scaleFactor,fUnitConv= unitConversionFactor,sets=[setToDisplay], propertyName= itemToDisp) diagram.addDiagram() displaySettings= vtk_FE_graphic.DisplaySettingsFE() displaySettings.cameraParameters= self.getCameraParameters() grid= displaySettings.setupGrid(setToDisplay) displaySettings.defineMeshScene(None,defFScale,color=setToDisplay.color) displaySettings.appendDiagram(diagram) #Append diagram to the scene. loadCaseName= self.modelSpace.preprocessor.getDomain.currentCombinationName if(not caption): caption= loadCaseName+' '+itemToDisp+' '+unitDescription +' '+setToDisplay.description displaySettings.displayScene(caption=caption,fileName=fileName)
def displayLoadVectors(self, setToDisplay= None, caption= None, fileName= None, defFScale= 0.0): '''Displays load vectors on the set argument. :param setToDisplay: set of elements to be displayed (defaults to total set) :param caption: text to display in the graphic. Defaults to ` None` in this case the text is the load case description and the units of the loads. :param fileName: full name of the graphic file to generate. Defaults to ` None`, in this case it returns a console output graphic., :param defFScale: factor to apply to current displacement of nodes so that the display position of each node equals to the initial position plus its displacement multiplied by this factor. (Defaults to 0.0, i.e. display of initial/undeformed shape) ''' if(setToDisplay==None): setToDisplay= self.modelSpace.getTotalSet() preprocessor= self.modelSpace.preprocessor loadCaseName= self.modelSpace.preprocessor.getDomain.currentCombinationName unitConversionFactor= self.outputStyle.getForceUnitsScaleFactor() unitDescription= self.outputStyle.getForceUnitsDescription() if(not caption): caption= 'load case: ' + loadCaseName + ', set: ' + setToDisplay.name + ', ' + unitDescription LrefModSize=setToDisplay.getBnd(1.0).diagonal.getModulus() #representative length of set size (to auto-scale) vectorScale= self.outputStyle.loadVectorsScaleFactor*LrefModSize/10. vField= lvf.LoadVectorField(loadCaseName,setToDisplay,unitConversionFactor,vectorScale) vField.multiplyByElementArea= self.outputStyle.multLoadsByElemArea displaySettings= vtk_FE_graphic.DisplaySettingsFE() displaySettings.cameraParameters= self.getCameraParameters() displaySettings.setupGrid(setToDisplay) vField.dumpVectors(preprocessor,defFScale) displaySettings.defineMeshScene(None,defFScale,color=setToDisplay.color) vField.addToDisplay(displaySettings) displaySettings.displayScene(caption,fileName) return displaySettings
def displayPressures(self, caption, fUnitConv, unitDescription, rgMinMax=None, fileName=None): '''Display foundation pressures for a single load case. :param rgMinMax: range (vmin,vmax) with the maximum and minimum values of the scalar field (if any) to be represented. All the values less than vmin are displayed in blue and those greater than vmax in red (defaults to None) :param fileName: file name (defaults to None -> screen display) ''' reac = self.calcPressures() field = fields.ExtrapolatedScalarField('soilPressure', 'getProp', self.foundationSet, component=2, fUnitConv=fUnitConv, rgMinMax=rgMinMax) displaySettings = vtk_FE_graphic.DisplaySettingsFE() field.display(displaySettings, caption=caption + ' ' + unitDescription, fName=fileName)
def __init__(self, xcSet): self.displaySettings = None self.xcSet = xcSet self.displaySettings = vtk_FE_graphic.DisplaySettingsFE() self.pthGraphOutput = '/tmp/' #Directory to put the graphics in. self.pthTextOutput = '/tmp/' #Directory to put the texts in. self.fichLatexFigs = None #Latex file to include figures. self.fichLatexList = None #Latex file with figures list.
def displayReactions(self,setToDisplay=None,fileName=None,defFScale=0.0, inclInertia= False): ''' Display reactions. :param setToDisplay: set of entities to be represented. :param fileName: name of the file to plot the graphic. Defaults to None, in that case an screen display is generated :param defFScale: factor to apply to current displacement of nodes so that the display position of each node equals to the initial position plus its displacement multiplied by this factor. (Defaults to 0.0, i.e. display of initial/undeformed shape) :param inclInertia: include inertia effects (defaults to false). ''' if(setToDisplay==None): setToDisplay= self.modelSpace.getTotalSet() self.modelSpace.preprocessor.getNodeHandler.calculateNodalReactions(inclInertia,1e-7) #auto-scale LrefModSize= setToDisplay.getBnd(1.0).diagonal.getModulus() #representative length of set size (to autoscale) maxAbs=0.0 forcePairs= list() momentPairs= list() threshold= LrefModSize/1000.0 for n in setToDisplay.nodes: f3d= n.getReactionForce3d m3d= n.getReactionMoment3d modF3d= f3d.getModulus() if(modF3d>threshold): p=n.getCurrentPos3d(defFScale) forcePairs.append(([p.x,p.y,p.z],[f3d.x,f3d.y,f3d.z])) modM3d= m3d.getModulus() if(modM3d>threshold): p=n.getCurrentPos3d(defFScale) momentPairs.append(([p.x,p.y,p.z],[m3d.x,m3d.y,m3d.z])) modR= max(modF3d,modF3d) if(modR>maxAbs): maxAbs=modR unitConversionFactor= self.outputStyle.getForceUnitsScaleFactor() unitDescription= self.outputStyle.getForceUnitsDescription() scaleFactor= self.outputStyle.reactionVectorsScaleFactor if(maxAbs>0): scaleFactor*=0.15*LrefModSize/(maxAbs*unitConversionFactor) captionText= self.getCaptionText('Reactions', unitDescription, setToDisplay) vFieldF= vf.VectorField(name='Freact',fUnitConv=unitConversionFactor,scaleFactor=scaleFactor,showPushing= True,symType=vtk.vtkArrowSource()) # Force vFieldM= vf.VectorField(name='Mreact',fUnitConv=unitConversionFactor,scaleFactor=scaleFactor,showPushing= True,symType=vtk.vtkArrowSource()) # Moment vFieldF.populateFromPairList(forcePairs) vFieldM.populateFromPairList(momentPairs) displaySettings= vtk_FE_graphic.DisplaySettingsFE() displaySettings.cameraParameters= self.getCameraParameters() displaySettings.setupGrid(setToDisplay) displaySettings.defineMeshScene(None,defFScale,color= setToDisplay.color) if(len(forcePairs)>0): vFieldF.addToDisplay(displaySettings) if(len(momentPairs)>0): vFieldM.addToDisplay(displaySettings,'V') displaySettings.displayScene(captionText,fileName)
def displayLoads(self, setToDisplay=None,elLoadComp='xyzComponents',fUnitConv=1,caption= None,fileName=None,defFScale=0.0): '''Display the loads applied on beam elements and nodes for a given load case :param setToDisplay: set of beam elements to be represented (defaults to TotalSet) :param elLoadComp: component of the loads on elements to be depicted [possible components: 'axialComponent', 'transComponent', 'transYComponent', 'transZComponent','xyzComponents'] :param fUnitConv: factor of conversion to be applied to the results (defaults to 1) :param caption: caption for the graphic :param fileName: name of the file to plot the graphic. Defaults to None, in that case an screen display is generated :param defFScale: factor to apply to current displacement of nodes so that the display position of each node equals to the initial position plus its displacement multiplied by this factor. (Defaults to 0.0, i.e. display of initial/undeformed shape) ''' if(setToDisplay==None): setToDisplay= self.modelSpace.getTotalSet() preprocessor= self.modelSpace.preprocessor loadCaseName= self.modelSpace.preprocessor.getDomain.currentCombinationName unitConversionFactor= self.outputStyle.getForceUnitsScaleFactor() unitDescription= self.outputStyle.getForceUnitsDescription() preprocessor= setToDisplay.getPreprocessor displaySettings= vtk_FE_graphic.DisplaySettingsFE() displaySettings.cameraParameters= self.getCameraParameters() grid= displaySettings.setupGrid(setToDisplay) displaySettings.defineMeshScene(None,defFScale,color=setToDisplay.color) # auto-scaling parameters LrefModSize=setToDisplay.getBnd(1.0).diagonal.getModulus() #representative length of set size (to auto-scale) elLoadScaleF= self.outputStyle.loadDiagramsScaleFactor diagram= lld.LinearLoadDiagram(setToDisp=setToDisplay,scale=elLoadScaleF,fUnitConv= unitConversionFactor,component=elLoadComp) maxAbs= diagram.getMaxAbsComp(preprocessor) if(maxAbs>0): elLoadScaleF*= LrefModSize/maxAbs*100.0 diagram.scaleFactor= elLoadScaleF #Linear loads diagram.addDiagram(preprocessor) if(diagram.isValid()): displaySettings.appendDiagram(diagram) # nodal loads vectorScale= self.outputStyle.loadVectorsScaleFactor*LrefModSize/10. vField= lvf.LoadVectorField(loadPatternName= loadCaseName,setToDisp=setToDisplay,fUnitConv= unitConversionFactor,scaleFactor= vectorScale, showPushing= self.outputStyle.showLoadsPushing) vField.multiplyByElementArea= self.outputStyle.multLoadsByElemArea count= vField.dumpNodalLoads(preprocessor, defFScale=defFScale) if(count >0): # vField.addToDisplay(displaySettings,orientation= self.outputStyle.nodalLoadBarOrientation) vField.addToDisplay(displaySettings,orientation= 'RV') if(not caption): caption= 'load case: ' + loadCaseName +' '+elLoadComp + ', set: ' + setToDisplay.name + ', ' + unitDescription displaySettings.displayScene(caption=caption,fileName=fileName)
def displayBeamResult(self,attributeName,itemToDisp,beamSetDispRes,setToDisplay=None,caption=None,fileName=None,defFScale=0.0): '''display results for beam elements from a limit state verification file. :param attributeName:attribute name(e.g. 'ULS_normalStressesResistance') :param itemToDisp: result item to display (e.g. 'N', 'My', ...) :param beamSetDispRes:set of linear elements to which display results :param setToDisplay: set of elements (any type) to be depicted (defaults to None, in that case only elements in beamSetDispRes are displayed) :param caption: caption to display (defaults to 'attributeName + itemToDisp') :param fileName: file to dump the display (defaults to screen display) :param defFScale: factor to apply to current displacement of nodes so that the display position of each node equals to the initial position plus its displacement multiplied by this factor. (Defaults to 0.0, i.e. display of initial/undeformed shape) ''' #auto-scale parameters if(len(beamSetDispRes.elements)): LrefModSize=setToDisplay.getBnd(1.0).diagonal.getModulus() #representative length of set size (to autoscale) lstArgVal=[e.getProp(attributeName+'Sect1')(itemToDisp) for e in beamSetDispRes.elements] unitConversionFactor, unitDescription= self.outputStyle.getUnitParameters(itemToDisp) scaleFactor= 1.0 maxAbs=max(abs(max(lstArgVal)),abs(min(lstArgVal))) if(maxAbs>0): scaleFactor*=0.15*LrefModSize/(maxAbs*unitConversionFactor) if not setToDisplay: setToDisplay= beamSetDispRes if not caption: if hasattr(beamSetDispRes,'description'): descrSet= beamSetDispRes.description.capitalize() if(len(descrSet)==0): # No description provided. descrSet= beamSetDispRes.name caption= attributeName + ', ' + itemToDisp +' '+unitDescription+ '. '+ descrSet diagram= cvd.ControlVarDiagram(scaleFactor= scaleFactor,fUnitConv= unitConversionFactor,sets=[beamSetDispRes],attributeName= attributeName,component= itemToDisp) diagram.addDiagram() displaySettings= vtk_FE_graphic.DisplaySettingsFE() displaySettings.cameraParameters= self.getCameraParameters() displaySettings.setupGrid(setToDisplay) displaySettings.defineMeshScene(None,defFScale,color= setToDisplay.color) displaySettings.appendDiagram(diagram) #Append diagram to the scene. displaySettings.displayScene(caption= caption,fileName= fileName) else: lmsg.warning('Element set: \''+beamSetDispRes.name+'\' is empty. There is nothing to display.')
def displayLocalAxes(self, setToDisplay= None, caption= None, fileName=None, defFScale= 0.0): '''Display the local axes of the elements contained in the set. :param setToDisplay: set to display. :param caption: title of the graphic. :param fileName: name of the file to plot the graphic. Defaults to None, in that case an screen display is generated :param defFScale: factor to apply to current displacement of nodes so that the display position of each node equals to the initial position plus its displacement multiplied by this factor. (Defaults to 0.0, i.e. display of initial/undeformed shape) ''' if(setToDisplay==None): setToDisplay= self.modelSpace.getTotalSet() if(caption==None): caption= setToDisplay.name+' set; local axes' displaySettings= vtk_FE_graphic.DisplaySettingsFE() displaySettings.cameraParameters= self.getCameraParameters() displaySettings.displayLocalAxes(setToDisplay,caption= caption, vectorScale= self.outputStyle.localAxesVectorsScaleFactor, fileName= fileName, defFScale= defFScale)
def displayIntForc(self,itemToDisp, setToDisplay=None,fileName=None,defFScale=0.0, rgMinMax=None): '''displays the component of internal forces in the set of entities as a scalar field (i.e. appropiated for 2D elements; shells...). :param itemToDisp: component of the internal forces ('N1', 'N2', 'N12', 'M1', 'M2', 'M12', 'Q1', 'Q2') to be depicted :param setToDisplay: set of entities to be represented (default to all entities) :param fileName: name of the file to plot the graphic. Defaults to None, in that case an screen display is generated :param defFScale: factor to apply to current displacement of nodes so that the display position of each node equals to the initial position plus its displacement multiplied by this factor. (Defaults to 0.0, i.e. display of initial/undeformed shape) :param rgMinMax: range (vmin,vmax) with the maximum and minimum values of the field to be represented. All the values less than vmin are displayed in blue and those greater than vmax in red (defaults to None) ''' if(setToDisplay==None): setToDisplay= self.modelSpace.getTotalSet() vCompDisp= self.modelSpace.getIntForceComponentFromName(itemToDisp) elSet= setToDisplay.elements.pickElemsOfDimension(2) if(len(elSet)>0): propName= 'propToDisp_'+str(itemToDisp) for e in elSet: if(e.getDimension==2): e.getResistingForce() physProp= e.getPhysicalProperties e.setProp(propName,physProp.getMeanGeneralizedStressByName(vCompDisp)) else: lmsg.warning('OutputHandler::displayIntForc; not a 2D element; ignored.') unitConversionFactor= self.outputStyle.getForceUnitsScaleFactor() unitDescription= self.outputStyle.getForceUnitsDescription() field= fields.ExtrapolatedProperty(propName,"getProp",setToDisplay,fUnitConv= unitConversionFactor,rgMinMax=rgMinMax) displaySettings= vtk_FE_graphic.DisplaySettingsFE() displaySettings.cameraParameters= self.getCameraParameters() captionText= self.getCaptionText(itemToDisp, unitDescription, setToDisplay) field.display(displaySettings=displaySettings,caption= captionText,fileName=fileName, defFScale=defFScale)
def displayField(self,limitStateLabel, section,argument, component, setToDisplay, fileName, defFScale=0.0, rgMinMax=None): '''Display a field defined over bi-dimensional elements in its two directions. :param limitStateLabel: label that identifies the limit state. :param section: section to display (1 or 2 or None if the value is not section dependent). :param argument: name of the control var to represent. :param component: component of the control var to represent. :param setToDisplay: represent the field over those elements. :param fileName: file name to store the image. If none -> window on screen. :param defFScale: factor to apply to current displacement of nodes so that the display position of each node equals to the initial position plus its displacement multiplied by this factor. (Defaults to 0.0, i.e. display of initial/undeformed shape) :param rgMinMax: range (vmin,vmax) with the maximum and minimum values of the scalar field (if any) to be represented. All the values less than vmin are displayed in blue and those greater than vmax in red (defaults to None) ''' sectRef= '' sectDescr= '' if(section): if section not in [1,2]: lmsg.warning('section', section, "doesn't exist, section 1 is displayed instead") section=1 sectRef='Sect'+str(section) sectDescr= self.outputStyle.directionDescription[section-1] if(setToDisplay==None): setToDisplay= self.modelSpace.getTotalSet() displaySettings= vtk_FE_graphic.DisplaySettingsFE() displaySettings.cameraParameters= self.getCameraParameters() attributeName= limitStateLabel + sectRef fUnitConv, unitDescription= self.outputStyle.getUnitParameters(argument) field= fields.getScalarFieldFromControlVar(attributeName,argument,setToDisplay,component,fUnitConv,rgMinMax) captionTexts= self.outputStyle.getCaptionTextsDict() captionBaseText= captionTexts[limitStateLabel] + ', ' + captionTexts[argument] + unitDescription + '. '+ setToDisplay.description.capitalize() field.display(displaySettings,caption= captionBaseText + ', ' + sectDescr, fileName= fileName, defFScale= defFScale)
def displayFEMesh(self, setsToDisplay= None, caption= None, fileName= None, defFScale= 0.0): '''Display the mesh (nodes, elements and constraints) of the set. :param setsToDisplay: list of sets to display (defaults to TotalSet). :param caption: title of the graphic. :param fileName: name of the file to plot the graphic. Defaults to None, in that case an screen display is generated :param defFScale: factor to apply to current displacement of nodes so that the display position of each node equals to the initial position plus its displacement multiplied by this factor. (Defaults to 0.0, i.e. display of initial/undeformed shape) ''' if(setsToDisplay==None): setsToDisplay= [self.modelSpace.getTotalSet()] if(caption==None): caption= 'mesh' displaySettings= vtk_FE_graphic.DisplaySettingsFE() displaySettings.cameraParameters= self.getCameraParameters() displaySettings.displayMesh(xcSets=setsToDisplay,caption= caption, scaleConstr= self.outputStyle.constraintsScaleFactor, fileName= fileName, defFScale= defFScale)
def displayEigenResult(self,eigenMode, setToDisplay=None, accelMode=None, caption= '',fileName=None, defFScale= 0.0): '''Display the deformed shape and/or the equivalent static forces associated with the eigenvibration mode passed as parameter. :param eigenMode: eigenvibration mode to be displayed :param setToDisplay: set of elements to be displayed (defaults to total set) :param accelMode: acceleration associated with the eigen mode depicted, only used if the equivalent static loads are to be displayed. :param caption: text to display in the graphic :param fileName: full name of the graphic file to generate. Defaults to ` None`, in this case it returns a console output graphic. :param defFScale: factor to apply to deformed shape so that the displayed position of each node equals to the initial position plus its eigenVector multiplied by this factor. (Defaults to 0.0 i.e. display of initial/undeformed shape) ''' if(setToDisplay==None): setToDisplay= self.modelSpace.getTotalSet() equLoadVctScale= self.outputStyle.equivalentLoadVectorsScaleFactor if((equLoadVctScale!=0.0) and accelMode==None): lmsg.warning("Can't display equivalent static loads. Parameter accelMode should not be null ") equLoadVctScale=None displaySettings= vtk_FE_graphic.DisplaySettingsFE() displaySettings.setupGrid(setToDisplay) displaySettings.cameraParameters= self.getCameraParameters() displaySettings.defineMeshScene(None,defFScale,eigenMode,color=setToDisplay.color) unitsScale= 1.0 if equLoadVctScale not in [None,0]: vField=vf.VectorField(name='modo'+str(eigenMode),fUnitConv=unitsScale,scaleFactor=equLoadVctScale,showPushing= True) setNodes= setToDisplay.nodes for n in setNodes: pos= n.getEigenPos3d(defFScale,eigenMode) vEqLoad= n.getEquivalentStaticLoad(eigenMode,accelMode) vField.data.insertNextPair(pos.x,pos.y,pos.z,vEqLoad[0],vEqLoad[1],vEqLoad[2],unitsScale,pushing= True) vField.addToDisplay(displaySettings) if(not caption): caption= 'Mode '+ str(eigenMode) + ' shape' + ' '+setToDisplay.description displaySettings.displayScene(caption,fileName) return displaySettings
def displayScalarPropertyAtNodes(self,propToDisp, fUnitConv, unitDescription, captionText, setToDisplay, fileName=None, defFScale=0.0, rgMinMax=None): '''displays the scalar property defined at the nodes of the set. :param propeToDisp: scalar property defined at nodes. :param fUnitConv: conversion factor for units :param unitDescription: unit(s) symbol(s) :param setToDisplay: set of entities to be represented. :param fileName: name of the file to plot the graphic. Defaults to None, in that case an screen display is generated :param defFScale: factor to apply to current displacement of nodes so that the display position of each node equals to the initial position plus its displacement multiplied by this factor. (Defaults to 0.0, i.e. display of initial/undeformed shape) :param rgMinMax: range (vmin,vmax) with the maximum and minimum values of the field to be represented. All the values less than vmin are displayed in blue and those greater than vmax in red (defaults to None) ''' field= fields.ScalarField(name=propToDisp,functionName="getProp",component=None,fUnitConv= fUnitConv,rgMinMax=rgMinMax) displaySettings= vtk_FE_graphic.DisplaySettingsFE() displaySettings.cameraParameters= self.getCameraParameters() displaySettings.displayMesh(xcSets=setToDisplay,field=field, diagrams= None, caption= captionText, fileName=fileName, defFScale=defFScale)
def displayIntForcDiag(self,itemToDisp, setToDisplay=None,fileName=None,defFScale=0.0): '''displays the component of internal forces in the set of entities as a diagram over lines (i.e. appropiated for beam elements). :param itemToDisp: component of the internal forces ('N', 'Qy' (or 'Vy'), 'Qz' (or 'Vz'), 'My', 'Mz', 'T') to be depicted :param setToDisplay: set of entities (elements of type beam) to be represented :param fileName: name of the file to plot the graphic. Defaults to None, in that case an screen display is generated :param defFScale: factor to apply to current displacement of nodes so that the display position of each node equals to the initial position plus its displacement multiplied by this factor. (Defaults to 0.0, i.e. display of initial/undeformed shape) ''' if(setToDisplay==None): setToDisplay= self.modelSpace.getTotalSet() #auto-scale parameters LrefModSize= setToDisplay.getBnd(1.0).diagonal.getModulus() #representative length of set size (to autoscale) scaleFactor= self.outputStyle.internalForcesDiagramScaleFactor unitConversionFactor= self.outputStyle.getForceUnitsScaleFactor() unitDescription= self.outputStyle.getForceUnitsDescription() diagAux=cvd.ControlVarDiagram(scaleFactor= scaleFactor,fUnitConv= unitConversionFactor,sets=[setToDisplay],attributeName= "intForce",component= itemToDisp) maxAbs=diagAux.getMaxAbsComp() if maxAbs > 0: scaleFactor*=0.15*LrefModSize/(maxAbs*unitConversionFactor) captionText= self.getCaptionText(itemToDisp, unitDescription, setToDisplay) diagram= cvd.ControlVarDiagram(scaleFactor= scaleFactor,fUnitConv= unitConversionFactor,sets=[setToDisplay],attributeName= "intForce",component= itemToDisp) diagram.addDiagram() displaySettings= vtk_FE_graphic.DisplaySettingsFE() displaySettings.cameraParameters= self.getCameraParameters() displaySettings.setupGrid(setToDisplay) displaySettings.defineMeshScene(None,defFScale,color= setToDisplay.color) displaySettings.appendDiagram(diagram) #Append diagram to the scene. displaySettings.displayScene(caption= captionText,fileName= fileName)
#Load properties to display: preprocessor= model.getPreprocessor() fName= cfg.projectDirTree.getVerifCrackQpermFile() execfile(fName) execfile('../captionTexts.py') limitStateLabel= lsd.quasiPermanentLoadsCrackControl.label #Possible arguments: 'getCF', 'getMaxSteelStress' argument= 'getMaxSteelStress' setDispRes=colsSet #set of linear elements to which display results setDisp=xcTotalSet #set of elements (any type) to be displayed diagram= cvd.ControlVarDiagram(scaleFactor= 1,fUnitConv= 1,sets=[setDispRes.elSet],attributeName= limitStateLabel,component= argument) diagram.addDiagram() displaySettings= vtk_FE_graphic.DisplaySettingsFE() #predefined view names: 'XYZPos','XNeg','XPos','YNeg','YPos', # 'ZNeg','ZPos' (defaults to 'XYZPos') displaySettings.cameraParameters= vtk_graphic_base.CameraParameters('YPos') #Point of view. displaySettings.setupGrid(setDisp.elSet) displaySettings.defineMeshScene(None) displaySettings.appendDiagram(diagram) #Append diagram to the scene. caption= capTexts[limitStateLabel] + ', ' + capTexts[argument] + '. '+ setDispRes.genDescr.capitalize() + ', ' + setDispRes.sectDescr[0] displaySettings.displayScene(caption)
def checksReports(limitStateLabel, setsShEl, argsShEl, capTexts, pathGr, texReportFile, grWdt, setsBmElView=[], argsBmElScale=[]): '''Create a LaTeX report including the desired graphical results obtained in the verification of a limit state. :param limitStateLabel:limit state :param setsShEl: Ordered list of sets of shell elements (defined in model_data.py as instances of utils_display.setToDisplay) to be included in the report :param argsShEl: Ordered list of arguments to be included in the report for shell elements :param capTexts: dictionary from wich to read the texts for captions :param pathGr: width to be applied to graphics :param texReportFile:laTex file where to include the graphics :param grWdt: width of the graphics for the tex file :param setsBmView: Ordered list of lists [set of beam elements, view to represent this set] to be included in the report. The sets have been defined in model_data.py as instances of utils_display.setToDisplay and the possible views are: 'XYZPos','XNeg','XPos','YNeg','YPos', 'ZNeg','ZPos' (defaults to 'XYZPos') :param argsShEl: Ordered list of lists [arguments, scale to represent the argument] to be included in the report for beam elements ''' report = open(texReportFile, 'w') #report latex file dfDisp = vtk_FE_graphic.DisplaySettingsFE() for st in setsShEl: for arg in argsShEl: attributeName = limitStateLabel + 'Sect1' field = Fields.getScalarFieldFromControlVar( attributeName, arg, st, None, 1.0) capt = capTexts[limitStateLabel] + ', ' + capTexts[ arg] + '. ' + st.name.capitalize() + ', ' + st.sectDescr[0] grFileNm = pathGr + st.name + arg + 'Sect1' field.display(displaySettings=dfDisp, caption=capt, fileName=grFileNm + '.jpg') insertGrInTex(texFile=report, grFileNm=grFileNm, grWdt=grWdt, capText=capt) attributeName = limitStateLabel + 'Sect2' field = Fields.getScalarFieldFromControlVar( attributeName, arg, st, None, 1.0) capt = capTexts[limitStateLabel] + ', ' + capTexts[ arg] + '. ' + st.name.capitalize() + ', ' + st.sectDescr[1] grFileNm = pathGr + st.name + arg + 'Sect2' field.display(displaySettings=dfDisp, caption=capt, fileName=grFileNm + '.jpg') insertGrInTex(texFile=report, grFileNm=grFileNm, grWdt=grWdt, capText=capt) for stV in setsBmElView: for argS in argsBmElScale: diagram = cvd.ControlVarDiagram(scaleFactor=argS[1], fUnitConv=1, sets=[stV[0].elSet], attributeName=limitStateLabel, component=argS[0]) diagram.addDiagram() dfDisp.cameraParameters = vtk_graphic_base.CameraParameters(stV[1]) dfDisp.setupGrid(stV[0].elSet) dfDisp.defineMeshScene(None) dfDisp.appendDiagram(diagram) capt = capTexts[limitStateLabel] + ', ' + capTexts[ argS[0]] + '. ' + stV[0].genDescr.capitalize( ) + ', ' + stV[0].sectDescr[0] grFileNm = pathGr + stV[0].elSet.name + argS[0] dfDisp.displayScene(caption=capt, fileName=grFileNm + '.jpg') insertGrInTex(texFile=report, grFileNm=grFileNm, grWdt=grWdt, capText=capt) report.close() return
def displayEigenvectors(self, mode= 1, setToDisplay=None, caption= None, fileName=None,defFScale=0.0): '''Displays the computed eigenvectors on the set argument. :param setToDisplay: set of elements to be displayed (defaults to total set) :param mode: mode to which the eigenvectors belong. :param caption: text to display in the graphic. Defaults to ` None` in this case the text is the load case description and the units of the loads. :param fileName: full name of the graphic file to generate. Defaults to ` None`, in this case it returns a console output graphic., :param defFScale: factor to apply to current displacement of nodes so that the display position of each node equals to the initial position plus its displacement multiplied by this factor. (Defaults to 0.0, i.e. display of initial/undeformed shape) ''' if(setToDisplay==None): setToDisplay= self.modelSpace.getTotalSet() preprocessor= self.modelSpace.preprocessor domain= preprocessor.getDomain numModes= domain.numModes # number of computed modes. if(mode<=numModes): norm= preprocessor.getDomain.getMesh.normalizeEigenvectors(mode) #auto-scale LrefModSize=setToDisplay.getBnd(1.0).diagonal.getModulus() #representative length of set size (to autoscale) maxAbs= 0.0 dispPairs= list() rotPairs= list() threshold= LrefModSize/1000.0 for n in setToDisplay.nodes: disp3d= n.getEigenvectorDisp3dComponents(mode) rot3d= n.getEigenvectorRot3dComponents(mode) modDisp3d= disp3d.getModulus() if(modDisp3d>threshold): p=n.getCurrentPos3d(defFScale) dispPairs.append(([p.x,p.y,p.z],[disp3d.x,disp3d.y,disp3d.z])) modRot3d= rot3d.getModulus() if(modRot3d>threshold): p=n.getCurrentPos3d(defFScale) rotPairs.append(([p.x,p.y,p.z],[rot3d.x,rot3d.y,rot3d.z])) modR= max(modDisp3d,modRot3d) if(modR>maxAbs): maxAbs=modR scaleFactor= self.outputStyle.eigenvectorsScaleFactor if(maxAbs > 0): scaleFactor*=0.15*LrefModSize/(maxAbs) # if(not caption): caption= 'Mode '+ str(mode) + ' eigenvectors' + ' '+setToDisplay.description vFieldD= vf.VectorField(name='Deigenvectors',fUnitConv=1.0,scaleFactor=scaleFactor,showPushing= True,symType=vtk.vtkArrowSource()) #Force vFieldR= vf.VectorField(name='Reigenvectors',fUnitConv=1.0,scaleFactor=scaleFactor,showPushing= True,symType=vtk.vtkArrowSource()) vFieldD.populateFromPairList(dispPairs) vFieldR.populateFromPairList(rotPairs) displaySettings= vtk_FE_graphic.DisplaySettingsFE() displaySettings.cameraParameters= self.getCameraParameters() displaySettings.setupGrid(setToDisplay) displaySettings.defineMeshScene(None,defFScale,color=setToDisplay.color) if(len(dispPairs)>0): vFieldD.addToDisplay(displaySettings) if(len(rotPairs)>0): vFieldR.addToDisplay(displaySettings,'V') displaySettings.displayScene(caption,fileName) else: lmsg.error('mode: '+str(mode)+' out of range (1,'+str(numModes)+')')