forked from SPECFEM/specfem3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'devel' of https://github.com/geodynamics/specfem3d into…
… devel
- Loading branch information
Showing
1,029 changed files
with
20,979 additions
and
13,182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
CUBIT_GEOCUBIT/geocubitlib/save_fault_nodes_elements.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
#!python | ||
# Opening fault cracks | ||
# Input : surface up and down. | ||
import cubit | ||
|
||
class fault_input: | ||
def __init__(self,id,surface_u,surface_d): | ||
self.id = id | ||
self.surface_u = surface_u | ||
self.surface_d = surface_d | ||
self.name = 'MESH/fault_file_'+str(id)+'.dat' | ||
|
||
quads_Aup,quads_Adp = save_cracks(self.name,self.surface_u,self.surface_d) | ||
#Unpacking list. | ||
quads_Au=unpack_list(quads_Aup) | ||
quads_Ad=unpack_list(quads_Adp) | ||
|
||
print 'len(Au):',len(quads_Au) | ||
print 'len(Ad):',len(quads_Ad) | ||
|
||
if not (len(quads_Au)==len(quads_Ad)): | ||
print 'Number of elements for each fauld side up and down do not concide' | ||
sys.exit('goodbye') | ||
|
||
save_elements_nodes(self.name,quads_Au,quads_Ad) | ||
|
||
|
||
def save_cracks(name,list_surface_up,list_surface_down): | ||
quads_fault_up = [] | ||
quads_fault_down = [] | ||
for surface in list_surface_up : | ||
quads_fault = cubit.get_surface_quads(surface) | ||
quads_fault_up.append(quads_fault) | ||
for surface in list_surface_down : | ||
quads_fault = cubit.get_surface_quads(surface) | ||
quads_fault_down.append(quads_fault) | ||
# TO DO : stop python properly in case fault nodes at both sides | ||
# do not match. | ||
# if len(quads_fault_u) != len(quads_fault_d): stop | ||
# | ||
# SAVING FAULT ELEMENTS AND NODES | ||
return quads_fault_up,quads_fault_down | ||
|
||
def unpack_list(fault_list): | ||
list_fault = [] | ||
for i in range(0,len(fault_list)): | ||
el=list(fault_list[i]) | ||
for j in el: | ||
list_fault.append(j) | ||
return list_fault | ||
|
||
def save_elements_nodes(name,quads_fault_u,quads_fault_d): | ||
fault_file = open(name,'w') | ||
txt ='' | ||
list_hex=cubit.parse_cubit_list('hex','all') | ||
txt='%10i %10i\n' % (len(quads_fault_u),len(quads_fault_d)) | ||
fault_file.write(txt) | ||
|
||
dic_quads_fault_u = dict(zip(quads_fault_u,quads_fault_u)) | ||
dic_quads_fault_d = dict(zip(quads_fault_d,quads_fault_d)) | ||
|
||
# FAULT SIDE DOWN | ||
# fault_file.write('upsurface') | ||
for h in list_hex: | ||
faces = cubit.get_sub_elements('hex',h,2) | ||
for f in faces: | ||
if dic_quads_fault_d.has_key(f): | ||
cubit.silent_cmd('group "nf" add Node in face '+str(f)) | ||
group1 = cubit.get_id_from_name("nf") | ||
nodes = cubit.get_group_nodes(group1) | ||
cubit.silent_cmd('del group '+ str(group1)) | ||
# nodes=cubit.get_connectivity('Face',f) | ||
# print 'h,fault nodes side down :',h,nodes[0],nodes[1],nodes[2],nodes[3] | ||
# txt='%10i %10i %10i %10i %10i\n' % (h,nodes[0],\ | ||
# nodes[1],nodes[2],nodes[3]) | ||
ngnod2d = len(nodes) | ||
if ngnod2d == 9: | ||
#kangchen added txt='%10i %10i %10i %10i %10i\n' % (h,nodes[0],\ | ||
# nodes[1],nodes[2],nodes[3]) | ||
txt='%10i %10i %10i %10i %10i %10i %10i %10i %10i %10i\n' % (h,nodes[0],\ | ||
nodes[1],nodes[2],nodes[3],nodes[4],nodes[5],nodes[6],nodes[7],nodes[8]) | ||
else: | ||
txt='%10i %10i %10i %10i %10i \n' % (h,nodes[0],\ | ||
nodes[1],nodes[2],nodes[3]) | ||
|
||
|
||
|
||
|
||
fault_file.write(txt) | ||
|
||
# FAULT SIDE UP | ||
# fault_file.write('downsurface') | ||
for h in list_hex: | ||
faces = cubit.get_sub_elements('hex',h,2) | ||
for f in faces: | ||
if dic_quads_fault_u.has_key(f): | ||
cubit.silent_cmd('group "nf" add Node in face '+str(f)) | ||
group1 = cubit.get_id_from_name("nf") | ||
nodes = cubit.get_group_nodes(group1) | ||
cubit.cmd('del group '+ str(group1)) | ||
ngnod2d=len(nodes) | ||
if ngnod2d == 9: | ||
# nodes=cubit.get_connectivity('Face',f) | ||
# print 'h,fault nodes side up :',h,nodes[0],nodes[1],nodes[2],nodes[3] | ||
#kangchen added txt='%10i %10i %10i %10i %10i\n' % (h,nodes[0],\ | ||
# nodes[1],nodes[2],nodes[3]) | ||
txt='%10i %10i %10i %10i %10i %10i %10i %10i %10i %10i\n' % (h,nodes[0],\ | ||
nodes[1],nodes[2],nodes[3],nodes[4],nodes[5],nodes[6],nodes[7],nodes[8]) | ||
else: | ||
txt='%10i %10i %10i %10i %10i \n' % (h,nodes[0],\ | ||
nodes[1],nodes[2],nodes[3]) | ||
|
||
|
||
|
||
fault_file.write(txt) | ||
|
||
fault_file.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.