def __init__ ( self, elnodes , props ): list.__init__( self, elnodes ) self.history = {} self.current = {} for name,val in props: if name is "material": self.matProps = val self.mat = MaterialManager( self.matProps ) else: setattr(self, name, val)
def __init__ ( self, elnodes , props ): list.__init__( self, elnodes ) self.history = {} self.current = {} self.solverStat = props.solverStat for name,val in props: if name == "material": self.matProps = val self.matProps.solverStat = self.solverStat self.mat = MaterialManager( self.matProps ) setattr( self, name, val )
def __init__ ( self, props ): BaseMaterial.__init__( self, props ) self.matmodels = [] for material in self.materials: matmodel = MaterialManager( getattr( props , material ) ) self.matmodels.append( matmodel )
def __init__ ( self, elnodes , props ): list.__init__( self, elnodes ) self.history = {} self.current = {} for name,val in props: if name is "material": self.matProps = val self.mat = MaterialManager( self.matProps ) else: setattr( self, name, val )
class Element ( list ): dofTypes = [] #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def __init__ ( self, elnodes , props ): list.__init__( self, elnodes ) self.history = {} self.current = {} for name,val in props: if name is "material": self.matProps = val self.mat = MaterialManager( self.matProps ) else: setattr( self, name, val ) #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def dofCount ( self ): return len( self ) * len( self.dofTypes ) #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def getNodes ( self ): return self #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def getType ( self ): return self.elemType #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def appendNodalOutput ( self , outputNames , globdat , outmat , outw = None ): if outw == None: outw = ones( outmat.shape[0] ) for i,name in enumerate(outputNames): if not hasattr( globdat , name ): globdat.outputNames.append( name ) setattr( globdat, name , zeros( len(globdat.nodes) ) ) setattr( globdat, name + 'Weights' , zeros( len(globdat.nodes) ) ) outMat = getattr( globdat , name ) outWeights = getattr( globdat , name + 'Weights' ) #if outmat.shape[1] != outMat.shape[1] or outmat.shape[0] != len(self): # raise RuntimeError("Appended output vector has incorrect size.") indi = globdat.nodes.getIndices( self ) outMat[ indi ] += outmat[:,i] outWeights[ indi ] += outw #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def setHistoryParameter ( self, name, val ): self.current[name] = val #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def getHistoryParameter ( self, name ): return self.history[name] #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def commitHistory ( self ): self.history = self.current.copy() self.current = {} if hasattr( self , "mat" ): self.mat.commitHistory() def commit ( self, elemdat ): pass
class Element ( list ): dofTypes = [] #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def __init__ ( self, elnodes , props ): list.__init__( self, elnodes ) self.history = {} self.current = {} for name,val in props: if name is "material": self.matProps = val self.mat = MaterialManager( self.matProps ) else: setattr( self, name, val ) #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def dofCount ( self ): return len( self ) * len( self.dofTypes ) #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def getNodes ( self ): return self #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def getType ( self ): return self.elemType #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def appendNodalOutput ( self, outputName, globdat, outmat, outw = None ): if outw == None: outw = ones( outmat.shape[0] ) if not hasattr( globdat, outputName ): globdat.outputNames.append( outputName ) setattr( globdat, outputName, zeros( ( len(globdat.nodes), outmat.shape[1] ) ) ) setattr( globdat, outputName + 'Weights', zeros( len(globdat.nodes) ) ) outMat = getattr( globdat, outputName ) outWeights = getattr( globdat, outputName + 'Weights' ) if outmat.shape[1] != outMat.shape[1] or outmat.shape[0] != len(self): raise RuntimeError("Appended output vector has incorrect size.") indi = globdat.nodes.getIndices( self ) outMat[ indi ] += outer( outw, ones(outmat.shape[1]) ) * outmat outWeights[ indi ] += outw #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def setHistoryParameter ( self, name, val ): self.current[name] = val #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def getHistoryParameter ( self, name ): return self.history[name] #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def commitHistory ( self ): self.history = self.current.copy() self.current = {} if hasattr( self , "mat" ): self.mat.commitHistory()
class Element ( list ): dofTypes = [] #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def __init__ ( self, elnodes , props ): list.__init__( self, elnodes ) self.history = {} self.current = {} for name,val in props: if name is "material": self.matProps = val self.mat = MaterialManager( self.matProps ) else: setattr(self, name, val) #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def dofCount ( self ): return len( self ) * len( self.dofTypes ) #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def getNodes ( self ): return self #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def getType ( self ): return self.elemType #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def appendNodalOutput(self, outputName, global_data, outmat, outw=None): if outw == None: outw = ones(outmat.shape[0]) if not hasattr(global_data, outputName): # [email protected] added comments here # This code add new attribute 'stresses' or 'strains' for an instant of object globaldat global_data.outputNames.append(outputName) setattr(global_data, outputName, zeros( ( len(global_data.nodes), outmat.shape[1]))) setattr(global_data, outputName + 'Weights', zeros(len(global_data.nodes))) outMat = getattr(global_data, outputName) outWeights = getattr(global_data, outputName + 'Weights') if outmat.shape[1] != outMat.shape[1] or outmat.shape[0] != len(self): raise RuntimeError("Appended output vector has incorrect size.") indi = global_data.nodes.getIndices(self) outMat[indi] += outer(outw, ones(outmat.shape[1])) * outmat outWeights[indi] += outw #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ # [email protected] added this function def appendCellOutput(self, outputName, global_data, outmat, elemID): if not hasattr(global_data, outputName): setattr(global_data, outputName, zeros((len(global_data.elements), outmat.shape[1]))) outMat = getattr(global_data, outputName) if outmat.shape[1] != outMat.shape[1] or outmat.shape[0] != len(self): raise RuntimeError("Appended output vector has incorrect size.") outMat[elemID] = outmat[0, :] # ------------------------------------------------------------------------------ # # ------------------------------------------------------------------------------ def setHistoryParameter(self, name, val): self.current[name] = val #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def getHistoryParameter(self, name): return self.history[name] #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def commitHistory(self): self.history = self.current.copy() self.current = {} if hasattr(self, "mat"): self.mat.commitHistory()
class Element ( list ): dofTypes = [] #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def __init__ ( self, elnodes , props ): list.__init__( self, elnodes ) self.history = {} self.current = {} self.solverStat = props.solverStat for name,val in props: if name == "material": self.matProps = val self.matProps.solverStat = self.solverStat self.mat = MaterialManager( self.matProps ) setattr( self, name, val ) #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def dofCount ( self ): return len( self ) * len( self.dofTypes ) #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def getNodes ( self ): return self #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def getType ( self ): return self.elemType #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def appendNodalOutput( self , labels , data , weight = 1.0 ): for i,name in enumerate(labels): if not hasattr( self.globdat , name ): self.globdat.outputNames.append( name ) setattr( self.globdat, name , zeros( len(self.globdat.nodes) ) ) setattr( self.globdat, name + 'Weights' , zeros( len(self.globdat.nodes) ) ) outMat = getattr( self.globdat , name ) outWeights = getattr( self.globdat , name + 'Weights' ) for idx in self.globdat.nodes.getIndices( self ): outMat[ idx ] += data[i] outWeights[ idx ] += weight #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def setHistoryParameter ( self, name, val ): self.current[name] = val #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def getHistoryParameter ( self, name ): return self.history[name] #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ def commitHistory ( self ): self.history = self.current.copy() self.current = {} if hasattr( self , "mat" ): self.mat.commitHistory() def commit ( self, elemdat ): pass