def find_boundaries(outputfolder): vtk_found = False nodeset = cubit.get_nodeset_id_list() for n in nodeset: name = cubit.get_exodus_entity_name('nodeset', n) if name.find('vtk') >= 0: vtk_found = True print('found interface nodes to create vtk') values = name.split(" ") title = values[1] nodes_vtk = cubit.get_nodeset_nodes(n) write_vtk_file(nodes_vtk, title, outputfolder) if not vtk_found: print('no interface nodes to create vtk found')
def create_group_nodeset_desc(Clist,grpname,nodesetID=0,grpname_remove=[]): while nodesetID == 0 or (nodesetID in cubit.get_nodeset_id_list()): nodesetID = nodesetID +1 for c in Clist: cubit.silent_cmd('group "' + grpname + '" add node in ' + c) #Remove some vertice in nodes if specified print grpname_remove if len(grpname_remove)!=0: # Check if group already specified for grp in grpname_remove: id_grp=cubit.get_id_from_name(grp) if id_grp!=0: cubit.silent_cmd('group "' + grpname + '" remove node in group ' + grp) # Name the nodesets cubit.silent_cmd('nodeset ' + str(nodesetID) + ' group ' + grpname) cubit.silent_cmd('nodeset ' + str(nodesetID) + ' name "' + grpname + '"' )
def create_group_nodeset_desc(Clist, grpname, nodesetID=0, grpname_remove=[]): while nodesetID == 0 or (nodesetID in cubit.get_nodeset_id_list()): nodesetID = nodesetID + 1 for c in Clist: cubit.silent_cmd('group "' + grpname + '" add node in ' + c) #Remove some vertice in nodes if specified print grpname_remove if len(grpname_remove) != 0: # Check if group already specified for grp in grpname_remove: id_grp = cubit.get_id_from_name(grp) if id_grp != 0: cubit.silent_cmd('group "' + grpname + '" remove node in group ' + grp) # Name the nodesets cubit.silent_cmd('nodeset ' + str(nodesetID) + ' group ' + grpname) cubit.silent_cmd('nodeset ' + str(nodesetID) + ' name "' + grpname + '"')
def block_definition(self): block_flag=[] block_mat=[] block_bc=[] block_bc_flag=[] material={} bc={} blocks=cubit.get_block_id_list() for block in blocks: name=cubit.get_exodus_entity_name('block',block) ty=cubit.get_block_element_type(block) #print block,blocks,ty,self.hex,self.face if self.hex in ty: flag=None vel=None vs=None rho=None q=0 ani=0 # material domain id if "acoustic" in name : imaterial = 1 elif "elastic" in name: imaterial = 2 elif "poroelastic" in name: imaterial = 3 else : imaterial = 0 # nattrib=cubit.get_block_attribute_count(block) if nattrib > 1: # material flag: # positive => material properties, # negative => interface/tomography domain flag=int(cubit.get_block_attribute_value(block,0)) if flag > 0 and nattrib >= 2: # material properties # vp vel=cubit.get_block_attribute_value(block,1) if nattrib >= 3: # vs vs=cubit.get_block_attribute_value(block,2) if nattrib >= 4: # density rho=cubit.get_block_attribute_value(block,3) if nattrib >= 5: # next: Q_kappa or Q_mu (new/old format style) q=cubit.get_block_attribute_value(block,4) if nattrib == 6: # only 6 parameters given (skipping Q_kappa ), old format style qmu = q #Q_kappa is 10 times stronger than Q_mu qk = q * 10 # last entry is anisotropic flag ani=cubit.get_block_attribute_value(block,5) elif nattrib > 6: #Q_kappa qk=q #Q_mu qmu=cubit.get_block_attribute_value(block,5) if nattrib == 7: #anisotropy_flag ani=cubit.get_block_attribute_value(block,6) # for q to be valid: it must be positive if qk < 0 or qmu < 0: print 'error, Q value invalid:',qk,qmu break elif flag < 0: # interface/tomography domain # velocity model vel=name attrib=cubit.get_block_attribute_value(block,1) if attrib == 1: kind='interface' flag_down=cubit.get_block_attribute_value(block,2) flag_up=cubit.get_block_attribute_value(block,3) elif attrib == 2: kind='tomography' elif nattrib == 1: flag=cubit.get_block_attribute_value(block,0) #print 'only 1 attribute ', name,block,flag vel,vs,rho,qk,qmu,ani=(0,0,0,9999.,9999.,0) else: flag=block vel,vs,rho,qk,qmu,ani=(name,0,0,9999.,9999.,0) block_flag.append(int(flag)) block_mat.append(block) if (flag > 0) and nattrib != 1: par=tuple([imaterial,flag,vel,vs,rho,qk,qmu,ani]) elif flag < 0 and nattrib != 1: if kind=='interface': par=tuple([imaterial,flag,kind,name,flag_down,flag_up]) elif kind=='tomography': par=tuple([imaterial,flag,kind,name]) elif flag==0 or nattrib == 1: par=tuple([imaterial,flag,name]) material[block]=par elif ty == self.face: block_bc_flag.append(4) block_bc.append(block) bc[block]=4 #face has connectivity = 4 if name == self.topo or block == 1001: self.topography=block if self.freetxt in name: self.free=block elif ty == 'SPHERE': pass else: # block elements differ from HEX8/QUAD4/SHELL4 print '****************************************' print 'block not properly defined:' print ' name:',name print ' type:',type print print 'please check your block definitions!' print print 'only supported types are:' print ' HEX/HEX8 for volumes' print ' QUAD4 for surface' print ' SHELL4 for surface' print '****************************************' continue return None, None,None,None,None,None,None,None nsets=cubit.get_nodeset_id_list() if len(nsets) == 0: self.receivers=None for nset in nsets: name=cubit.get_exodus_entity_name('nodeset',nset) if name == self.rec: self.receivers=nset else: print 'nodeset '+name+' not defined' self.receivers=None try: self.block_mat=block_mat self.block_flag=block_flag self.block_bc=block_bc self.block_bc_flag=block_bc_flag self.material=material self.bc=bc print 'HEX Blocks:' for m,f in zip(self.block_mat,self.block_flag): print 'block ',m,'material flag ',f print 'Absorbing Boundary Conditions:' for m,f in zip(self.block_bc,self.block_bc_flag): print 'bc ',m,'bc flag ',f print 'Topography (free surface)' print self.topography print 'Free surface' print self.free except: print '****************************************' print 'sorry, no blocks or blocks not properly defined' print block_mat print block_flag print block_bc print block_bc_flag print material print bc print '****************************************'
def block_definition(self): """ Import blocks features from Cubit """ block_flag = [] # Will contain material id (1 if fluid 2 if solid) block_mat = [] # Will contain face block ids block_bc = [] # Will contain edge block ids block_bc_flag = [] # Will contain edge id -> 2 abs_boun = [-1] * self.nabs # total 4 sides of absorbing boundaries (index 0 : bottom, index 1 : right, index 2 : top, index 3 : left) #pml_boun = [-1] * 6 # To store pml layers id (for each pml layer : x_acoust, z_acoust, xz_acoust, x_elast, z_elast, xz_elast) pml_boun = [[] for _ in range(6)] # To store the block id corresponding to pml layers id (arbitrary number of blocks for each pml layer : x_acoust, z_acoust, xz_acoust, x_elast, z_elast, xz_elast) material = {} # Will contain each material name and their properties bc = {} # Will contains each boundary name and their connectivity -> 2 blocks = cubit.get_block_id_list() # Load the blocks list for block in blocks: # Loop on the blocks name = cubit.get_exodus_entity_name('block',block) # Contains the name of the blocks ty = cubit.get_block_element_type(block) # Contains the block element type (QUAD4...) if ty == self.face: # If we are dealing with a block containing faces nAttributes = cubit.get_block_attribute_count(block) if (nAttributes != 1 and nAttributes != 6): print 'Blocks not properly defined, 2d blocks must have one attribute (material id) or 6 attributes' return None,None,None,None,None,None,None,None flag=int(cubit.get_block_attribute_value(block,0)) # Fetch the first attribute value (containing material id) print "nAttributes : ",nAttributes if nAttributes == 6: self.write_nummaterial_velocity_file = True velP = cubit.get_block_attribute_value(block,1) # Fetch the first attribute value (containing P wave velocity) velS = cubit.get_block_attribute_value(block,2) # Fetch the second attribute value (containing S wave velocity) rho = cubit.get_block_attribute_value(block,3) # Fetch the third attribute value (containing material density) qFlag = cubit.get_block_attribute_value(block,4) # Fetch the first attribute value (containing Qflag) anisotropy_flag = cubit.get_block_attribute_value(block,5) # Fetch the first attribute value (containing anisotropy_flag) # Store (material_id,rho,velP,velS,Qflag,anisotropy_flag) in par : par = tuple([flag,rho,velP,velS,qFlag,anisotropy_flag]) material[name] = par # associate the name of the block to its id and properties block_flag.append(int(flag)) # Append material id to block_flag block_mat.append(block) # Append block id to block_mat if name in self.pml_boun_name : # If the block considered refered to one of the pml layer self.abs_mesh=True self.pml_layers=True pml_boun[self.pml_boun_name.index(name)]=block # -> Put it at the correct position in pml_boun # (index 0 : pml_x_acoust, index 1 : pml_z_acoust, index 2 : pml_xz_acoust, # index 3 : pml_x_elast, index 4 : pml_z_elast, index 5 : pml_xz_elast) elif ty == self.edge: # If we are dealing with a block containing edges block_bc_flag.append(2) # Append "2" to block_bc_flag block_bc.append(block) # Append block id to block_bc bc[name] = 2 # Associate the name of the block with its connectivity : an edge has connectivity = 2 if name == self.topo: self.topo_mesh=True topography=block # If the block considered refered to topography store its id in "topography" if name == self.axisname: self.axisymmetric_mesh = True axisId = block # AXISYM If the block considered refered to the axis store its id in "axisId" if name in self.abs_boun_name : # If the block considered refered to one of the boundaries self.abs_mesh = True abs_boun[self.abs_boun_name.index(name)] = block # -> Put it at the correct position in abs_boun (index 0 : bottom, index 1 : right, index 2 : top, index 3 : left) else: print 'Blocks not properly defined', ty return None,None,None,None,None,None,None,None nsets = cubit.get_nodeset_id_list() # Get the list of all nodeset if len(nsets) == 0: self.receivers = None # If this list is empty : put None in self.receivers for nset in nsets: name = cubit.get_exodus_entity_name('nodeset',nset) # Contains the name of the nodeset if name == self.rec: # If the name considered match self.rec (receivers) self.receivers = nset # Store the id of the nodeset in self.receivers else: print 'nodeset '+name+' not defined' self.receivers = None # Store everything in the object : try: self.block_mat = block_mat self.block_flag = block_flag self.block_bc = block_bc self.block_bc_flag = block_bc_flag self.bc = bc if self.write_nummaterial_velocity_file: self.material = material if self.abs_mesh: self.abs_boun = abs_boun if self.topo_mesh: self.topography = topography if self.axisymmetric_mesh: self.axisId = axisId if self.pml_layers: self.pml_boun = pml_boun except: print 'Blocks not properly defined'
def block_definition(self): block_flag = [] block_mat = [] block_bc = [] block_bc_flag = [] material = {} bc = {} blocks = cubit.get_block_id_list() for block in blocks: name = cubit.get_exodus_entity_name("block", block) type = cubit.get_block_element_type(block) print block, name, blocks, type, self.hex, self.face # block has hexahedral elements (HEX8) if type == self.hex: flag = None vel = None vs = None rho = None q = 0 ani = 0 # material domain id if name.find("acoustic") >= 0: imaterial = 1 elif name.find("elastic") >= 0: imaterial = 2 elif name.find("poroelastic") >= 0: imaterial = 3 else: imaterial = 0 print "block: ", name print " could not find appropriate material for this block..." print "" break nattrib = cubit.get_block_attribute_count(block) if nattrib != 0: # material flag: # positive => material properties, # negative => interface/tomography domain flag = int(cubit.get_block_attribute_value(block, 0)) if flag > 0 and nattrib >= 2: # vp vel = cubit.get_block_attribute_value(block, 1) if nattrib >= 3: # vs vs = cubit.get_block_attribute_value(block, 2) if nattrib >= 4: # density rho = cubit.get_block_attribute_value(block, 3) if nattrib >= 5: # Q_mu q = cubit.get_block_attribute_value(block, 4) # for q to be valid: it must be positive if q < 0: print "error, q value invalid:", q break if nattrib == 6: # only 6 parameters given (skipping Q_kappa ), old format style # Q_kappa is 10 times stronger than Q_mu q2 = q * 10 # last entry is anisotropic flag ani = cubit.get_block_attribute_value(block, 5) elif nattrib > 6: # Q_kappa q2 = cubit.get_block_attribute_value(block, 5) # for q to be valid: it must be positive if q2 < 0: print "error, q value invalid:", q2 break if nattrib == 7: # anisotropy_flag ani = cubit.get_block_attribute_value(block, 6) elif flag < 0: # velocity model vel = name attrib = cubit.get_block_attribute_value(block, 1) if attrib == 1: kind = "interface" flag_down = cubit.get_block_attribute_value(block, 2) flag_up = cubit.get_block_attribute_value(block, 3) elif attrib == 2: kind = "tomography" else: flag = block vel, vs, rho, q, q2, ani = (name, 0, 0, 0, 0, 0) block_flag.append(int(flag)) block_mat.append(block) if flag > 0: par = tuple([imaterial, flag, vel, vs, rho, q, q2, ani]) elif flag < 0: if kind == "interface": par = tuple([imaterial, flag, kind, name, flag_down, flag_up]) elif kind == "tomography": par = tuple([imaterial, flag, kind, name]) elif flag == 0: par = tuple([imaterial, flag, name]) material[block] = par elif (type == self.face) or (type == self.face2): # block has surface elements (QUAD4 or SHELL4) block_bc_flag.append(4) block_bc.append(block) bc[block] = 4 # face has connectivity = 4 if name == self.topo: topography_face = block else: # block elements differ from HEX8/QUAD4/SHELL4 print "****************************************" print "block not properly defined:" print " name:", name print " type:", type print print "please check your block definitions!" print print "only supported types are:" print " HEX8 for volumes" print " QUAD4 for surface" print " SHELL4 for surface" print "****************************************" continue nsets = cubit.get_nodeset_id_list() if len(nsets) == 0: self.receivers = None for nset in nsets: name = cubit.get_exodus_entity_name("nodeset", nset) if name == self.rec: self.receivers = nset else: print "nodeset " + name + " not defined" self.receivers = None try: self.block_mat = block_mat self.block_flag = block_flag self.block_bc = block_bc self.block_bc_flag = block_bc_flag self.material = material self.bc = bc self.topography = topography_face except: print "****************************************" print "sorry, no blocks or blocks not properly defined" print block_mat print block_flag print block_bc print block_bc_flag print material print bc print topography print "****************************************"
def block_definition(self): block_flag = [] block_mat = [] block_bc = [] block_bc_flag = [] material = {} bc = {} blocks = cubit.get_block_id_list() for block in blocks: name = cubit.get_exodus_entity_name('block', block) type = cubit.get_block_element_type(block) print block, name, blocks, type, self.hex, self.face # block has hexahedral elements (HEX8) if type == self.hex: flag = None vel = None vs = None rho = None q = 0 ani = 0 # material domain id if name.find("acoustic") >= 0: imaterial = 1 elif name.find("elastic") >= 0: imaterial = 2 elif name.find("poroelastic") >= 0: imaterial = 3 else: imaterial = 0 print "block: ", name print " could not find appropriate material for this block..." print "" break nattrib = cubit.get_block_attribute_count(block) if nattrib != 0: # material flag: # positive => material properties, # negative => interface/tomography domain flag = int(cubit.get_block_attribute_value(block, 0)) if flag > 0 and nattrib >= 2: # vp vel = cubit.get_block_attribute_value(block, 1) if nattrib >= 3: # vs vs = cubit.get_block_attribute_value(block, 2) if nattrib >= 4: #density rho = cubit.get_block_attribute_value(block, 3) if nattrib >= 5: #Q_kappa qkappa = cubit.get_block_attribute_value( block, 4) # for q to be valid: it must be positive if qkappa < 0: print 'error, qkappa value invalid:', qkappa break if nattrib >= 6: #Q_mu qmu = cubit.get_block_attribute_value( block, 5) # for q to be valid: it must be positive if qmu < 0: print 'error, qmu value invalid:', qmu break if nattrib == 7: #anisotropy_flag ani = cubit.get_block_attribute_value( block, 5) elif flag < 0: # velocity model vel = name attrib = cubit.get_block_attribute_value(block, 1) if attrib == 1: kind = 'interface' flag_down = cubit.get_block_attribute_value( block, 2) flag_up = cubit.get_block_attribute_value(block, 3) elif attrib == 2: kind = 'tomography' else: flag = block vel, vs, rho, qkappa, qmu, ani = (name, 0, 0, 0, 0, 0) block_flag.append(int(flag)) block_mat.append(block) if flag > 0: par = tuple( [imaterial, flag, vel, vs, rho, qkappa, qmu, ani]) elif flag < 0: if kind == 'interface': par = tuple( [imaterial, flag, kind, name, flag_down, flag_up]) elif kind == 'tomography': par = tuple([imaterial, flag, kind, name]) elif flag == 0: par = tuple([imaterial, flag, name]) material[block] = par elif (type == self.face) or (type == self.face2): # block has surface elements (QUAD4 or SHELL4) block_bc_flag.append(4) block_bc.append(block) bc[block] = 4 #face has connectivity = 4 if name == self.topo: topography_face = block else: # block elements differ from HEX8/QUAD4/SHELL4 print '****************************************' print 'block not properly defined:' print ' name:', name print ' type:', type print print 'please check your block definitions!' print print 'only supported types are:' print ' HEX8 for volumes' print ' QUAD4 for surface' print ' SHELL4 for surface' print '****************************************' continue nsets = cubit.get_nodeset_id_list() if len(nsets) == 0: self.receivers = None for nset in nsets: name = cubit.get_exodus_entity_name('nodeset', nset) if name == self.rec: self.receivers = nset else: print 'nodeset ' + name + ' not defined' self.receivers = None try: self.block_mat = block_mat self.block_flag = block_flag self.block_bc = block_bc self.block_bc_flag = block_bc_flag self.material = material self.bc = bc self.topography = topography_face except: print '****************************************' print 'sorry, no blocks or blocks not properly defined' print block_mat print block_flag print block_bc print block_bc_flag print material print bc print topography print '****************************************'
def get_block(self): ''' extract block information ''' block_flag = [] block_mat = [] block_pml = [] block_pmlflag = [] ns_free = [] ns_absorb = [] material = [] # number of blocks blocks = cubit.get_block_id_list() # go through blocks for block in blocks: name = cubit.get_exodus_entity_name('block', block) type = cubit.get_block_element_type(block) print block, name, blocks, type if type == self.tri: # check if elastic if name.find('elastic') >= 0: print('found elastic block') imat = 1 # get number of attributes values = name.split(" ") print values flag = int(values[1]) vp = float(values[2]) vs = float(values[3]) rho = float(values[4]) qp = float(values[5]) qs = float(values[6]) block_flag.append(flag) block_mat.append(block) material.append([imat, vp, vs, rho, qp, qs]) elif name.find('pml') >= 0: ipml = 1 values = name.split(" ") flag = int(values[1]) block_pmlflag.append(flag) block_pml.append(block) else: print('error, no correct material in block', block) ns = cubit.get_nodeset_id_list() for n in ns: name = cubit.get_exodus_entity_name('nodeset', n) if name.find('free') >= 0: print('found free surface nodes') ns_free.append(n) elif name.find('absorb') >= 0: print('found absorb surface nodes') ns_absorb.append(n) else: print('error in boundaries', n) print('BLOCKFLAG', block_flag) self.block_flag = block_flag self.block_mat = block_mat self.block_pml = block_pml self.block_pmlflag = block_pmlflag self.mat = material self.ns_free = ns_free self.ns_absorb = ns_absorb
def get_block(self): ''' extract block information ''' block_flag=[] block_mat=[] block_pml=[] block_pmlflag=[] ns_free=[] ns_absorb=[] material=[] # number of blocks blocks=cubit.get_block_id_list() # go through blocks for block in blocks: name=cubit.get_exodus_entity_name('block',block) type=cubit.get_block_element_type(block) print block,name,blocks,type if type == self.tri: # check if elastic if name.find('elastic') >=0: print('found elastic block') imat=1 # get number of attributes values=name.split(" ") print values flag=int(values[1]) vp=float(values[2]) vs=float(values[3]) rho=float(values[4]) qp=float(values[5]) qs=float(values[6]) pml=float(values[7]) block_flag.append(flag) block_pmlflag.append(pml) block_mat.append(block) material.append([imat,vp,vs,rho,qp,qs]) elif name.find('poro') >=0: print('found poroelastic block') self.poro=True imat=2 # get number of attributes values=name.split(" ") print values flag=int(values[1]) typeid=float(values[2]) rhos=float(values[3]) lambdau=float(values[4]) my=float(values[5]) phi=float(values[6]) kappa=float(values[7]) b=float(values[8]) invT=float(values[9]) invN=float(values[10]) rho1=float(values[11]) S1=float(values[12]) K1=float(values[13]) ny1=float(values[14]) rho2=float(values[15]) S2=float(values[16]) K2=float(values[17]) ny2=float(values[18]) fitting_n=float(values[19]) fitting_chi=float(values[20]) Sr1=float(values[21]) Sr2=float(values[22]) block_flag.append(flag) block_pmlflag.append(0) block_mat.append(block) material.append([imat,typeid,rhos,lambdau,my,phi,kappa,b,invT,invN,rho1,S1,K1,ny1,rho2,S2,K2,ny2,fitting_n,fitting_chi,Sr1,Sr2]) elif name.find('pml') >=0: ipml=1 values=name.split(" ") flag=int(values[1]) block_pmlflag.append(flag) block_pml.append(block) else: print('error, no correct material in block',block) ns=cubit.get_nodeset_id_list() for n in ns: name=cubit.get_exodus_entity_name('nodeset',n) if name.find('free') >=0: print('found free surface nodes') ns_free.append(n) elif name.find('absorb') >=0: print('found absorb surface nodes') ns_absorb.append(n) elif name.find('vtk') >=0: pass else: print('error in boundaries',n) print('BLOCKFLAG',block_flag) self.block_flag=block_flag self.block_mat=block_mat self.block_pml=block_pml self.block_pmlflag=block_pmlflag self.mat=material self.ns_free=ns_free self.ns_absorb=ns_absorb
def block_definition(self): block_flag=[] block_mat=[] block_bc=[] block_bc_flag=[] material={} bc={} blocks=cubit.get_block_id_list() for block in blocks: name=cubit.get_exodus_entity_name('block',block) type=cubit.get_block_element_type(block) print block,name,blocks,type,self.hex,self.face # block has hexahedral elements (HEX8) if type == self.hex: flag=None vel=None vs=None rho=None q=0 ani=0 # material domain id if name.find("acoustic") >= 0 : imaterial = 1 elif name.find("elastic") >= 0 : imaterial = 2 elif name.find("poroelastic") >= 0 : imaterial = 3 else : imaterial = 0 print "block: ",name print " could not find appropriate material for this block..." print "" break nattrib=cubit.get_block_attribute_count(block) if nattrib != 0: # material flag: # positive => material properties, # negative => interface/tomography domain flag=int(cubit.get_block_attribute_value(block,0)) if flag > 0 and nattrib >= 2: # vp vel=cubit.get_block_attribute_value(block,1) if nattrib >= 3: # vs vs=cubit.get_block_attribute_value(block,2) if nattrib >= 4: #density rho=cubit.get_block_attribute_value(block,3) if nattrib >= 5: #Q_mu q=cubit.get_block_attribute_value(block,4) # for q to be valid: it must be positive if q < 0 : print 'error, q value invalid:', q break if nattrib == 6: #anisotropy_flag ani=cubit.get_block_attribute_value(block,5) elif flag < 0: # velocity model vel=name attrib=cubit.get_block_attribute_value(block,1) if attrib == 1: kind='interface' flag_down=cubit.get_block_attribute_value(block,2) flag_up=cubit.get_block_attribute_value(block,3) elif attrib == 2: kind='tomography' else: flag=block vel,vs,rho,q,ani=(name,0,0,0,0) block_flag.append(int(flag)) block_mat.append(block) if flag > 0: par=tuple([imaterial,flag,vel,vs,rho,q,ani]) elif flag < 0: if kind=='interface': par=tuple([imaterial,flag,kind,name,flag_down,flag_up]) elif kind=='tomography': par=tuple([imaterial,flag,kind,name]) elif flag==0: par=tuple([imaterial,flag,name]) material[block]=par elif (type == self.face) or (type == self.face2) : # block has surface elements (QUAD4 or SHELL4) block_bc_flag.append(4) block_bc.append(block) bc[block]=4 #face has connectivity = 4 if name == self.topo: topography_face=block else: # block elements differ from HEX8/QUAD4/SHELL4 print '****************************************' print 'block not properly defined:' print ' name:',name print ' type:',type print print 'please check your block definitions!' print print 'only supported types are:' print ' HEX8 for volumes' print ' QUAD4 for surface' print ' SHELL4 for surface' print '****************************************' continue nsets=cubit.get_nodeset_id_list() if len(nsets) == 0: self.receivers=None for nset in nsets: name=cubit.get_exodus_entity_name('nodeset',nset) if name == self.rec: self.receivers=nset else: print 'nodeset '+name+' not defined' self.receivers=None try: self.block_mat=block_mat self.block_flag=block_flag self.block_bc=block_bc self.block_bc_flag=block_bc_flag self.material=material self.bc=bc self.topography=topography_face except: print '****************************************' print 'sorry, no blocks or blocks not properly defined' print block_mat print block_flag print block_bc print block_bc_flag print material print bc print topography print '****************************************'
def block_definition(self): block_flag=[] block_mat=[] block_bc=[] block_bc_flag=[] material={} bc={} blocks=cubit.get_block_id_list() for block in blocks: name=cubit.get_exodus_entity_name('block',block) ty=cubit.get_block_element_type(block) #print block,blocks,ty,self.hex,self.face if self.hex in ty: nattrib=cubit.get_block_attribute_count(block) flag=None vel=None vs=None rho=None q=0 ani=0 # material domain id if "acoustic" in name : imaterial = 1 elif "elastic" in name: imaterial = 2 elif "poroelastic" in name: imaterial = 3 else : imaterial = 0 # if nattrib > 1: # material flag: # positive => material properties, # negative => interface/tomography domain flag=int(cubit.get_block_attribute_value(block,0)) if flag > 0 and nattrib >= 2: vel=cubit.get_block_attribute_value(block,1) if nattrib >= 3: vs=cubit.get_block_attribute_value(block,2) if nattrib >= 4: rho=cubit.get_block_attribute_value(block,3) if nattrib >= 5: q=cubit.get_block_attribute_value(block,4) # for q to be valid: it must be positive if q < 0 : print 'error, q value invalid:', q break if nattrib == 6: ani=cubit.get_block_attribute_value(block,5) elif flag < 0: vel=name attrib=cubit.get_block_attribute_value(block,1) if attrib == 1: kind='interface' flag_down=cubit.get_block_attribute_value(block,2) flag_up=cubit.get_block_attribute_value(block,3) elif attrib == 2: kind='tomography' elif nattrib == 1: flag=cubit.get_block_attribute_value(block,0) print 'only 1 attribute ', name,block,flag vel,vs,rho,q,ani=(0,0,0,0,0) else: flag=block vel,vs,rho,q,ani=(name,0,0,0,0) block_flag.append(int(flag)) block_mat.append(block) if flag > 0 and nattrib != 1: par=tuple([imaterial,flag,vel,vs,rho,q,ani]) elif flag < 0 and nattrib != 1: if kind=='interface': par=tuple([imaterial,flag,kind,name,flag_down,flag_up]) elif kind=='tomography': par=tuple([imaterial,flag,kind,name]) elif flag==0 or nattrib == 1: par=tuple([imaterial,flag,name]) material[block]=par elif ty == self.face: #Stacey condition, we need hex here for pml block_bc_flag.append(4) block_bc.append(block) bc[block]=4 #face has connectivity = 4 if name == self.topo or block == 1001: topography_face=block elif ty == 'SPHERE': pass else: # block elements differ from HEX8/QUAD4/SHELL4 print '****************************************' print 'block not properly defined:' print ' name:',name print ' type:',type print print 'please check your block definitions!' print print 'only supported types are:' print ' HEX/HEX8 for volumes' print ' QUAD4 for surface' print ' SHELL4 for surface' print '****************************************' continue return None, None,None,None,None,None,None,None nsets=cubit.get_nodeset_id_list() if len(nsets) == 0: self.receivers=None for nset in nsets: name=cubit.get_exodus_entity_name('nodeset',nset) if name == self.rec: self.receivers=nset else: print 'nodeset '+name+' not defined' self.receivers=None print block_mat print block_flag print block_bc print block_bc_flag print material print bc print topography_face # try: self.block_mat=block_mat self.block_flag=block_flag self.block_bc=block_bc self.block_bc_flag=block_bc_flag self.material=material self.bc=bc self.topography=topography_face except: print '****************************************' print 'sorry, no blocks or blocks not properly defined' print block_mat print block_flag print block_bc print block_bc_flag print material print bc print topography print '****************************************'