Skip to content

Commit 151b253

Browse files
committed
moves routines to save mesh as cubit to file save_mesh_as_cubit.f90 (for in-house mesher); code cleaning
1 parent c5d29e9 commit 151b253

10 files changed

+1022
-982
lines changed

src/decompose_mesh/part_decompose_mesh.F90

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,8 @@ end subroutine write_material_props_database
613613
! discontinuity interface
614614
!-------------------------------------------------
615615
subroutine write_wavefield_discontinuity_database(iproc, outputpath_name, &
616-
nb_wd, boundary_to_ispec_wd, side_wd, &
617-
nspec, glob2loc_elmnts, part)
616+
nb_wd, boundary_to_ispec_wd, side_wd, &
617+
nspec, glob2loc_elmnts, part)
618618
use constants, only: FNAME_WAVEFIELD_DISCONTINUITY_MESH, &
619619
IFILE_WAVEFIELD_DISCONTINUITY, MAX_STRING_LEN
620620
implicit none
@@ -630,11 +630,13 @@ subroutine write_wavefield_discontinuity_database(iproc, outputpath_name, &
630630
local_side_wd
631631
character(len=MAX_STRING_LEN), intent(in) :: outputpath_name
632632
character(len=MAX_STRING_LEN) :: prname
633+
633634
write(prname, "('proc',i6.6,'_')") iproc
634635
open(unit=IFILE_WAVEFIELD_DISCONTINUITY, &
635636
file = trim(outputpath_name)//'/'//trim(prname)//&
636637
trim(FNAME_WAVEFIELD_DISCONTINUITY_MESH), &
637638
form='unformatted', action='write')
639+
638640
local_nb_wd = 0
639641
do ib = 1, nb_wd
640642
ispec = boundary_to_ispec_wd(ib)
@@ -643,7 +645,9 @@ subroutine write_wavefield_discontinuity_database(iproc, outputpath_name, &
643645
local_nb_wd = local_nb_wd + 1
644646
endif
645647
enddo
648+
646649
print *, 'partition', iproc, ' has ', local_nb_wd, ' elements on wavefield discontinuity interface'
650+
647651
allocate(local_boundary_to_ispec_wd(local_nb_wd))
648652
allocate(local_side_wd(local_nb_wd))
649653
local_nb_wd = 0
@@ -656,11 +660,15 @@ subroutine write_wavefield_discontinuity_database(iproc, outputpath_name, &
656660
local_side_wd(local_nb_wd) = iside
657661
endif
658662
enddo
663+
659664
write(IFILE_WAVEFIELD_DISCONTINUITY) local_nb_wd
660665
write(IFILE_WAVEFIELD_DISCONTINUITY) local_boundary_to_ispec_wd
661666
write(IFILE_WAVEFIELD_DISCONTINUITY) local_side_wd
667+
662668
close(IFILE_WAVEFIELD_DISCONTINUITY)
669+
663670
deallocate(local_boundary_to_ispec_wd, local_side_wd)
671+
664672
end subroutine write_wavefield_discontinuity_database
665673

666674

src/decompose_mesh/write_mesh_databases.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ subroutine write_mesh_databases()
202202
endif
203203

204204

205-
!! setting up wavefield discontinuity boundary
205+
! setting up wavefield discontinuity boundary
206206
if (IS_WAVEFIELD_DISCONTINUITY) then
207207
do ipart = 0, nparts-1
208208
call write_wavefield_discontinuity_database(ipart, outputpath_name, &
209-
nb_wd, boundary_to_ispec_wd, side_wd, &
210-
nspec, glob2loc_elmnts, part)
209+
nb_wd, boundary_to_ispec_wd, side_wd, &
210+
nspec, glob2loc_elmnts, part)
211211
enddo
212212
endif
213213

src/meshfem3D/create_CPML_regions.f90

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ subroutine create_CPML_regions(nglob)
3636
! create the different regions of the mesh
3737
use constants, only: IMAIN,CUSTOM_REAL,SMALL_PERCENTAGE_TOLERANCE, &
3838
CPML_X_ONLY,CPML_Y_ONLY,CPML_Z_ONLY,CPML_XY_ONLY,CPML_XZ_ONLY,CPML_YZ_ONLY,CPML_XYZ, &
39-
PI,TINYVAL,HUGEVAL,MAX_STRING_LEN,NDIM,myrank
39+
PI,HUGEVAL,MAX_STRING_LEN,myrank
4040

4141
use constants_meshfem, only: NGLLX_M,NGLLY_M,NGLLZ_M
4242

@@ -434,11 +434,11 @@ subroutine create_CPML_regions(nglob)
434434
write(IMAIN,*)
435435
! converts to degrees
436436
if (.not. SUPPRESS_UTM_PROJECTION) then
437-
write(IMAIN,'(a,f8.5,a,f8.5)') ' min/max element size along X sides (in degree) = ',&
437+
write(IMAIN,'(a,f8.5,a,f8.5)') ' min/max element size along X sides (in degree) = ', &
438438
sngl(elem_size_x_min*METERS_TO_DEGREES),'/',sngl(elem_size_x_max*METERS_TO_DEGREES)
439-
write(IMAIN,'(a,f8.5,a,f8.5)') ' min/max element size along Y sides (in degree) = ',&
439+
write(IMAIN,'(a,f8.5,a,f8.5)') ' min/max element size along Y sides (in degree) = ', &
440440
sngl(elem_size_y_min*METERS_TO_DEGREES),'/',sngl(elem_size_y_max*METERS_TO_DEGREES)
441-
write(IMAIN,'(a,f8.5,a,f8.5)') ' min/max element size along Z sides (in degree) = ',&
441+
write(IMAIN,'(a,f8.5,a,f8.5)') ' min/max element size along Z sides (in degree) = ', &
442442
sngl(elem_size_z_min*METERS_TO_DEGREES),'/',sngl(elem_size_z_max*METERS_TO_DEGREES)
443443
write(IMAIN,*)
444444
endif
@@ -525,9 +525,9 @@ subroutine add_CPML_region_as_extra_layers(nglob)
525525
UTM_X_MIN,UTM_X_MAX
526526

527527
! create the different regions of the mesh
528-
use constants, only: IMAIN,CUSTOM_REAL,SMALL_PERCENTAGE_TOLERANCE, &
528+
use constants, only: IMAIN, &
529529
CPML_X_ONLY,CPML_Y_ONLY,CPML_Z_ONLY,CPML_XY_ONLY,CPML_XZ_ONLY,CPML_YZ_ONLY,CPML_XYZ, &
530-
PI,TINYVAL,HUGEVAL,MAX_STRING_LEN,NDIM,myrank, &
530+
MAX_STRING_LEN,NDIM,myrank, &
531531
GAUSSALPHA,GAUSSBETA
532532

533533
use constants_meshfem, only: NGLLX_M,NGLLY_M,NGLLZ_M
@@ -617,7 +617,7 @@ subroutine add_CPML_region_as_extra_layers(nglob)
617617
integer :: elem_mapping(NGNOD)
618618
logical :: is_mapped(NGNOD)
619619
! MPI Cartesian topology uses W for West (= XI_MIN), E for East (= XI_MAX), S for South (= ETA_MIN), N for North (= ETA_MAX)
620-
integer, parameter :: W = 1,E = 2,S = 3,N = 4,B = 5,T = 6 ! B==Bottom, T==Top
620+
integer, parameter :: W = 1,E = 2,S = 3,N = 4,B = 5,T = 6 ! B == Bottom, T == Top
621621

622622
integer :: p1,p2,p3,p4,p5,p6,p7,p8,p9,ia,iglob
623623
integer :: factor_x,factor_y,factor_z

src/meshfem3D/create_meshfem_mesh.f90

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,13 @@ subroutine create_meshfem_mesh()
8383
! HDF5 file i/o
8484
use shared_parameters, only: HDF5_ENABLED
8585

86-
!! setting up wavefield discontinuity interface
86+
! setting up wavefield discontinuity interface
8787
use shared_parameters, only: IS_WAVEFIELD_DISCONTINUITY
8888

89+
! CUBIT output
90+
use shared_parameters, only: COUPLE_WITH_INJECTION_TECHNIQUE
91+
use meshfem_par, only: SAVE_MESH_AS_CUBIT
92+
8993
implicit none
9094

9195
! local parameters
@@ -194,6 +198,28 @@ subroutine create_meshfem_mesh()
194198
ibelm_xmin,ibelm_xmax,ibelm_ymin,ibelm_ymax,ibelm_bottom,ibelm_top)
195199
endif
196200

201+
! CUBIT output
202+
if (SAVE_MESH_AS_CUBIT) then
203+
! add outputs as CUBIT
204+
call save_mesh_files_as_cubit(nspec,nglob, &
205+
nodes_coords, ispec_material_id, &
206+
nspec2D_xmin,nspec2D_xmax,nspec2D_ymin,nspec2D_ymax, &
207+
ibelm_xmin,ibelm_xmax,ibelm_ymin,ibelm_ymax,ibelm_bottom,ibelm_top)
208+
209+
! output for AxiSEM coupling
210+
if (COUPLE_WITH_INJECTION_TECHNIQUE) then
211+
call save_mesh_files_for_coupled_model(nspec, &
212+
nspec2D_xmin,nspec2D_xmax,nspec2D_ymin,nspec2D_ymax, &
213+
ibelm_xmin,ibelm_xmax,ibelm_ymin,ibelm_ymax,ibelm_bottom,ibelm_top, &
214+
xstore,ystore,zstore)
215+
endif
216+
endif
217+
218+
! setting up wavefield discontinuity interface
219+
if (IS_WAVEFIELD_DISCONTINUITY) then
220+
call write_wavefield_discontinuity_database()
221+
endif
222+
197223
! re-assign back actual number of elements and nodes
198224
NSPEC_AB = nspec
199225
NGLOB_AB = nglob

src/meshfem3D/get_wavefield_discontinuity.f90

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,51 +27,64 @@
2727

2828

2929
subroutine write_wavefield_discontinuity_database()
30+
3031
! write data related to wavefield discontinuity to proc*_Database
32+
3133
use meshfem_par, only: nb_wd, boundary_to_ispec_wd, side_wd, prname
3234
use constants, only: FNAME_WAVEFIELD_DISCONTINUITY_MESH, &
3335
IFILE_WAVEFIELD_DISCONTINUITY
3436
implicit none
35-
! local variables
37+
3638
open(unit=IFILE_WAVEFIELD_DISCONTINUITY, &
3739
file = prname(1:len_trim(prname))//&
3840
trim(FNAME_WAVEFIELD_DISCONTINUITY_MESH), &
3941
form='unformatted', action='write')
42+
4043
write(IFILE_WAVEFIELD_DISCONTINUITY) nb_wd
4144
write(IFILE_WAVEFIELD_DISCONTINUITY) boundary_to_ispec_wd
4245
write(IFILE_WAVEFIELD_DISCONTINUITY) side_wd
46+
4347
close(IFILE_WAVEFIELD_DISCONTINUITY)
48+
4449
end subroutine write_wavefield_discontinuity_database
4550

4651
!
4752
!-----------------------------------------------------------
4853
!
4954

5055
subroutine write_wavefield_discontinuity_file()
56+
5157
! write wavefield discontinuity interfaces to an ascii file
5258
! works only when NPROC = 1
59+
5360
use meshfem_par, only: nb_wd, boundary_to_ispec_wd, side_wd
5461
use constants, only: IFILE_WAVEFIELD_DISCONTINUITY, &
5562
FNAME_WAVEFIELD_DISCONTINUITY_INTERFACE
5663
implicit none
5764
! local variables
5865
integer :: i
66+
5967
open(unit=IFILE_WAVEFIELD_DISCONTINUITY, &
6068
file='MESH/'//trim(FNAME_WAVEFIELD_DISCONTINUITY_INTERFACE), &
6169
form='formatted', action='write')
70+
6271
do i = 1, nb_wd
6372
write(IFILE_WAVEFIELD_DISCONTINUITY, *) boundary_to_ispec_wd(i), side_wd(i)
6473
enddo
74+
6575
close(IFILE_WAVEFIELD_DISCONTINUITY)
76+
6677
end subroutine write_wavefield_discontinuity_file
6778

6879
!
6980
!-----------------------------------------------------------
7081
!
7182

7283
subroutine find_wavefield_discontinuity_elements()
84+
7385
! read the wavefield_discontinuity_box file
7486
! find the wavefield discontinuity interface
87+
7588
use constants, only: IFILE_WAVEFIELD_DISCONTINUITY, &
7689
FNAME_WAVEFIELD_DISCONTINUITY_BOX
7790
use meshfem_par, only: xstore,ystore,zstore,nspec
@@ -90,6 +103,7 @@ subroutine find_wavefield_discontinuity_elements()
90103
open(unit=IFILE_WAVEFIELD_DISCONTINUITY, &
91104
file=trim(FNAME_WAVEFIELD_DISCONTINUITY_BOX), &
92105
form='formatted', action='read')
106+
93107
read(IFILE_WAVEFIELD_DISCONTINUITY, *) IS_TOP_WAVEFIELD_DISCONTINUITY
94108
read(IFILE_WAVEFIELD_DISCONTINUITY, *) IS_EXTRAPOLATION_MODE
95109
read(IFILE_WAVEFIELD_DISCONTINUITY, *) x_min
@@ -98,7 +112,9 @@ subroutine find_wavefield_discontinuity_elements()
98112
read(IFILE_WAVEFIELD_DISCONTINUITY, *) y_max
99113
read(IFILE_WAVEFIELD_DISCONTINUITY, *) z_min
100114
read(IFILE_WAVEFIELD_DISCONTINUITY, *) z_max
115+
101116
close(IFILE_WAVEFIELD_DISCONTINUITY)
117+
102118
nb_wd = 0
103119
do ispec = 1, nspec
104120
covered(:) = .false.
@@ -473,9 +489,11 @@ subroutine find_wavefield_discontinuity_elements()
473489
endif
474490
endif
475491
enddo
492+
476493
allocate(boundary_to_ispec_wd(nb_wd), side_wd(nb_wd))
477494
boundary_to_ispec_wd(1:nb_wd) = boundary_to_ispec_wd_temp(1:nb_wd)
478495
side_wd(1:nb_wd) = side_wd_temp(1:nb_wd)
496+
479497
end subroutine find_wavefield_discontinuity_elements
480498

481499
!
@@ -490,7 +508,9 @@ logical function is_boundary_wd(x, y, z, x_min, x_max, y_min, y_max, &
490508
double precision :: x_min, x_max, y_min, y_max, z_min, z_max
491509
double precision :: x, y, z, x_mid, y_mid, z_mid, dx, dy, dz
492510
logical :: IS_TOP_WAVEFIELD_DISCONTINUITY, IS_EXTRAPOLATION_MODE
511+
493512
is_boundary_wd = .false.
513+
494514
if (IS_EXTRAPOLATION_MODE) then
495515
if (((x > x_min - dx) .and. (x < x_max + dx) .and. &
496516
(y > y_min - dy) .and. (y < y_max + dy) .and. &
@@ -510,4 +530,5 @@ logical function is_boundary_wd(x, y, z, x_min, x_max, y_min, y_max, &
510530
(z_mid < z_max))) &
511531
is_boundary_wd = .true.
512532
endif
533+
513534
end function is_boundary_wd

src/meshfem3D/read_mesh_parameter_file.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ subroutine read_mesh_parameter_file()
323323
endif
324324
endif
325325
call synchronize_all()
326-
326+
327327
! set time step and radial distribution of elements
328328
! right distribution is determined based upon maximum value of NEX
329329
NEX_MAX = max(NEX_XI,NEX_ETA)

src/meshfem3D/rules.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ meshfem3D_OBJECTS = \
6464
$O/read_value_mesh_parameters.mesh.o \
6565
$O/save_databases.mesh.o \
6666
$O/save_databases_hdf5.mesh_hdf5.o \
67+
$O/save_mesh_as_cubit.mesh.o \
6768
$O/store_boundaries.mesh.o \
6869
$O/store_coords.mesh.o \
6970
$(EMPTY_MACRO)

0 commit comments

Comments
 (0)