Ejemplo n.º 1
0
 def getMaxAbsComp(self,preprocessor):
     '''Return the maximum absolute value of the component.
     It is used for calculating auto-scale parameter
     '''
     maxV=0
     activeLoadPatterns= preprocessor.getDomain.getConstraints.getLoadPatterns
     if(len(activeLoadPatterns)<1):
         lmsg.warning('No active load patterns.')
     for lp in activeLoadPatterns: #Iterate over loaded elements.
         lIter= lp.data().loads.getElementalLoadIter
         eLoad= lIter.next()
         while(eLoad):
             tags= eLoad.elementTags
             for i in range(0,len(tags)):
                 if(self.component=='axialComponent'):
                     vComp= eLoad.axialComponent
                 elif(self.component=='transComponent'):
                     vComp= eLoad.transComponent
                 elif(self.component=='transYComponent'):
                     vComp=eLoad.transYComponent
                 elif(self.component=='transZComponent'):
                     vComp=eLoad.transZComponent
                 else:
                     lmsg.error("LinearLoadDiagram :'"+self.component+"' unknown.")
                 maxV=max(abs(vComp),maxV)
                 eLoad= lIter.next()
     return maxV  
Ejemplo n.º 2
0
    def defElasticShearSection3d(self, preprocessor, material):
        '''elastic section appropiate for 3D beam analysis, including shear 
           deformations

        :param preprocessor: preprocessor object.
        :param material:      material (for which E is the Young's modulus and G() the shear modulus)  
        '''
        if (not self.xc_material):
            materialHandler = preprocessor.getMaterialHandler
            if (materialHandler.materialExists(self.sectionName)):
                lmsg.warning("Section: " + self.sectionName +
                             " already defined.")
                self.xc_material = materialHandler.getMaterial(
                    self.sectionName)
            else:
                self.xc_material = typical_materials.defElasticShearSection3d(
                    preprocessor,
                    self.sectionName,
                    self.A(),
                    material.E,
                    material.G(),
                    self.Iz(),
                    self.Iy(),
                    self.J(),
                    self.alphaY(),
                    linearRho=material.rho * self.A())
        else:
            lmsg.warning('Material: ' + self.sectionName +
                         ' already defined as:' + str(self.xc_material))
        return self.xc_material
Ejemplo n.º 3
0
    def defElasticShearSection2d(self, preprocessor, material, majorAxis=True):
        '''elastic section appropiate for 2D beam analysis, including shear deformations

        :param  preprocessor: preprocessor object.
        :param material: material constitutive model (for which 
                         E is the Young's modulus and G() the shear modulus).
        :param majorAxis: true if bending occurs in the section major axis.
        '''
        if (not self.xc_material):
            materialHandler = preprocessor.getMaterialHandler
            if (materialHandler.materialExists(self.sectionName)):
                lmsg.warning("Section: " + self.sectionName +
                             " already defined.")
                self.xc_material = materialHandler.getMaterial(
                    self.sectionName)
            else:
                I = self.Iz()
                if (not majorAxis):
                    I = self.Iy()
                self.xc_material = typical_materials.defElasticShearSection2d(
                    preprocessor,
                    self.sectionName,
                    self.A(),
                    material.E,
                    material.G(),
                    I,
                    self.alphaY(),
                    linearRho=material.rho * self.A())
        else:
            lmsg.warning('Material: ' + self.sectionName +
                         ' already defined as:' + str(self.xc_material))
        return self.xc_material
Ejemplo n.º 4
0
def getLoadedSides(xcSet):
    ''' Return the sides affected by loads.'''
    retval = dict()
    for s in xcSet.surfaces:
        if (s.hasProp('load_tag')):  # is loaded
            loadTag = s.getProp('load_tag')
            loadDirI = s.getProp('load_dir_i')
            loadDirJ = s.getProp('load_dir_j')
            loadDirK = s.getProp('load_dir_k')
            ## Get the lines pointed by the load direction: loaded sides.
            faceCenter = s.getCentroid()
            sideList = list()
            if (loadTag in retval):
                sideList.extend(retval[loadTag]['sideList'])
            for side in s.getSides:
                sideCenter = side.getCentroid()
                sideDir = sideCenter - faceCenter
                angle = loadDirI.getAngle(sideDir)
                if (abs(angle) < 1e-3):
                    sideList.append(side)
            if (len(sideList) == 0):
                lmsg.warning('side list empty for load tag: ' + str(loadTag))
            retval[loadTag] = {
                'I': loadDirI,
                'J': loadDirJ,
                'K': loadDirK,
                'sideList': sideList
            }
    return retval
Ejemplo n.º 5
0
def defConcrete02(preprocessor, name, epsc0, fpc, fpcu, epscu, ratioSlope, ft,
                  Ets):
    ''''Constructs an uniaxial concrete material with linear tension
    softening. Compressive concrete parameters should be input as negative values.
    The initial slope for this model is (2*fpc/epsc0) 

    :param preprocessor: preprocessor
    :param name:         name identifying the material
    :param epsc0:        concrete strain at maximum strength 
    :param fpc:          concrete compressive strength at 28 days (compression is negative)
    :param fpcu:         concrete crushing strength 
    :param epscu:        concrete strain at crushing strength 
    :param ratioSlope:   ratio between unloading slope at epscu and initial slope 
    :param ft:           tensile strength
    :param Ets:          tension softening stiffness (absolute value) (slope of the linear tension softening branch) 

    '''
    materialHandler = preprocessor.getMaterialHandler
    retval = materialHandler.newMaterial("concrete02_material", name)
    retval.epsc0 = epsc0
    retval.fpc = fpc
    retval.fpcu = fpcu
    retval.epscu = epscu
    retval.ratioSlope = ratioSlope
    retval.ft = ft
    retval.Ets = Ets
    if fpc == fpcu:
        lmsg.warning(
            "concrete02 compressive strength fpc is equal to crushing strength fpcu => the solver can return wrong stresses or have convergence problems "
        )
    return retval
Ejemplo n.º 6
0
 def selectKPoints(self):
     '''Selects the k-points to be used in the model. All the points that
        are closer than the threshold distance are melted into one k-point.
     '''
     points, layers= self.extractPoints()
     if(len(points)>0):
         self.kPoints= [points[0]]
         pointName= layers[0][1]
         layerName= layers[0][0]
         self.labelDict[pointName]= [layerName]
         indexDict= dict()
         indexDict[0]= pointName
         for p, l in zip(points, layers):
             pointName= l[1]
             layerName= l[0]
             indexNearestPoint= self.getIndexNearestPoint(p)
             nearestPoint= self.kPoints[indexNearestPoint]
             dist= cdist([p],[nearestPoint])[0][0]
             if(dist>self.threshold):
                 indexNearestPoint= len(self.kPoints) # The point itself.
                 self.kPoints.append(p)
                 self.labelDict[pointName]= [layerName]
                 indexDict[indexNearestPoint]= pointName
             else:
                 pointName= indexDict[indexNearestPoint]
                 layers= self.labelDict[pointName]
                 if(not layerName in layers):
                     layers.append(layerName)
     else:
         lmsg.warning('No points in DXF file.')
     return indexDict
Ejemplo n.º 7
0
    def defCircularLayers(self,
                          reinforcement,
                          code,
                          diagramName,
                          extRad,
                          anglePairs=None):
        '''
        Definition of the reinforcement layers

        :param reinforcement: XC section reinforcement.
        :param code: identifier for the layer.
        :param diagramName: name of the strain-stress diagram of the steel.
        :param points: end points for each row.
        '''
        if (len(self.rebarRows) > 0):
            if (not anglePairs):
                for rbRow in self.rebarRows:
                    layer = rbRow.defCircularLayer(reinforcement, code,
                                                   diagramName, extRad)
                    self.reinfLayers.append(layer)
            else:
                for rbRow, angles in zip(self.rebarRows, anglePairs):
                    initAngle = anglePairs[0]
                    finalAngle = anglePairs[1]
                    layer = rbRow.defCircularLayer(reinforcement, code,
                                                   diagramName, extRad,
                                                   initAngle, finalAngle)
                    self.reinfLayers.append(layer)
        else:
            lmsg.warning('No longitudinal reinforcement.')
Ejemplo n.º 8
0
  def getElementComponentData(self,elem):
    '''Returns the data to use to represent the diagram over the element
 
       :param elem: element to deal with.
       :param component: component to represent:
    '''
    # default values.
    elemVDir= elem.getJVector3d(True) #initialGeometry= True
    value1= 0.0
    value2= 0.0
    if(self.component == 'N'):
      value1= elem.getN1
      value2= elem.getN2
    elif(self.component == 'Qy'):
      elemVDir= elem.getJVector3d(True) # initialGeometry= True 
      value1= elem.getVy1
      value2= elem.getVy2
    elif(self.component == 'Qz'):
      elemVDir= elem.getKVector3d(True) # initialGeometry= True 
      value1= elem.getVz1
      value2= elem.getVz2
    elif(self.component == 'T'):
      value1= elem.getT1
      value2= elem.getT2
    elif(self.component == 'My'):
      elemVDir= elem.getKVector3d(True) # initialGeometry= True 
      value1= elem.getMy1
      value2= elem.getMy2
    elif(self.component == 'Mz'):
      elemVDir= elem.getJVector3d(True) # initialGeometry= True 
      value1= elem.getMz1
      value2= elem.getMz2
    else:
      lmsg.warning("'component :'"+ self.component+ "' unknown.")
    return [elemVDir,value1,value2]
Ejemplo n.º 9
0
    def exportBlockTopology(self, name):
        retval = bte.BlockData()
        retval.name = name
        retval.dxfFileName = self.dxfFileName

        counter = 0
        if (self.kPoints):
            for p in self.kPoints:
                key = self.kPointsNames[counter]
                retval.appendPoint(id=counter,
                                   x=p[0],
                                   y=p[1],
                                   z=p[2],
                                   labels=self.labelDict[key])
                counter += 1

            counter = 0
            for key in self.lines:
                line = self.lines[key]
                block = bte.BlockRecord(counter, 'line', line,
                                        self.labelDict[key])
                retval.appendBlock(block)
                counter += 1

            for name in self.layersToImport:
                fg = self.facesByLayer[name]
                for key in fg:
                    face = fg[key]
                    block = bte.BlockRecord(counter, 'face', face,
                                            self.labelDict[key])
                    retval.appendBlock(block)
                    counter += 1
        else:
            lmsg.warning('Nothing to export.')
        return retval
Ejemplo n.º 10
0
def gdls_elasticidad2D(nodes):
    '''Defines the dimension of the space: nodes by two coordinates (x,y) and two DOF for each node (Ux,Uy)

    :param nodes: nodes handler
    '''
    lmsg.warning('gdls_elasticidad2D DEPRECATED; use SolidMechanics2D.')
    return SolidMechanics2D(nodes)
Ejemplo n.º 11
0
 def getStressComponentFromName(self, compName):
     '''Return the component index from the
        stress name.'''
     lmsg.warning('getStressComponentFromName not tested yet.')
     retval = 0
     self.N = 0  # generalized strains; axial strain,
     self.Mz = 1  # curvature about z-axis,
     self.Vy = 2  # shear along y-axis.
     self.My = 3  # curvature about y-axis,
     self.Vz = 4  # shear along z-axis.
     self.T = 5  # torsion along x-axis.
     if ((compName == 'N') or (compName == 'P')):
         retval = self.N
     elif (compName == 'Mz'):
         retval = self.Mz
     elif ((compName == 'Qy') or (compName == 'Vy')):
         retval = self.Qy
     elif (compName == 'My'):
         retval = self.My
     elif ((compName == 'Qz') or (compName == 'Vz')):
         retval = self.Qz
     elif (compName == 'T'):
         retval = self.Qz
     else:
         lmsg.error(
             'Item ' + str(compName) +
             ' is not a valid component. Available components are: N, Mz, Qy, My, Qz, T.'
         )
     return retval
Ejemplo n.º 12
0
    def setUniaxialBearing2D(self, iNod, bearingMaterial, direction):
        '''Modelize an uniaxial bearing on the defined direction.

         :param iNod (int): node identifier (tag).
         :param  bearingMaterial (str): material name for the zero length
                 element.
          :return rtype: (int, int) new node tag, new element tag.
        '''
        nodes = self.preprocessor.getNodeHandler
        newNode = nodes.duplicateNode(iNod)  # new node.
        # Element definition
        elems = self.preprocessor.getElementHandler
        elems.dimElem = self.preprocessor.getNodeHandler.dimSpace  # space dimension.
        if (elems.dimElem > 2):
            lmsg.warning("Not a bi-dimensional space.")
        elems.defaultMaterial = bearingMaterial
        zl = elems.newElement("ZeroLength", xc.ID([newNode.tag, iNod]))
        zl.setupVectors(xc.Vector([direction[0], direction[1], 0]),
                        xc.Vector([-direction[1], direction[0], 0]))
        zl.clearMaterials()
        zl.setMaterial(0, bearingMaterial)
        # Boundary conditions
        numDOFs = self.preprocessor.getNodeHandler.numDOFs
        for i in range(0, numDOFs):
            spc = self.constraints.newSPConstraint(newNode.tag, i, 0.0)
        return newNode.tag, zl.tag
Ejemplo n.º 13
0
    def defineLocalAxes(self, setToDisplay):
        ''' Define the local axes of the blocks.

        :param setToDisplay: set of elements to be displayed.
        '''
        lineAxesField = None
        surfAxesField = None
        numKPts = setToDisplay.getPoints.size
        if (numKPts > 0):
            avgSize = setToDisplay.getEntities.getAverageSize()
            vectorScale = avgSize / 4.0
            ## Draw lines local axes.
            lineAxesField = lavf.LinesLocalAxesVectorField(
                setToDisplay.name + '_lineLocalAxes', scaleFactor=vectorScale)
            lineAxesField.dumpVectors(setToDisplay)
            ## Draw quad surfaces local axes.
            surfAxesField = lavf.SurfacesLocalAxesVectorField(
                setToDisplay.name + '_surfLocalAxes', scaleFactor=vectorScale)
            surfAxesField.dumpVectors(setToDisplay)
        else:
            lmsg.warning(
                "Error when drawing set: '" + setToDisplay.name +
                "' it has not key points so I can't get set geometry (use fillDownwards?)"
            )
        return lineAxesField, surfAxesField
Ejemplo n.º 14
0
 def dumpLoads(self, preprocessor, indxDiagram):
     ''' Dump loads over elements.'''
     activeLoadPatterns= preprocessor.getDomain.getConstraints.getLoadPatterns
     if(len(activeLoadPatterns)<1):
         lmsg.warning('No active load patterns.')
     for lp in activeLoadPatterns: #Iterate over loaded elements.
         self.dumpElementalLoads(preprocessor,lp.data(),indxDiagram)
Ejemplo n.º 15
0
    def ic(self, deltaB, deltaL, Hload, Beff, Leff):
        '''Factor that introduces the effect of load inclination on
           the cohesion component.

        :param deltaB: angle between the load and the foundation width
                       atan(HloadB/VLoad).
        :param deltaL: angle between the load and the foundation length
                       atan(HloadL/VLoad).
        :param Hload: Horizontal load. 
        :param Beff: Width of the effective foundation area
                     (see figure 12 in page 44 of reference[2]).
        :param Leff: Length of the effective foundation area
                    (see figure 12 in page 44 of reference[2]).
        '''
        if (self.getDesignPhi() != 0.0):
            iq = self.iq(deltaB, deltaL)
            return (iq * self.Nq() - 1.0) / (self.Nq() - 1.0)
        else:  #See expresion (15) in reference [2]
            resist = Beff * Leff * self.getDesignC()
            if (Hload <= resist):
                twoAlpha = math.acos(Hload / resist)
                return 0.5 + (twoAlpha + math.sin(twoAlpha)) / (math.pi + 2.0)
            else:
                lmsg.warning('Load (H= ' + str(Hload) +
                             ') greater than soil strength R=' + str(resist) +
                             ' returns 0.0')
                return 0.0
Ejemplo n.º 16
0
def VtkDibujaIdsKPts(uGrid, setToDraw, renderer):
    '''Draw the point labels.'''
    numKPtsDI = setToDraw.getPoints.size
    if (numKPtsDI > 0):
        ids = vtk.vtkIdFilter()
        ids.SetInput(uGrid)
        ids.CellIdsOff()
        ids.PointIdsOff()

        VtkCargaIdsKPts(uGrid, setToDraw)

        visPts = vtk.vtkSelectVisiblePoints()
        visPts.SetInputConnection(ids.GetOutputPort())
        visPts.SetRenderer(renderer)
        visPts.SelectionWindowOff()

        #Create the mapper to display the point ids.  Specify the format to
        #  use for the labels.  Also create the associated actor.
        ldm = vtk.vtkLabeledDataMapper()
        ldm.SetInputConnection(visPts.GetOutputPort())
        ldm.GetLabelTextProperty().SetColor(0.1, 0.1, 0.1)

        pointLabels = vtk.vtkActor2D()
        pointLabels.SetMapper(ldm)

        renderer.AddActor2D(pointLabels)
    else:
        lmsg.warning("El conjunto: '" + setToDraw.name + "' no tiene KPts.")
Ejemplo n.º 17
0
 def createElementSet(self):
     '''Create the attributes 'length' and 'elemSet' that 
     represent the length of the beam and the set of elements included in it.'''
     prep = self.getPreprocessor()
     if self.lstLines:
         lstLn = self.lstLines
         lstP3d = gu.lstP3d_from_lstLns(lstLn)
     elif self.lstPoints:
         lstP3d = [p.getPos for p in self.lstPoints]
         lstLn = gu.lstLns_from_lstPnts(self.lstPoints)
     else:
         lmsg.warning(
             'Incomplete member definition: list of lines or points  required'
         )
     #set of elements included in the member
     s = prep.getSets.defSet(self.name + 'Set')
     self.elemSet = s.elements
     for l in lstLn:
         for e in l.elements:
             self.elemSet.append(e)
     pol = geom.Polyline3d()
     for p in lstP3d:
         pol.append(p)
     self.length = pol.getLength()
     return pol
Ejemplo n.º 18
0
    def getLoadData(self, internalForces, origin):
        ''' Extracts the internal forces for this member from the
            argument.

        :param internalForces: internal forces of the connected elements.
        :param origin: connection origin.
        '''
        originPos = origin.getInitialPos3d
        orientation = self.getOrientation(originPos)
        self.internalForces = dict()
        for comb in internalForces:
            loads = internalForces[comb]
            for elemId in loads:
                if (int(elemId) == self.eTag):  # loads for this member
                    elemLoads = loads[elemId]
                    elemInternalForces = elemLoads['internalForces']
                    iForces = None
                    if (orientation > 0):
                        iForces = elemInternalForces['0']
                    else:
                        iForces = elemInternalForces['1']
                    loadPos = [originPos.x, originPos.y, originPos.z]
                    self.internalForces[comb] = (loadPos, iForces)
        if (len(self.internalForces) == 0):
            lmsg.warning('No internal forces found for element: ' +
                         str(self.eTag))
        return self.internalForces
Ejemplo n.º 19
0
    def checkSetFromIntForcFile(self, intForcCombFileName, setCalc=None):
        '''Launch checking.

        :param setCalc: set of elements to check
        '''
        intForcItems = lsd.readIntForcesFile(intForcCombFileName, setCalc)
        internalForcesValues = intForcItems[2]
        for e in setCalc.elements:
            sh = e.getProp('crossSection')
            sc = e.getProp('sectionClass')
            elIntForc = internalForcesValues[e.tag]
            if (len(elIntForc) == 0):
                lmsg.warning('No internal forces for element: ' + str(e.tag) +
                             ' of type: ' + e.type())
            for lf in elIntForc:
                CFtmp = sh.getYShearEfficiency(sc, lf.Vy)
                if lf.idSection == 0:
                    if (CFtmp > e.getProp(self.limitStateLabel + 'Sect1').CF):
                        e.setProp(
                            self.limitStateLabel + 'Sect1',
                            cv.ShearYControlVars('Sects1', lf.idComb, CFtmp,
                                                 lf.Vy))
                else:
                    if (CFtmp > e.getProp(self.limitStateLabel + 'Sect2').CF):
                        e.setProp(
                            self.limitStateLabel + 'Sect2',
                            cv.ShearYControlVars('Sects2', lf.idComb, CFtmp,
                                                 lf.Vy))
Ejemplo n.º 20
0
    def qu(self,q,D,Beff,Leff,Vload,HloadB,HloadL,NgammaCoef= 1.5,psi= 0.0,eta= 0.0):
        '''Ultimate bearing capacity pressure of the soil.

        :param D: foundation depth.
        :param Beff: Width of the effective foundation area
                     (see figure 12 in page 44 of reference[2]).
        :param Leff: Length of the effective foundation area
                     (see figure 12 in page 44 of reference[2]).
        :param Vload: Vertical load (positive downwards). 
        :param HloadB: Horizontal load on Beff direction. 
        :param HloadL: Horizontal load on Leff direction. 
        :param NgammaCoef: 1.5 in reference [1], 1.8 in reference 2 
                           and 2 in reference 3
        :param psi: angle of the line on wich the q load acts 
                    (see figure 4.7 in page 102 of reference [3])
                    must be determined by iterations.
        '''
        if(Vload<0.0):
             lmsg.warning('Negative vertical load (V= '+str(Vload)+') means pushing upwards.')
        deltaB= math.atan(HloadB/Vload)
        deltaL= math.atan(HloadL/Vload)
        Hload= math.sqrt(HloadB**2+HloadL**2)
        gammaComp= self.quGamma(D,Beff,Leff,Vload,HloadB,HloadL,NgammaCoef,psi,eta)
        cComp= self.quCohesion(D,Beff,Leff,Vload,HloadB,HloadL,psi,eta)
        qComp= self.quQ(q,D,Beff,Leff,Vload,HloadB,HloadL,psi,eta)
        return gammaComp+cComp+qComp
Ejemplo n.º 21
0
    def getBlocks(self, blockProperties=None):
        ''' Creates the block data for later meshing.

        :param blockProperties: labels and attributes to assign to the newly created blocks.
        '''
        originNodeTag = str(self.originNode.tag)
        properties = bte.BlockProperties.copyFrom(blockProperties)
        properties.appendAttribute('jointId', originNodeTag)
        retval = bte.BlockData()
        # Column blocks.
        columnShapeBlocks = self.getColumnShapeBlocks(
            self.columnLengthFactor, blockProperties=properties)
        retval.extend(columnShapeBlocks)
        # Beam blocks.
        beamShapeBlocks = self.getBeamShapeBlocks(self.beamLengthFactor,
                                                  blockProperties=properties)
        retval.extend(beamShapeBlocks)
        # Diagonal blocks.
        for e in self.diagonals:
            retval.extend(
                self.getGussetBlocksForDiagonal(e, blockProperties=properties))
        if (hasattr(self, 'basePlate')):
            retval.extend(
                self.getBasePlateBlocks(columnShapeBlocks,
                                        blockProperties=properties))
        else:
            lmsg.warning('base plate not found.')
        return retval
Ejemplo n.º 22
0
 def solve(self):
     self.modelSpace.removeAllLoadPatternsFromDomain()
     self.modelSpace.addNewLoadCaseToDomain(self.loadCaseName,self.loadCaseExpr)
     #Solution
     lmsg.warning('Here we use a simple linear static solution that is not always a suitable method.')
     analysis= predefined_solutions.simple_static_linear(self.feProblem)
     result= analysis.analyze(1)
Ejemplo n.º 23
0
    def dumpVectors(self,
                    preprocessor,
                    defFScale,
                    showElementalLoads=True,
                    showNodalLoads=True):
        ''' Iterate over loads dumping them into the graphic.

        :param preprocessor: preprocessor of the FE problem.
        :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.
        :param showElementalLoads: if true show loads over elements.
        :param showNodalLoads: if true show loads over nodes.
        '''
        count = 0
        activeLoadPatterns = preprocessor.getDomain.getConstraints.getLoadPatterns
        if (len(activeLoadPatterns) < 1):
            lmsg.warning('No active load patterns.')
        else:
            for lp in activeLoadPatterns:  #Iterate over loaded elements.
                numberOfLoads = self.populateLoads(lp.data())
                if (numberOfLoads > 0):
                    maxLoad = self.getMaxLoad()
                    if (maxLoad != 0):
                        self.data.scaleFactor /= self.getMaxLoad()
                    #Iterate over loaded elements.
                    count += self.dumpElementalPositions(lp.data())
                    #Iterate over loaded nodes.
                    count += self.dumpNodalPositions(lp.data(), defFScale)
                    if (count == 0):
                        lmsg.warning(
                            'LoadVectorField.dumpVectors: no loads defined.')
        return count
Ejemplo n.º 24
0
 def selectKPoints(self):
     '''Selects the k-points to be used in the model. All the points that
        are closer than the threshold distance are melted into one k-point.
     '''
     points, layers= self.extractPoints()
     indexDict= None
     if(len(points)>0):
         self.kPoints= [points[0]]
         pointName= layers[0][0]
         objProperties= layers[0][1]
         self.propertyDict[pointName]= objProperties
         indexDict= dict()
         indexDict[0]= pointName
         for p, l in zip(points, layers):
             pointName= l[0]
             objProperties= l[1]
             indexNearestPoint= self.getIndexNearestPoint(p)
             nearestPoint= self.kPoints[indexNearestPoint]
             dist= cdist([p],[nearestPoint])[0][0]
             if(dist>self.threshold): # new point.
                 indexNearestPoint= len(self.kPoints) # The point itself.
                 self.kPoints.append(p)
                 self.propertyDict[pointName]= objProperties
                 indexDict[indexNearestPoint]= pointName
             else:
                 pointName= indexDict[indexNearestPoint]
                 self.propertyDict[pointName].extend(objProperties)
     else:
         lmsg.warning('No points in :'+self.fileName+' file.')
     return indexDict
Ejemplo n.º 25
0
def AsSimpleBending(M, fcd, fsd, b, d):
    ''' Return the required reinforcement for a rectangular section
      subjected to simple bending.

  :param M: bending moment to resist.
  :param fcd: concrete design compressive strength (absolute value).
  :param fsd: steel design yield strength.
  :param b: section width.
  :param d: section depth.
  '''
    if (fcd < 0.0):
        lmsg.warning(
            'positive value expected for concrete design strength fcd= ' +
            str(fcd / 1e6) + ' MPa.')
    Ml = Mlim(fcd, b, d)
    if (M > Ml):
        lmsg.warning('compression reinforcement needed Ml= ' + str(Ml / 1e3) +
                     ' kN m < ' + str(M / 1e3) + ' kN m')
        T = 1e9
    else:
        c = 0.85 * fcd * b
        T = c * (d - math.sqrt(d**2 - 2 * M / c))
        xpl = T / c
        assert xpl <= d, "xpl bigger than section depth."
    return T / fsd
Ejemplo n.º 26
0
    def exportBlockTopology(self, name):
        retval= bte.BlockData()
        retval.name= name
        retval.fileName= self.fileName
        retval.logMessage= '# imported from file: '+self.fileName+' on '
        retval.logMessage+= str(datetime.datetime.now())

        counter= 0
        if(self.kPoints):
            for p in self.kPoints:
                key= self.kPointsNames[counter]
                bp= bte.BlockProperties(labels= self.labelDict[key])
                retval.appendPoint(id= counter,x= p[0],y= p[1],z= p[2], pointProperties= bp)
                counter+= 1

            counter= 0
            for key in self.lines:
                line= self.lines[key]
                bp= bte.BlockProperties(labels= self.labelDict[key])
                block= bte.BlockRecord(counter,'line',line, blockProperties= bp)
                retval.appendBlock(block)
                counter+= 1

            for name in self.getNamesToImport():
                fg= self.facesTree[name]
                for key in fg:
                    face= fg[key]
                    bp= bte.BlockProperties(labels= self.labelDict[key])
                    block= bte.BlockRecord(counter,'face',face, blockProperties= bp)
                    retval.appendBlock(block)
                    counter+= 1
        else:
            lmsg.warning('Nothing to export.')
        return retval
Ejemplo n.º 27
0
    def defElasticSection1d(self, preprocessor, material):
        ''' Return an elastic section appropiate for truss analysis.

        :param preprocessor: preprocessor object.
        :param material:     material constitutive model 
                             (for which E is the Young's modulus)
        '''
        if (not self.xc_material):
            materialHandler = preprocessor.getMaterialHandler
            if (materialHandler.materialExists(self.sectionName)):
                lmsg.warning("Section: " + self.sectionName +
                             " already defined.")
                self.xc_material = materialHandler.getMaterial(
                    self.sectionName)
            else:
                self.xc_material = typical_materials.defElasticSection1d(
                    preprocessor,
                    self.sectionName,
                    self.A(),
                    material.E,
                    linearRho=material.rho * self.A())
        else:
            lmsg.warning('Material: ' + self.sectionName +
                         ' already defined as:' + str(self.xc_material))
        return self.xc_material
Ejemplo n.º 28
0
    def displayNodeValueDiagram(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)
        lmsg.warning("Auto scale not implemented yet.")
        LrefModSize= setToDisplay.getBnd(1.0).diagonal.getModulus() #representative length of set size (to autoscale)
        scaleFactor= LrefModSize/unitConversionFactor 
        diagram= npd.NodePropertyDiagram(scaleFactor= scaleFactor,fUnitConv= unitConversionFactor,sets=[setToDisplay], attributeName= 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)
Ejemplo n.º 29
0
 def alphaZ(self):
     '''Return shear shape factor with respect to local z-axis'''
     msg = 'alphaZ: shear shape factor not implemented for section: '
     msg += self.sectionName
     msg += '. 5/6 returned'
     lmsg.warning(msg)
     return 5.0 / 6.0
Ejemplo n.º 30
0
def create_attribute_at_nodes(xcSet, attributeName, initialValue):
    ''' Create an attribute on the nodes of the set passed as parameter.
    return tags of the affected nodes.

    :param xcSet: nodes that will receive the attribute.
    :param attributeName: name of the attribute to define.
    :param initialValue: initial value to assign to the attribute.
    '''
    touchedNodesTags = {}
    for e in xcSet:
        elemNodes = e.getNodes
        sz = len(elemNodes)
        for i in range(0, sz):
            n = elemNodes[i]
            tag = n.tag
            if tag not in touchedNodesTags:
                touchedNodesTags[tag] = 1
                if (n.hasProp(attributeName)):
                    lmsg.warning('node: ' + str(n.tag) +
                                 ' already has a property named: \'' +
                                 attributeName + '\'.')
                n.setProp(attributeName, initialValue)
            else:
                touchedNodesTags[tag] += 1
    return touchedNodesTags