示例#1
0
文件: fea.py 项目: certik/sfepy
    def setup_global_base( self, domain ):
        """
        efaces: indices of faces into econn.
        """

        node_offset_table = nm.zeros( (4, len( self ) + 1), dtype = nm.int32 )
##         print node_offset_table.shape
        
        i_vertex, i_edge, i_face, i_bubble = 0, 1, 2, 3

        # Global node number.
        iseq = 0

        ##
        # Vertex nodes.
        n_v = domain.shape.n_nod
        cnt_vn = nm.empty( (n_v,), dtype = nm.int32 )
        cnt_vn.fill( -1 )
        
        node_offset_table[i_vertex,0] = iseq
        ia = 0
        for region_name, ig, ap in self.iter_aps():
            region = ap.region
            node_desc = self.node_descs[region_name]
            n_ep = ap.n_ep['v']
            group = region.domain.groups[ig]
            
            ap.econn = nm.zeros( (region.shape[ig].n_cell, n_ep), nm.int32 )
##             print ap.econn.shape
#            pause()
            if node_desc.vertex.size:
                offset = group.shape.n_ep
                vertices = region.get_vertices( ig )
                n_new = (nm.where( cnt_vn[vertices] == -1 )[0]).shape[0]
                cnt_vn[vertices] = vertices
#                print n_new
                iseq += n_new
            node_offset_table[i_vertex,ia+1] = iseq
            ia += 1

        ##
        # Remap vertex node connectivity to field-local numbering.
        indx = nm.arange( iseq, dtype = nm.int32 )
        remap = nm.empty( (n_v,), dtype = nm.int32 )
        remap.fill( -1 )
        remap[nm.where( cnt_vn >= 0 )[0]] = indx
##         print remap
##         pause()
##         print iseq, remap
##         pause()
        for region_name, ig, ap in self.iter_aps():
            region = ap.region
            node_desc = self.node_descs[region_name]
            group = region.domain.groups[ig]
            if node_desc.vertex.size:
                offset = group.shape.n_ep
                cells = region.get_cells( ig )
                ap.econn[:,:offset] = remap[group.conn[cells]]
##                 print group.conn, nm.amax( group.conn )
##                 print ap.econn, nm.amax( ap.econn )
##                 pause()

        ed, ned, fa, nfa = domain.get_neighbour_lists()
        entt = self.ent_table
        cnt_en = nm.zeros( (entt.shape[1], ed.n_unique), nm.int32 ) - 1

        ##
        # Edge nodes.
        node_offset_table[i_edge,0] = iseq
        ia = 0
        for region_name, ig, ap in self.iter_aps():
            region = ap.region
            node_desc = self.node_descs[region_name]
            group = region.domain.groups[ig]
            if node_desc.edge:
                cptr0 = int( ned.pel[ned.pg[ig]] )
                ori = self.edge_oris[ig]
                iseq = mu.assign_edge_nodes( iseq, ap.econn, cnt_en, \
                                           ori, entt, ned.uid, \
                                           node_desc.edge, cptr0 )[1]
##                 print ap.econn
##                 pause()
            node_offset_table[i_edge,ia+1] = iseq
            ia += 1
            
        #    cnt_fn = nm.zeros( (fntt.shape[1], fa.n_unique), nm.int32 ) - 1
        node_offset_table[i_face,0] = iseq
        ia = 0
        for region_name, ig, ap in self.iter_aps():
            node_offset_table[i_face,ia+1] = iseq
            ia += 1

        #    cnt_bn = nm.zeros( (fntt.shape[1], fa.n_unique), nm.int32 ) - 1
        ##
        # Bubble nodes.
        node_offset_table[i_bubble,0] = iseq
        ia = 0
        for region_name, ig, ap in self.iter_aps():
            region = ap.region
            node_desc = self.node_descs[region_name]
            group = region.domain.groups[ig]
            if (node_desc.bubble):
                n_bubble = node_desc.bubble[0].shape[0]
                n_el = region.shape[ig].n_cell
                aux = nm.arange( iseq, iseq + n_bubble * n_el )
                aux.shape = (n_el, n_bubble)
                offset = node_desc.bubble[0][0,0]
                ap.econn[:,offset:] = aux[:,:]
                iseq += n_bubble * n_el

            node_offset_table[i_bubble,ia+1] = iseq
            ia += 1
            
##         print node_offset_table
        if node_offset_table[-1,-1] != iseq:
            raise RuntimeError
        
        self.node_offset_table = node_offset_table

        ia = 0
        for region_name, ig, ap in self.iter_aps():
            ap.node_offsets = self.node_offset_table[:,ia:ia+2]
            ia += 1
##             print ia
##             print ap.econn
##             print ap.node_offsets
#            pause()
            
        for region_name, ig, ap in self.iter_aps():
            node_desc = self.node_descs[region_name]

            gd = ap.interp.gel.data['v']
            ap.efaces = gd.faces.copy()

            if ap.has_extra_edge_nodes:
                nd = node_desc.edge
                efs = []
                for eof in gd.edges_of_faces:
                    ef = [nd[ie][:,0] for ie in eof]
                    efs.append( ef )
                efs = nm.array( efs ).squeeze()
                if efs.ndim < 2:
                    efs = efs[:,nm.newaxis]
#                print efs
                ap.efaces = nm.hstack( (ap.efaces, efs ) )

            if ap.has_extra_face_nodes:
                nd = node_desc.face
                efs = [ef[:,0] for ef in nd]
#                print nd
                efs = nm.array( efs ).squeeze()
                if efs.ndim < 2:
                    efs = efs[:,nm.newaxis]
#                print efs
                ap.efaces = nm.hstack( (ap.efaces, efs ) )
                
##             print ap.efaces
##             print ap.interp.base_funs['v'].fun
##             try:
##                 print ap.interp.base_funs['s2'].fun
##                 print ap.interp.base_funs['s3'].fun
##             except:
##                 pass
##             pause()

        return iseq, remap, cnt_vn, cnt_en
示例#2
0
    def setup_global_base(self):
        """
        efaces: indices of faces into econn.
        """
        region = self.region
        node_desc = self.node_desc

        node_offset_table = nm.zeros( (4, len( self ) + 1), dtype = nm.int32 )

        i_vertex, i_edge, i_face, i_bubble = 0, 1, 2, 3

        # Global node number.
        iseq = 0

        ##
        # Vertex nodes.
        n_v = region.n_v_max
        cnt_vn = nm.empty( (n_v,), dtype = nm.int32 )
        cnt_vn.fill( -1 )
        
        node_offset_table[i_vertex,0] = iseq
        ia = 0
        for ig, ap in self.iter_aps():
            n_ep = ap.n_ep['v']
            n_cell = region.get_n_cells(ig, self.is_surface)
            ap.econn = nm.zeros((n_cell, n_ep), nm.int32)

##             print ap.econn.shape
#            pause()
            if node_desc.vertex is not None:
                vertices = region.get_vertices( ig )
                n_new = (nm.where( cnt_vn[vertices] == -1 )[0]).shape[0]
                cnt_vn[vertices] = vertices
#                print n_new
                iseq += n_new
            node_offset_table[i_vertex,ia+1] = iseq
            ia += 1

        ##
        # Remap vertex node connectivity to field-local numbering.
        indx = nm.arange( iseq, dtype = nm.int32 )
        remap = nm.empty( (n_v,), dtype = nm.int32 )
        remap.fill( -1 )
        remap[nm.where( cnt_vn >= 0 )[0]] = indx
##         print remap
##         pause()
##         print iseq, remap
##         pause()
        for ig, ap in self.iter_aps():
            group = region.domain.groups[ig]
            if node_desc.vertex is not None:
                if not self.is_surface:
                    offset = group.shape.n_ep
                    cells = region.get_cells( ig )
                    ap.econn[:,:offset] = remap[group.conn[cells]]

                else:
                    faces = group.gel.get_surface_entities()
                    aux = FESurface('aux', region, faces, group.conn, ig)
                    ap.econn[:,:aux.n_fp] = aux.leconn
                    ap.surface_data[region.name] = aux

        ed, fa = region.domain.get_facets()
        entt = self.ent_table
        cnt_en = nm.zeros( (entt.shape[1], ed.n_unique), nm.int32 ) - 1

        ##
        # Edge nodes.
        node_offset_table[i_edge,0] = iseq
        ia = 0
        for ig, ap in self.iter_aps():
            if node_desc.edge is not None:
                cptr0 = ed.indx[ig].start
                ori = self.edge_oris[ig]
                iseq = mu.assign_edge_nodes( iseq, ap.econn, cnt_en, \
                                           ori, entt, ed.uid_i, \
                                           node_desc.edge, cptr0 )[1]
##                 print ap.econn
##                 pause()
            node_offset_table[i_edge,ia+1] = iseq
            ia += 1

        #    cnt_fn = nm.zeros( (fntt.shape[1], fa.n_unique), nm.int32 ) - 1
        node_offset_table[i_face,0] = iseq
        ia = 0
        for ig, ap in self.iter_aps():
            node_offset_table[i_face,ia+1] = iseq
            ia += 1

        #    cnt_bn = nm.zeros( (fntt.shape[1], fa.n_unique), nm.int32 ) - 1
        ##
        # Bubble nodes.
        node_offset_table[i_bubble,0] = iseq
        ia = 0
        for ig, ap in self.iter_aps():
            if node_desc.bubble is not None:
                n_bubble = node_desc.bubble.shape[0]
                n_cell = region.get_n_cells(ig, self.is_surface)
                aux = nm.arange( iseq, iseq + n_bubble * n_cell )
                aux.shape = (n_cell, n_bubble)
                offset = node_desc.bubble[0]
                ap.econn[:,offset:] = aux[:,:]
                iseq += n_bubble * n_cell

            node_offset_table[i_bubble,ia+1] = iseq
            ia += 1

##         print node_offset_table
        if node_offset_table[-1,-1] != iseq:
            raise RuntimeError
        
        self.node_offset_table = node_offset_table

        ia = 0
        for ig, ap in self.iter_aps():
            ap.node_offsets = self.node_offset_table[:,ia:ia+2]
            ia += 1
##             print ia
##             print ap.econn
##             print ap.node_offsets
#            pause()
            
        for ig, ap in self.iter_aps():
            gel = ap.interp.gel
            ap.efaces = gel.get_surface_entities().copy()

            if ap.has_extra_edge_nodes:
                nd = node_desc.edge
                efs = []
                for eof in gel.get_edges_per_face():
                    ef = [nd[ie] for ie in eof]
                    efs.append( ef )
                efs = nm.array( efs ).squeeze()
                if efs.ndim < 2:
                    efs = efs[:,nm.newaxis]
#                print efs
                ap.efaces = nm.hstack( (ap.efaces, efs ) )

            if ap.has_extra_face_nodes:
                efs = node_desc.face
#                print nd
                efs = nm.array( efs ).squeeze()
                if efs.ndim < 2:
                    efs = efs[:,nm.newaxis]
#                print efs
                ap.efaces = nm.hstack( (ap.efaces, efs ) )
                
        return iseq, remap, cnt_vn, cnt_en