Пример #1
0
    def add_node(self, coords, setname=None):
        nn = self.nodelist.get_seqmax()

        try:
            item = np.array(coords, dtype=float)
        except:
            raise ValueError, ('input node coordinates', coords,
                               'can not convert to numpy float array')
        tempnode = coordinate(item, seq=nn + 1)
        self.nodelist.add(tempnode)
        if setname != None:
            self.add_to_set(setname, [nn + 1], settype='node')

        return tempnode
Пример #2
0
    def add_node(self,coords,setname=None):
        nn = self.nodelist.get_seqmax()

        try:
            item = np.array(coords,dtype=float)
        except:
            raise ValueError,('input node coordinates',coords,
                                  'can not convert to numpy float array')
        tempnode = coordinate(item,seq=nn+1)
        self.nodelist.add(tempnode)
        if setname != None:
            self.add_to_set(setname,[nn+1],settype='node')
        
        return tempnode
Пример #3
0
    def node(self, nlist, setname='default'):
        ''' create list of coordinate instance and add to nodelist
            input:
                list --  node location list [[x1,y1,z1],[x2,y2,z2],..,[xn,yn,zn]]
                         if in format of list, will be convert to numpy array
                         the sequence of node will be automatically assigned
                         based on the input sequence from current max sequence 
        '''
        # get current max sequence
        nn = self.nodelist.get_seqmax()
        no = nn
        tempnode = []
        tempnodeseqlist = []
        for item in nlist:
            nn += 1
            dseq = None
            # convert to the desired numpy array format
            try:
                if len(item) == 3:
                    item = np.array(item, dtype=float)
                elif len(item) == 2:
                    item = np.array([item[0], item[1], 0], dtype=float)

                elif len(
                        item
                ) == 4:  # node coordinates include the seq at first column
                    dseq = int(item[0])
                    item = np.array([item[1], item[2], item[3]], dtype=float)

                else:
                    raise ValueError, "Input coordinates size shall be 2 or 3"
            except:
                raise ValueError, ('input node coordinates', item,
                                   'can not convert to numpy float array')
            if dseq == None:
                seq = nn
            else:
                seq = dseq

            tempnode.append(coordinate(item, seq=seq))
            tempnodeseqlist.append(seq)

        if setname not in self.setlist.keys():
            self.nodeset(setname, {'nodelist': tempnodeseqlist})
        else:
            self.setlist[setname].addnode(tempnodeseqlist)
        # add nodes to nodelist
        self.nodelist.addbylist(tempnode)
        return no
Пример #4
0
 def node(self,nlist,setname='default'):
     ''' create list of coordinate instance and add to nodelist
         input:
             list --  node location list [[x1,y1,z1],[x2,y2,z2],..,[xn,yn,zn]]
                      if in format of list, will be convert to numpy array
                      the sequence of node will be automatically assigned
                      based on the input sequence from current max sequence 
     '''
     # get current max sequence
     nn = self.nodelist.get_seqmax()
     no = nn
     tempnode = []
     tempnodeseqlist = []
     for item in nlist:
         nn += 1
         dseq = None
         # convert to the desired numpy array format
         try:
             if len(item) == 3:
                 item = np.array(item,dtype=float)
             elif len(item) == 2:
                 item = np.array([item[0],item[1],0],dtype=float)
 
             elif len(item) == 4:  # node coordinates include the seq at first column
                 dseq = int(item[0])
                 item = np.array([item[1],item[2],item[3]],dtype=float)
                 
 
             else:
                 raise ValueError, "Input coordinates size shall be 2 or 3"
         except:
             raise ValueError,('input node coordinates',item,
                               'can not convert to numpy float array')
         if dseq == None:
             seq = nn
         else:
             seq = dseq
         
         tempnode.append(coordinate(item,seq=seq))   
         tempnodeseqlist.append(seq)
         
     if setname not in self.setlist.keys():
         self.nodeset(setname,{'nodelist':tempnodeseqlist})
     else:
         self.setlist[setname].addnode(tempnodeseqlist)
     # add nodes to nodelist
     self.nodelist.addbylist(tempnode)
     return no