Beispiel #1
0
    def elem_write(self, mesh_name):
        meshfile = open(mesh_name, 'w')
        print('Writing ' + mesh_name + '.....')
        nelem = cubit.get_tri_count()
        print('number of elements:', str(nelem))
        meshfile.write(str(nelem) + '\n')
        num_write = 0
        temp_tri = []
        for block, flag in zip(self.block_mat, self.block_flag):
            tris = cubit.get_block_tris(block)
            for tri in tris:
                nodes = cubit.get_connectivity('Tri', tri)
                temp_tri.append(tri)


#                txt=('%10i ')% tri
#                txt=txt+('%10i %10i %10i\n')% nodes[:]
#               meshfile.write(txt)

        temp_tri.sort()
        for tri in temp_tri:
            nodes = cubit.get_connectivity('Tri', tri)
            txt = ('%10i ') % tri
            txt = txt + ('%10i %10i %10i\n') % nodes[:]
            meshfile.write(txt)

        meshfile.close()
        print('Ok')
Beispiel #2
0
    def free_write(self, free_name):
        freefile = open(free_name, 'w')
        print('writing ' + free_name)

        list_tet = cubit.parse_cubit_list('tet', 'all')

        if (self.block_free != []):
            for n in self.block_free:
                elems_free = cubit.get_block_tris(n)
                dic_free = dict(zip(elems_free, elems_free))
                nfree = len(elems_free)
                freefile.write(str(nfree) + '\n')
                print('Number of free elements ', nfree)

            for tet in list_tet:
                tris = cubit.get_sub_elements('tet', tet, 2)
                for tri in tris:
                    if dic_free.has_key(tri):
                        nodes = cubit.get_connectivity('Tri', tri)
                        txt = ('%10i ') % tet
                        txt = txt + ('%10i %10i %10i') % nodes[:]
                        freefile.write(str(txt) + '\n')
        else:
            freefile.write(str(0) + '\n')
            print('Number of free elements ', 0)
Beispiel #3
0
    def absorb_write(self, absorb_name):
        absorbfile = open(absorb_name, 'w')
        print('writing ' + absorb_name)

        #        for n in self.ns_absorb:
        #            nodes_absorb=cubit.get_nodeset_nodes(n)
        #        nabs=len(nodes_absorb)
        #        absorbfile.write(str(nabs)+'\n')
        #        print('Number of absorbing nodes ',nabs)

        #        for node in nodes_absorb:
        #            absorbfile.write(str(node)+'\n')
        ###
        list_tet = cubit.parse_cubit_list('tet', 'all')

        if (self.block_absorb != []):
            for n in self.block_absorb:
                elems_absorb = cubit.get_block_tris(n)
                dic_absorb = dict(zip(elems_absorb, elems_absorb))
                nabs = len(elems_absorb)
                absorbfile.write(str(nabs) + '\n')
                print('Number of absorbing elements ', nabs)

            for tet in list_tet:
                tris = cubit.get_sub_elements('tet', tet, 2)
                for tri in tris:
                    if dic_absorb.has_key(tri):
                        nodes = cubit.get_connectivity('Tri', tri)
                        txt = ('%10i ') % tet
                        txt = txt + ('%10i %10i %10i') % nodes[:]
                        absorbfile.write(str(txt) + '\n')
        else:
            absorbfile.write(str(0) + '\n')
            print('Number of absorbing elements ', 0)
Beispiel #4
0
    def elem_write(self,mesh_name):
        meshfile=open(mesh_name,'w')
        print('Writing '+mesh_name+'.....')
        nelem=cubit.get_tri_count()
        print('number of elements:',str(nelem))
        meshfile.write(str(nelem)+'\n')
        num_write=0
        temp_tri=[]
        trilength=1
        for block,flag in zip(self.block_mat,self.block_flag):
            trilength += len(cubit.get_block_tris(block))
        tri_vp=range(trilength)
        tri_vs=range(trilength)
        tri_rho=range(trilength)
        tri_qp=range(trilength)
        tri_qs=range(trilength)
        tri_block=range(trilength)
        for block,flag in zip(self.block_mat,self.block_flag):
            tris=cubit.get_block_tris(block)
            name=cubit.get_exodus_entity_name('block',block)
            type=cubit.get_block_element_type(block)
            for tri in tris:
                nodes=cubit.get_connectivity('Tri',tri)
                temp_tri.append(tri)
                values=name.split(" ")
                tri_vp[tri]=float(values[2])
                tri_vs[tri]=float(values[3])
                tri_rho[tri]=float(values[4])
                tri_qp[tri]=float(values[5])
                tri_qs[tri]=float(values[6])
        temp_tri.sort()
        for tri in temp_tri:
            nodes=cubit.get_connectivity('Tri',tri)
            txt=('%10i ')% tri
            txt=txt+('%10i %10i %10i\n')% nodes[:]
            # This is later needed for the inversion feature:
            #txt=txt+('%10i %10i %10i')% nodes[:]
            #txt=txt+(' %9.1f %9.1f %9.1f %5i %5i\n') % (tri_vp[tri],tri_vs[tri],tri_rho[tri],tri_qp[tri],tri_qs[tri])
            meshfile.write(txt)


        meshfile.close()
        print('Ok')
Beispiel #5
0
    def mat_write(self, mat_name):
        nelem = cubit.get_tri_count()
        element = [[0, 0, 0] for i in range(nelem)]
        for block, flag in zip(self.block_mat, self.block_flag):
            tris = cubit.get_block_tris(block)
            for tri in tris:
                element[tri - 1] = [tri, flag, 0]

        for block, flag in zip(self.block_pml, self.block_pmlflag):
            tris = cubit.get_block_tris(block)
            for tri in tris:
                element[tri - 1][2] = flag

        mat = open(mat_name, 'w')
        print('Writing ' + mat_name + '.....')
        for i in range(nelem):
            mat.write(('%10i %10i %10i\n') %
                      (element[i][0], element[i][1], element[i][2]))
        mat.close()
        print('Ok')