Ejemplo n.º 1
0
 def __init__(self, loadCaseName, loadCaseDescr, loadCaseExpr,
              setsToDispLoads, setsToDispDspRot, setsToDispIntForc):
     self.loadCaseName = loadCaseName
     self.loadCaseDescr = loadCaseDescr
     self.loadCaseExpr = loadCaseExpr
     self.setsToDispLoads = setsToDispLoads
     self.setsToDispBeamLoads = []
     self.compElLoad = 'transComponent'
     self.unitsScaleLoads = 1.0
     self.unitsLoads = 'units:[m,kN]'
     self.vectorScaleLoads = 1.0
     self.vectorScalePointLoads = 1.0
     self.multByElemAreaLoads = False
     self.listDspRot = ['uX', 'uY', 'uZ']
     self.setsToDispDspRot = setsToDispDspRot
     self.unitsScaleDispl = 1.0
     self.unitsDispl = '[m]'
     self.listIntForc = ['N1', 'N2', 'M1', 'M2', 'Q1', 'Q2']
     self.setsToDispIntForc = setsToDispIntForc
     self.listBeamIntForc = ['N', 'My', 'Mz', 'Qy', 'Qz', 'T']
     self.setsToDispBeamIntForc = []
     self.scaleDispBeamIntForc = (1.0, 1.0, 1.0)
     self.unitsScaleForc = 1.0
     self.unitsForc = '[kN/m]'
     self.unitsScaleMom = 1.0
     self.unitsMom = '[kN.m/m]'
     self.cameraParameters = vtk_graphic_base.CameraParameters('XYZPos')
     self.cameraParametersBeams = vtk_graphic_base.CameraParameters(
         'XYZPos')
Ejemplo n.º 2
0
 def __init__(self,setsToDispLoads= None, setsToDispDspRot= None ,setsToDispIntForc= None):
     super(RecordDisp,self).__init__()
     if(setsToDispLoads):
         self.setsToDispLoads= setsToDispLoads
     else:
         self.setsToDispLoads= list()
     if(setsToDispDspRot):
         self.setsToDispDspRot= setsToDispDspRot
     else:
         self.setsToDispDspRot= list()
     if(setsToDispIntForc):
         self.setsToDispIntForc= setsToDispIntForc
     else:
         self.setsToDispIntForc= list()
     self.setsToDispBeamLoads= list()
     self.compElLoad='transComponent'
     self.multByElemAreaLoads=False
     self.listDspRot=['uX', 'uY', 'uZ']
     self.setsToDispDspRot=setsToDispDspRot
     self.listIntForc=['N1', 'N2', 'M1', 'M2', 'Q1', 'Q2']
     self.setsToDispIntForc= setsToDispIntForc
     self.listBeamIntForc=['N', 'My', 'Mz', 'Qy', 'Qz','T']
     self.setsToDispBeamIntForc=[]
     self.setsToDispReactions=[]
     self.setsToDispEigenvectors=[]
     self.cameraParameters= vtk_graphic_base.CameraParameters('XYZPos')
     self.cameraParametersBeams= vtk_graphic_base.CameraParameters('XYZPos')
Ejemplo n.º 3
0
 def getDefaultCameraParameters(self):
     '''Return the default camera parameters.'''
     if (self.modelSpace.getSpaceDimension() == 3):  # 3D problem
         return vtk_graphic_base.CameraParameters('XYZPos')
     else:  # 2D or 1D problem
         retval = vtk_graphic_base.CameraParameters('Custom')
         retval.viewUpVc = [0, 1, 0]  #[0,0,1]
         retval.posCVc = [0, 0, 100]  #[0,-100,0]
         return retval
Ejemplo n.º 4
0
def display_axes(vectorField,
                 preprocessor,
                 setToDisplay=None,
                 vectorScale=1.0,
                 viewDef=vtk_graphic_base.CameraParameters("XYZPos", 1.0),
                 caption='',
                 fileName=None,
                 defFScale=0.0):
    '''vector field display of the loads applied to the chosen set of elements in the load case passed as parameter

    :param vectorField: function that generates the vector field.
    :param setToDisplay: set of elements to be displayed (defaults to total set)
    :param vectorScale: factor to apply to the vectors length in the 
           representation.
    :param viewDef: camera parameters.
    :param fileName: full name of the graphic file to generate. Defaults to 
           `None`, in this case it returns a console output graphic.
    :param caption: text to display in the 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)
    '''
    defDisplay = vtk_FE_graphic.RecordDefDisplayEF()
    defDisplay.setupGrid(setToDisplay)
    defDisplay.cameraParameters = viewDef
    defDisplay.defineMeshScene(None, defFScale)
    vectorField.addToDisplay(defDisplay)
    defDisplay.displayScene(caption, fileName)
    return defDisplay
Ejemplo n.º 5
0
  def displayLocalAxes(self,setToDisplay=None,vectorScale=1.0,viewDef= vtk_graphic_base.CameraParameters('XYZPos'), caption= '',fileName=None,defFScale=0.0):
    '''vector field display of the loads applied to the chosen set of elements in the load case passed as parameter
    
    :param setToDisplay:   set of elements to be displayed (defaults to total set)
    :param vectorScale:    factor to apply to the vectors length in the representation
    :param viewDef:       parameters that define the view to use
           predefined view names: 'XYZPos','XNeg','XPos','YNeg','YPos',
           'ZNeg','ZPos'
    :param fileName:       full name of the graphic file to generate. Defaults to `None`, in this case it returns a console output graphic.
    :param caption:        text to display in the 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.getPreprocessor().getSets.getSet('total')
      setToDisplay.fillDownwards()
      lmsg.warning('set to display not defined; using total set.')

    defDisplay= vtk_FE_graphic.RecordDefDisplayEF()
    defDisplay.setupGrid(setToDisplay)
    if setToDisplay.color.Norm()==0:
      setToDisplay.color=xc.Vector([rd.random(),rd.random(),rd.random()])
    vField=lavf.LocalAxesVectorField(setToDisplay.name+'_localAxes',vectorScale)
    vField.dumpVectors(setToDisplay)
    defDisplay.cameraParameters= viewDef
    defDisplay.defineMeshScene(None,defFScale,color=setToDisplay.color) 
    vField.addToDisplay(defDisplay)
    defDisplay.displayScene(caption,fileName)
    return defDisplay
Ejemplo n.º 6
0
def display_local_axes(prep,
                       setToDisplay=None,
                       vectorScale=1.0,
                       viewDef=vtk_graphic_base.CameraParameters(
                           "XYZPos", 1.0),
                       caption='',
                       fileName=None,
                       defFScale=0.0):
    '''vector field display of the loads applied to the chosen set of elements in the load case passed as parameter
    
    :param setToDisplay: set of elements to be displayed (defaults to total set)
    :param vectorScale: factor to apply to the vectors length in the 
           representation.
    :param viewDef: camera parameters.
    :param fileName: full name of the graphic file to generate. 
           Defaults to `None`, in this case it returns a console output graphic.
    :param caption: text to display in the 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)
    '''
    setToDisplay = checkSetToDisp(prep, setToDisplay)
    vField = lavf.LocalAxesVectorField(setToDisplay.name + '_localAxes',
                                       vectorScale)
    vField.dumpVectors(setToDisplay)
    return display_axes(vField, prep, setToDisplay, vectorScale, viewDef,
                        caption, fileName, defFScale)
Ejemplo n.º 7
0
def display_strong_weak_axis(preprocessor,
                             setToDisplay=None,
                             vectorScale=1.0,
                             viewDef=vtk_graphic_base.CameraParameters(
                                 "XYZPos", 1.0),
                             caption='',
                             fileName=None,
                             defFScale=0.0):
    '''vector field display of the loads applied to the chosen set of elements 
       in the load case passed as parameter
    
    :param setToDisplay: set of elements to be displayed (defaults to total set)
    :param vectorScale: factor to apply to the vectors length in the 
           representation.
    :param viewDef: camera parameters.
    :param fileName: full name of the graphic file to generate. Defaults to 
           `None`, in this case it returns a console output graphic.
    :param caption: text to display in the 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 = preprocessor.getSets.getSet('total')
        setToDisplay.fillDownwards()
        lmsg.warning('set to display not defined; using total set.')
    vField = lavf.StrongWeakAxisVectorField(
        setToDisplay.name + '_strongWeakAxis', vectorScale)
    vField.dumpVectors(setToDisplay)
    return display_axes(vField, preprocessor, setToDisplay, vectorScale,
                        viewDef, caption, fileName, defFScale)
Ejemplo n.º 8
0
    def displayEigenvectors(
            self,
            mode=1,
            setToDisplay=None,
            fConvUnits=1.0,
            scaleFactor=1.0,
            viewDef=vtk_graphic_base.CameraParameters('XYZPos'),
            fileName=None,
            defFScale=0.0):
        self.checkSetToDisp(setToDisplay)
        preprocessor = setToDisplay.getPreprocessor
        #auto-scale
        LrefModSize = self.xcSet.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 self.xcSet.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
        if maxAbs > 0:
            scaleFactor *= 0.15 * LrefModSize / (maxAbs * fConvUnits)
        #
        caption = 'Mode ' + str(
            mode) + ' eigenvectors' + ' ' + self.xcSet.description
        vFieldD = vf.VectorField(name='Deigenvectors',
                                 fUnitConv=fConvUnits,
                                 scaleFactor=scaleFactor,
                                 showPushing=True,
                                 symType=vtk.vtkArrowSource())  #Force
        vFieldR = vf.VectorField(name='Reigenvectors',
                                 fUnitConv=fConvUnits,
                                 scaleFactor=scaleFactor,
                                 showPushing=True,
                                 symType=vtk.vtkArrowSource())
        vFieldD.populateFromPairList(dispPairs)
        vFieldR.populateFromPairList(rotPairs)

        defDisplay = self.getDisplay(viewDef)
        defDisplay.setupGrid(self.xcSet)
        defDisplay.defineMeshScene(None, defFScale, color=self.xcSet.color)
        if (len(dispPairs) > 0):
            vFieldD.addToDisplay(defDisplay)
        if (len(rotPairs) > 0):
            vFieldR.addToDisplay(defDisplay, 'V')
        defDisplay.displayScene(caption, fileName)
Ejemplo n.º 9
0
    def displayIntForc(self,
                       itemToDisp='',
                       setToDisplay=None,
                       fConvUnits=1.0,
                       unitDescription='',
                       viewDef=vtk_graphic_base.CameraParameters('XYZPos'),
                       fileName=None,
                       defFScale=0.0):
        '''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 fConvUnits:   factor of conversion to be applied to the results 
             (defalts to 1)
        :param unitDescription: string like '[kN/m] or [kN m/m]'
        :param viewDef:  camera parameters.
        :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):
            self.xcSet = setToDisplay
        else:
            lmsg.warning(
                'QuickGraphics::displayIntForc; set to display not defined; using previously defined set (total if None).'
            )
        vCompDisp = self.getIntForceComponentFromName(itemToDisp)
        elSet = self.xcSet.getElements.pickElemsOfDimension(2)
        if (len(elSet) > 0):
            propName = 'propToDisp_' + str(itemToDisp)
            for e in elSet:
                if (e.getDimension == 2):
                    e.getResistingForce()
                    mat = e.getPhysicalProperties.getVectorMaterials
                    e.setProp(propName,
                              mat.getMeanGeneralizedStressByName(vCompDisp))
                else:
                    lmsg.warning(
                        'QuickGraphics::displayIntForc; not a 2D element; ignored.'
                    )
            field = Fields.ExtrapolatedProperty(propName,
                                                "getProp",
                                                self.xcSet,
                                                fUnitConv=fConvUnits)
            defDisplay = self.getDisplay(viewDef)
            field.display(defDisplay=defDisplay,
                          fName=fileName,
                          caption=self.loadCaseName + ' ' + itemToDisp + ' ' +
                          unitDescription + ' ' + self.xcSet.description,
                          defFScale=defFScale)
Ejemplo n.º 10
0
    def displayReactions(self,
                         setToDisplay=None,
                         fConvUnits=1.0,
                         scaleFactor=1.0,
                         unitDescription='',
                         viewDef=vtk_graphic_base.CameraParameters('XYZPos'),
                         fileName=None,
                         defFScale=0.0):
        self.checkSetToDisp(setToDisplay)
        preprocessor = setToDisplay.getPreprocessor
        preprocessor.getNodeHandler.calculateNodalReactions(True, 1e-7)
        #auto-scale
        LrefModSize = self.xcSet.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 self.xcSet.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
        if (maxAbs > 0):
            scaleFactor *= 0.15 * LrefModSize / (maxAbs * fConvUnits)
        #
        caption = self.loadCaseName + ' Reactions' + ' ' + unitDescription + ' ' + self.xcSet.description
        vFieldF = vf.VectorField(name='Freact',
                                 fUnitConv=fConvUnits,
                                 scaleFactor=scaleFactor,
                                 showPushing=True,
                                 symType=vtk.vtkArrowSource())  # Force
        vFieldM = vf.VectorField(name='Mreact',
                                 fUnitConv=fConvUnits,
                                 scaleFactor=scaleFactor,
                                 showPushing=True,
                                 symType=vtk.vtkArrowSource())  # Moment
        vFieldF.populateFromPairList(forcePairs)
        vFieldM.populateFromPairList(momentPairs)

        defDisplay = self.getDisplay(viewDef)
        defDisplay.setupGrid(self.xcSet)
        defDisplay.defineMeshScene(None, defFScale, color=self.xcSet.color)
        if (len(forcePairs) > 0):
            vFieldF.addToDisplay(defDisplay)
        if (len(momentPairs) > 0):
            vFieldM.addToDisplay(defDisplay, 'V')
        defDisplay.displayScene(caption, fileName)
Ejemplo n.º 11
0
    def displayDispRot(self,
                       itemToDisp='',
                       setToDisplay=None,
                       fConvUnits=1.0,
                       unitDescription='',
                       viewDef=vtk_graphic_base.CameraParameters(
                           'XYZPos', 1.0),
                       fileName=None,
                       defFScale=0.0,
                       rgMinMax=None):
        '''displays the component of the displacement or rotations in the 
        set of entities.

        :param itemToDisp: component of the displacement ('uX', 'uY' or 'uZ') 
                    or the rotation ('rotX', rotY', 'rotZ') to be depicted 
        :param setToDisplay:   set of entities to be represented (defaults to all 
                    entities)
        :param fConvUnits: factor of conversion to be applied to the results 
                    (defaults to 1)
        :param unitDescription: string describing units like '[mm] or [cm]'
        :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):
            self.xcSet = setToDisplay
        else:
            lmsg.warning(
                'QuickGraphics::displayDispRot; set to display not defined; using previously defined set (total if None).'
            )
        vCompDisp = self.getDispComponentFromName(itemToDisp)
        nodSet = self.xcSet.getNodes
        for n in nodSet:
            n.setProp('propToDisp', n.getDisp[vCompDisp])
        field = Fields.ScalarField(name='propToDisp',
                                   functionName="getProp",
                                   component=None,
                                   fUnitConv=fConvUnits,
                                   rgMinMax=rgMinMax)
        defDisplay = self.getDisplay(viewDef)
        defDisplay.displayMesh(xcSets=self.xcSet,
                               field=field,
                               diagrams=None,
                               fName=fileName,
                               caption=self.loadCaseName + ' ' + itemToDisp +
                               ' ' + unitDescription + ' ' +
                               self.xcSet.description,
                               defFScale=defFScale)
Ejemplo n.º 12
0
    def getDisplay(self,
                   wmDef=vtk_graphic_base.CameraParameters('XYZPos', 1.0)):
        '''Returns a suitable display to show the graphics.

        :param vwDef:  camera parameters.
        '''
        defDisplay = vtk_FE_graphic.RecordDefDisplayEF()
        defDisplay.cameraParameters = wmDef
        return defDisplay
Ejemplo n.º 13
0
def displayFieldDirs1and2Base(
        limitStateLabel,
        argument,
        elementSet,
        genDescr,
        sectDescr,
        component,
        fUnitConv,
        captionTexts,
        fileName,
        defFScale=0.0,
        viewDef=vtk_graphic_base.CameraParameters('XYZPos'),
        rgMinMax=None):
    '''Display a field defined over bi-dimensional elements in its two directions.

  :param limitStateLabel: label that identifies the limit state.
  :param argument: name of the control var to represent.
  :param xcSet: represent the field over those elements.
  :param genDescr: text to identify the set (i.e 'deck' or 'west wall').
  :param sectDescr: text list to identify each direction (as ['vertical reinforcement', 'horizontal reinforcement']).
  :param component: component of the control var to represent.
  :param fUnitConv: unit conversion factor (i.e N->kN => fUnitConv= 1e-3).
  :param captionTexts: dictionary of caption texts. 
  :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 viewDef: camera parameters (position, orientation,...)
  :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)
  '''
    defDisplay = vtk_FE_graphic.RecordDefDisplayEF()
    defDisplay.cameraParameters = viewDef
    attributeName = limitStateLabel + 'Sect1'  #Normal stresses limit state direction 1.
    field = Fields.getScalarFieldFromControlVar(attributeName, argument,
                                                elementSet, component,
                                                fUnitConv, rgMinMax)
    captionBaseText = captionTexts[limitStateLabel] + ', ' + captionTexts[
        argument] + '. ' + genDescr.capitalize()
    field.display(defDisplay,
                  caption=captionBaseText + ', ' + sectDescr[0],
                  fileName=fileName,
                  defFScale=defFScale)

    attributeName = limitStateLabel + 'Sect2'  #Normal stresses limit state direction 2
    field = Fields.getScalarFieldFromControlVar(attributeName, argument,
                                                elementSet, component,
                                                fUnitConv, rgMinMax)
    field.display(defDisplay,
                  caption=captionBaseText + ', ' + sectDescr[1],
                  fileName=fileName,
                  defFScale=defFScale)
Ejemplo n.º 14
0
 def __init__(self, loadCaseName, loadCaseDescr, loadCaseExpr,
              setsToDispLoads, setsToDispDspRot, setsToDispIntForc):
     super(RecordLoadCaseDisp, self).__init__()
     self.loadCaseName = loadCaseName
     self.loadCaseDescr = loadCaseDescr
     self.loadCaseExpr = loadCaseExpr
     self.setsToDispLoads = setsToDispLoads
     self.setsToDispBeamLoads = []
     self.compElLoad = 'transComponent'
     self.multByElemAreaLoads = False
     self.listDspRot = ['uX', 'uY', 'uZ']
     self.setsToDispDspRot = setsToDispDspRot
     self.listIntForc = ['N1', 'N2', 'M1', 'M2', 'Q1', 'Q2']
     self.setsToDispIntForc = setsToDispIntForc
     self.listBeamIntForc = ['N', 'My', 'Mz', 'Qy', 'Qz', 'T']
     self.setsToDispBeamIntForc = []
     self.cameraParameters = vtk_graphic_base.CameraParameters('XYZPos')
     self.cameraParametersBeams = vtk_graphic_base.CameraParameters(
         'XYZPos')
Ejemplo n.º 15
0
def display_beam_result(attributeName,
                        itemToDisp,
                        beamSetDispRes,
                        setToDisplay=None,
                        fConvUnits=1.0,
                        scaleFactor=1.0,
                        caption=None,
                        viewDef=vtk_graphic_base.CameraParameters('XYZPos'),
                        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 fConvUnits:   factor of conversion to be applied to the results 
           (defaults to 1)
    :param scaleFactor:  factor of scale to apply to the auto-scaled display
           (defaults to 1)
    :param caption:      caption to display
           (defaults to 'attributeName + itemToDisp')
    :param viewDef:      instance of class CameraParameters
           (defaults to 'XYZPos')
    :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
    LrefModSize = setToDisplay.getBnd(1.0).diagonal.getModulo(
    )  #representative length of set size (to autoscale)
    lstArgVal = [
        e.getProp(attributeName + 'Sect1')(itemToDisp)
        for e in beamSetDispRes.getElements
    ]
    maxAbs = max(abs(max(lstArgVal)), abs(min(lstArgVal)))
    if maxAbs > 0:
        scaleFactor *= 0.15 * LrefModSize / (maxAbs * fConvUnits)
    if not setToDisplay:
        setToDisplay = beamSetDispRes
    if not caption:
        if hasattr(beamSetDispRes, 'description'):
            descrSet = beamSetDispRes.description.capitalize()
        else:
            descrSet = ''
        caption = attributeName + ', ' + itemToDisp + '. ' + descrSet
    display_diagram(scaleFactor, fConvUnits, beamSetDispRes, setToDisplay,
                    attributeName, itemToDisp, caption, viewDef, defFScale,
                    fileName)
Ejemplo n.º 16
0
    def displayIntForcDiag(self,
                           itemToDisp='',
                           setToDisplay=None,
                           fConvUnits=1.0,
                           scaleFactor=1.0,
                           unitDescription='',
                           viewDef=vtk_graphic_base.CameraParameters('XYZPos'),
                           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 fConvUnits:   factor of conversion to be applied to the results 
            (defaults to 1)
        :param scaleFactor:  factor of scale to apply to the diagram display
        :param unitDescription: string like '[kN/m] or [kN m/m]'
        :param vwDef:  camera parameters.
        :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)
        '''
        self.checkSetToDisp(setToDisplay)
        #auto-scale parameters
        LrefModSize = self.xcSet.getBnd(1.0).diagonal.getModulus(
        )  #representative length of set size (to autoscale)
        diagAux = cvd.ControlVarDiagram(scaleFactor=scaleFactor,
                                        fUnitConv=fConvUnits,
                                        sets=[self.xcSet],
                                        attributeName="intForce",
                                        component=itemToDisp)
        maxAbs = diagAux.getMaxAbsComp()
        if maxAbs > 0:
            scaleFactor *= 0.15 * LrefModSize / (maxAbs * fConvUnits)
        #
        caption = self.loadCaseName + ' ' + itemToDisp + ' ' + unitDescription + ' ' + self.xcSet.description
        display_diagram(scaleFactor=scaleFactor,
                        fConvUnits=fConvUnits,
                        setToDispRes=self.xcSet,
                        setDisp=self.xcSet,
                        attributeName="intForce",
                        component=itemToDisp,
                        caption=caption,
                        viewDef=viewDef,
                        defFScale=defFScale,
                        fileName=fileName)
Ejemplo n.º 17
0
def display_load(preprocessor,
                 setToDisplay=None,
                 loadCaseNm='',
                 unitsScale=1.0,
                 vectorScale=1.0,
                 multByElemArea=False,
                 viewDef=vtk_graphic_base.CameraParameters("XYZPos", 1.0),
                 caption='',
                 fileName=None,
                 defFScale=0.0):
    '''vector field display of the loads applied to the chosen set of elements in the load case passed as parameter
    
    :param setToDisplay: set of elements to be displayed (defaults to total set)
    :param loadCaseNm: name of the load case to be depicted
    :param unitsScale: factor to apply to the results if we want to change the 
           unit system.
    :param vectorScale: factor to apply to the vectors length in the 
           representation
    :param multByElemArea: boolean value that must be `True` if we want to 
           represent the total load on each element (=load multiplied by 
           element area) and `False` if we are going to depict the value of
            the uniform load per unit area
    :param viewDef: camera parameters.
    :param fileName: full name of the graphic file to generate. Defaults to 
           ` None`, in this case it returns a console output graphic.
    :param caption: text to display in the 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 = preprocessor.getSets.getSet('total')
        setToDisplay.fillDownwards()
        lmsg.warning('set to display not defined; using total set.')

    LrefModSize = setToDisplay.getBnd(1.0).diagonal.getModulo(
    )  #representative length of set size (to auto-scale)
    vectorScale *= LrefModSize / 10.
    if setToDisplay.color.Norm() == 0:
        setToDisplay.color = xc.Vector([rd.random(), rd.random(), rd.random()])
    defDisplay = vtk_FE_graphic.RecordDefDisplayEF()
    defDisplay.setupGrid(setToDisplay)
    vField = lvf.LoadVectorField(loadCaseNm, unitsScale, vectorScale)
    vField.multiplyByElementArea = multByElemArea
    vField.dumpLoads(preprocessor, defFScale)
    defDisplay.cameraParameters = viewDef
    defDisplay.defineMeshScene(None, defFScale, color=setToDisplay.color)
    vField.addToDisplay(defDisplay)
    defDisplay.displayScene(caption, fileName)
    return defDisplay
Ejemplo n.º 18
0
    def displayNodeValueDiagram(
            self,
            itemToDisp='',
            setToDisplay=None,
            fConvUnits=1.0,
            scaleFactor=1.0,
            unitDescription='',
            viewDef=vtk_graphic_base.CameraParameters('XYZPos'),
            fileName=None,
            defFScale=0.0):
        '''displays the a displacement (uX,uY,...) or a property defined in nodes 
        as a diagram over lines (i.e. appropiated for beam elements).

        :param itemToDisp:   item to display.
        :param setToDisplay: set of entities (elements of type beam) to be 
               represented
        :param fConvUnits:   factor of conversion to be applied to the results 
               (defalts to 1)
        :param scaleFactor:  factor of scale to apply to the diagram display of
        :param unitDescription: string like '[m]' or '[rad]' or '[m/s2]'
        :param viewDef: camera parameters.
        :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):
            self.xcSet = setToDisplay
            if self.xcSet.color.Norm() == 0:
                self.xcSet.color = xc.Vector(
                    [rd.random(), rd.random(),
                     rd.random()])
        else:
            lmsg.warning(
                'QuickGraphics::displayNodeValueDiagram; set to display not defined; using previously defined set (total if None).'
            )
        diagram = npd.NodePropertyDiagram(scaleFactor=scaleFactor,
                                          fUnitConv=fConvUnits,
                                          sets=[self.xcSet],
                                          attributeName=itemToDisp)
        diagram.addDiagram()
        defDisplay = self.getDisplay(viewDef)
        defDisplay.setupGrid(self.xcSet)
        defDisplay.defineMeshScene(None, defFScale, color=self.xcSet.color)
        defDisplay.appendDiagram(diagram)  #Append diagram to the scene.

        caption = self.loadCaseName + ' ' + itemToDisp + ' ' + unitDescription + ' ' + self.xcSet.description
        defDisplay.displayScene(caption=caption, fName=fileName)
Ejemplo n.º 19
0
    def FEmeshGraphic(self,xcSet,caption= '',cameraParameters= vtk_graphic_base.CameraParameters('XYZPos'),defFScale=0.0):
        ''' Graphic of the FE mesh

        :param xcSet:   XC set of elements to be displayed
        :param caption: text to write in the graphic
        :param cameraParameters: camera parameters (position, orientation,...).
        :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)
        '''
        self.cameraParameters= cameraParameters
        self.setupGrid(xcSet)
        self.displayGrid(caption)
Ejemplo n.º 20
0
    def FEmeshGraphic(self,setToDisplay,caption= '',cameraParameters= vtk_graphic_base.CameraParameters('XYZPos'),defFScale=0.0):
        ''' Graphic of the FE mesh

        :param setToDisplay:   XC set of elements to be displayed
        :param caption: text to write in the graphic
        :param cameraParameters: camera parameters (position, orientation,...).
        :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)
        '''
        lmsg.warning('FEmeshGraphic DEPRECATED use displayFEMesh.')
        self.cameraParameters= cameraParameters
        self.displayFEMesh(setToDisplay,caption,defFScale)
Ejemplo n.º 21
0
    def displayLocalAxes(self,xcSet,caption= '',cameraParameters= vtk_graphic_base.CameraParameters('XYZPos'), vectorScale=1.0):
        '''vector field display of the loads applied to the chosen set of elements in the load case passed as parameter

        :param xcSet:   set of elements to be displayed (defaults to total set)
        :param caption:        text to display in the graphic 
        :param cameraParameters: camera parameters (position, orientation,...).
        :param vectorScale:    factor to apply to the vectors length in the representation
        '''
        self.cameraParameters= cameraParameters
        self.setupGrid(xcSet)
        vField=lavf.LocalAxesVectorField(xcSet.name+'_localAxes',vectorScale)
        vField.dumpVectors(xcSet)
        self.cameraParameters= cameraParameters
        self.defineMeshScene(None) 
        vField.addToDisplay(self)
        self.displayScene(caption)
Ejemplo n.º 22
0
 def __init__(self,pLabel,limitStateLabel,figDescr,reinfDescr=None,units=None,sz= "90mm"):
   ''' Figure base constructor.
   pLabel: part label; something like 'wall' or '2ndFloorDeck'
   limitStateLabel; limit state check label; Something like "Fatigue" or "CrackControl"
   figDescr: figure description; text to insert as caption in the figure file and int the LaTeX file.
   units: units displayed; something like '[MPa]' or 'radians'...
   reinfDescr: reinforcement description; sSomething like "horizontal reinforcement."
   sz: LaTeX size for the figure.
   '''
   self.partLabel= pLabel #Something like 'wall' or '2ndFloorDeck'
   self.limitStateLabel= limitStateLabel #Something like "Fatigue" or "CrackControl"
   self.attributeName= ''
   self.figDescription= figDescr #Text to insert as caption in the LaTeX file.
   self.unitsLabel= units # Somethin like '[MPa]' or 'radians'...
   self.reinforcementDescription= reinfDescr #Something like "horizontal reinforcement."
   self.figSize= sz #LaTeX size for the figure.
   self.cameraParameters= vtk_graphic_base.CameraParameters('XYZPos')
Ejemplo n.º 23
0
  def displayMesh(self,partToDisplay,caption= '',viewDef= vtk_graphic_base.CameraParameters('XYZPos'),defFScale=0.0):
    '''return a graphical representation of the mesh

    :param partToDisplay: XC set of elements to be displayed
    :param caption:       text to write in the graphic
    :param viewDef:       parameters that define the view to use
           predefined view names: 'XYZPos','XNeg','XPos','YNeg','YPos',
           'ZNeg','ZPos'
    :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)
    '''
    defDisplay= vtk_FE_graphic.RecordDefDisplayEF()
    defDisplay.FEmeshGraphic(partToDisplay,caption,viewDef,defFScale)
    return defDisplay
Ejemplo n.º 24
0
def displayFieldDirs1and2(limitStateLabel,
                          argument,
                          elementSet,
                          component,
                          fUnitConv,
                          captionTexts,
                          fileName,
                          defFScale=0.0,
                          viewDef=vtk_graphic_base.CameraParameters('XYZPos'),
                          rgMinMax=None):
    '''Display a field defined over bi-dimensional elements in its two directions.

  :param limitStateLabel: label that identifies the limit state.
  :param argument: name of the control var to represent.
  :param xcSet: represent the field over those elements with "genDescr" and "sectDescr" attributes.
  :param component: component of the control var to represent.
  :param fUnitConv: unit conversion factor (i.e N->kN => fUnitConv= 1e-3).
  :param captionTexts: dictionary of caption texts. 
  :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 viewDef: camera parameters (position, orientation,...)
  :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)
  
  '''
    #  displayFieldDirs1and2Base(limitStateLabel,argument,elementSet,elementSet.description,elementSet.sectDescr,component,fUnitConv,captionTexts, fileName,defFScale=defFScale )  #21/07/2017 needs revision
    displayFieldDirs1and2Base(limitStateLabel,
                              argument,
                              elementSet,
                              elementSet.description, ['dir. 1', 'dir. 2'],
                              component,
                              fUnitConv,
                              captionTexts,
                              fileName,
                              defFScale=defFScale,
                              viewDef=viewDef,
                              rgMinMax=rgMinMax)
Ejemplo n.º 25
0
def display_load(preprocessor,
                 setToDisplay=None,
                 loadCaseNm='',
                 unitsScale=1.0,
                 vectorScale=1.0,
                 multByElemArea=False,
                 viewDef=vtk_graphic_base.CameraParameters("XYZPos", 1.0),
                 caption='',
                 fileName=None,
                 defFScale=0.0):
    '''vector field display of the loads applied to the chosen set of elements in the load case passed as parameter
    
    :param setToDisplay: set of elements to be displayed (defaults to total set)
    :param loadCaseNm: name of the load case to be depicted
    :param unitsScale: factor to apply to the results if we want to change the 
           unit system.
    :param vectorScale: factor to apply to the vectors length in the 
           representation
    :param multByElemArea: boolean value that must be `True` if we want to 
           represent the total load on each element (=load multiplied by 
           element area) and `False` if we are going to depict the value of
            the uniform load per unit area
    :param viewDef: camera parameters.
    :param fileName: full name of the graphic file to generate. Defaults to 
           ` None`, in this case it returns a console output graphic.
    :param caption: text to display in the 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)
    '''
    setToDisplay = checkSetToDisp(preprocessor, setToDisplay)
    LrefModSize = setToDisplay.getBnd(1.0).diagonal.getModulus(
    )  #representative length of set size (to auto-scale)
    vectorScale *= LrefModSize / 10.
    vField = lvf.LoadVectorField(loadCaseNm, unitsScale, vectorScale)
    vField.multiplyByElementArea = multByElemArea
    display_vector_field(preprocessor, vField, setToDisplay, viewDef, caption,
                         fileName, defFScale)
Ejemplo n.º 26
0
  
  cameraParametersBeams: parameters that define the position and orientation of the
                 camera for beam elements displays (defaults to "XYZPos")
  
'''
G1=graphical_reports.LoadCaseDispParameters(loadCaseName='GselfWeight',loadCaseDescr='G1: self weight',loadCaseExpr='1.0*GselfWeight',setsToDispLoads=[deck,found],setsToDispDspRot=[deck,found],setsToDispIntForc=[])
G1.unitsScaleLoads=1e-3
G1.unitsScaleDispl=1e3
G1.unitsDispl='[mm]'
G1.unitsScaleMom=1e-3
G1.unitsMom='[m.kN]'
G1.unitsScaleForc=1e-3
G1.unitsForc='[kN]'
G1.setsToDispBeamIntForc=[columnZ,beamX,beamY]
G1.listBeamIntForc=['My','Mz','Qy','Qz','N']
G1.cameraParameters= vtk_graphic_base.CameraParameters('XYZPos')
G1.setsToDispBeamLoads=[beamY]
G1.vectorScalePointLoads=0.005
G1.compElLoad='axialComponent'


Q1=graphical_reports.LoadCaseDispParameters(loadCaseName='Qdeck',loadCaseDescr='Q1: uniform load on the deck',loadCaseExpr='1.0*Qdeck',setsToDispLoads=[overallSet],setsToDispDspRot=[overallSet],setsToDispIntForc=[deck,found])
Q1.unitsScaleLoads=1e-3
Q1.unitsScaleDispl=1e3
Q1.unitsDispl='[mm]'
Q1.unitsScaleMom=1e-3
Q1.unitsMom='[m.kN]'
Q1.unitsScaleForc=1e-3
Q1.unitsForc='[kN]'
Q1.setsToDispBeamIntForc=[columnZ,beamX,beamY]
Q1.listBeamIntForc=['My','Mz','Qy','Qz','N']
Ejemplo n.º 27
0
#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)



Ejemplo n.º 28
0
G1 = graphical_reports.LoadCaseDispParameters(loadCaseName='lcase01',
                                              loadCaseDescr='G1: self weight',
                                              loadCaseExpr='1.0*lcase01',
                                              setsToDispLoads=[],
                                              setsToDispDspRot=[beamSet],
                                              setsToDispIntForc=[])
G1.unitsScaleLoads = 1e-3
G1.unitsScaleDispl = 1e3
G1.unitsDispl = '[mm]'
G1.unitsScaleMom = 1e-3
G1.unitsMom = '[m.kN]'
G1.unitsScaleForc = 1e-3
G1.unitsForc = '[kN]'
G1.setsToDispBeamIntForc = [beamSet]
G1.listBeamIntForc = ['My', 'Mz', 'Qy', 'Qz', 'N']
G1.cameraParameters = vtk_graphic_base.CameraParameters('XYZPos')
G1.setsToDispBeamLoads = [beamSet]
G1.vectorScalePointLoads = 0.005
G1.compElLoad = 'axialComponent'

G2 = graphical_reports.LoadCaseDispParameters(loadCaseName='lcase02',
                                              loadCaseDescr='G2: self weight',
                                              loadCaseExpr='1.0*lcase02',
                                              setsToDispLoads=[],
                                              setsToDispDspRot=[beamSet],
                                              setsToDispIntForc=[])
G2.unitsScaleLoads = 1e-3
G2.unitsScaleDispl = 1e3
G2.unitsDispl = '[mm]'
G2.unitsScaleMom = 1e-3
G2.unitsMom = '[m.kN]'
Ejemplo n.º 29
0
diag10.sectionArea= diagArea
diag11= elements.newElement("CorotTruss",xc.ID([11,12]))
diag11.sectionArea= diagArea
diag12= elements.newElement("CorotTruss",xc.ID([10,12]))
diag12.sectionArea= diagArea

diag13= elements.newElement("CorotTruss",xc.ID([1,7]))
diag13.sectionArea= diagArea


# Displaying of the mesh
from postprocess.xcVtk.FE_model import vtk_FE_graphic
from postprocess.xcVtk import vtk_graphic_base
displaySettings= vtk_FE_graphic.DisplaySettingsFE()
totalSet= prep.getSets.getSet('total')
displaySettings.FEmeshGraphic(xcSet=totalSet,caption= 'All elements',cameraParameters= vtk_graphic_base.CameraParameters('XYZPos'))

quit()

# Plotting of CAD entities
# from postprocess.xcVtk.CAD_model import vtk_CAD_graphic
# displaySettings= vtk_CAD_graphic.DisplaySettingsBlockTopo()
# totalSet= prep.getSets.getSet('total')
# displaySettings.displayBlocks(setToDisplay=totalSet,caption= 'Model grid')

# Seed element for struts
seedElemHandler= prep.getElementHandler.seedElemHandler
seedElemHandler.defaultMaterial= "strutMat"
seedElemHandler.dimElem= 3
seedElemHandler.defaultTag= 1 
strutTruss= seedElemHandler.newElement("CorotTruss",xc.ID([0,0]))
Ejemplo n.º 30
0
# -*- coding: utf-8 -*-

from postprocess.reports import graphical_reports as gr
from postprocess.xcVtk import vtk_graphic_base
from postprocess.xcVtk.FE_model import quick_graphics as qg

execfile('./cantilever_mesh_generation.py')

#available components: 'axialComponent', 'transComponent', 'transYComponent',
#                      'transZComponent'

rlcd = gr.getRecordLoadCaseDispFromLoadPattern(lp0)
rlcd.cameraParameters = vtk_graphic_base.CameraParameters('Custom')
rlcd.cameraParameters.viewUpVc = [0, 1, 0]
rlcd.cameraParameters.posCVc = [-100, 100, 100]

loadCasesToDisplay = [rlcd]

#End data

for lc in loadCasesToDisplay:
    for st in lc.setsToDispLoads:
        #        capt=lc.loadCaseDescr + ', ' + st.genDescr + ', '  + lc.unitsLoads
        capt = lc.loadCaseDescr + ', ' + lc.unitsLoads
        qg.displayLoad(preprocessor,
                       setToDisplay=st,
                       loadCaseNm=lc.loadCaseName,
                       unitsScale=lc.unitsScaleLoads,
                       vectorScale=lc.vectorScaleLoads,
                       multByElemArea=lc.multByElemAreaLoads,
                       viewDef=lc.cameraParameters,