Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates postscript plotting; updates submodules and readme #1246

Merged
merged 4 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ compiler: gcc
# deprecated
#sudo: required

# turns off submodule fetching by default
git:
submodules: false

env:
global:
- FC=gfortran
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ involved in the community and keep them in the specfem3d github wiki:
[specfem3d wiki](https://github.com/SPECFEM/specfem3d/wiki)


## Our contributors :sparkles:

[![SPECFEM2D contributors](https://contrib.rocks/image?repo=SPECFEM/specfem2d)](https://github.com/SPECFEM/specfem2d/graphs/contributors)


## Computational Infrastructure for Geodynamics (CIG)

SPECFEM2D is part of the software that is hosted by the Computational Infrastructure for Geodynamics (CIG). It is available on the CIG website [here (SPECFEM2D)](https://geodynamics.org/resources/specfem2d).
2 changes: 1 addition & 1 deletion m4
Submodule m4 updated 1 files
+1 −1 cit_numpy.m4
1 change: 1 addition & 0 deletions src/meshfem2D/repartition_coupling.f90
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@
! user output
write(IMAIN,*) 'done detecting points for periodic boundary conditions.'
write(IMAIN,*) 'number of periodic elements found and grouped in the same partition: ',count(is_periodic)
write(IMAIN,*)

Check warning on line 436 in src/meshfem2D/repartition_coupling.f90

View check run for this annotation

Codecov / codecov/patch

src/meshfem2D/repartition_coupling.f90#L436

Added line #L436 was not covered by tests
call flush_IMAIN()

! loop on all the elements to find the first partition that contains a periodic element
Expand Down
59 changes: 44 additions & 15 deletions src/specfem2D/plot_post.F90
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
fluid_solid_acoustic_ispec,fluid_solid_acoustic_iedge,num_fluid_solid_edges, &
fluid_poro_acoustic_ispec,fluid_poro_acoustic_iedge,num_fluid_poro_edges, &
solid_poro_poroelastic_ispec,solid_poro_poroelastic_iedge,num_solid_poro_edges, &
myrank,NPROC
myrank,NPROC, &
P_SV

use shared_parameters, only: subsamp_postscript,imagetype_postscript,interpol, &
meshvect,modelvect, &
Expand Down Expand Up @@ -192,7 +193,12 @@
ratio_page = min(rpercentz*sizez/(zmax-zmin),rpercentx*sizex/(xmax-xmin)) / 100.d0

! compute the maximum of the norm of the vector
dispmax = maxval(sqrt(vector_field_display(1,:)**2 + vector_field_display(2,:)**2))
if (P_SV) then
dispmax = maxval(sqrt(vector_field_display(1,:)**2 + vector_field_display(2,:)**2))
else
! SH (membrane) waves, plot y-component
dispmax = maxval(abs(vector_field_display(1,:)))

Check warning on line 200 in src/specfem2D/plot_post.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/plot_post.F90#L200

Added line #L200 was not covered by tests
endif

call max_all_all_dp(dispmax, dispmax_glob)
dispmax = dispmax_glob
Expand Down Expand Up @@ -1516,22 +1522,39 @@
Uxinterp(i,j) = 0.d0
Uzinterp(i,j) = 0.d0

do k = 1,NGLLX
do l= 1,NGLLX
if (AXISYM) then
if (is_on_the_axis(ispec)) then
Uxinterp(i,j) = Uxinterp(i,j) + vector_field_display(1,ibool(k,l,ispec))*flagrange_GLJ(k,i)*flagrange_GLJ(l,j)
Uzinterp(i,j) = Uzinterp(i,j) + vector_field_display(2,ibool(k,l,ispec))*flagrange_GLJ(k,i)*flagrange_GLJ(l,j)
if (P_SV) then
do k = 1,NGLLX
do l= 1,NGLLX
if (AXISYM) then
if (is_on_the_axis(ispec)) then
Uxinterp(i,j) = Uxinterp(i,j) + vector_field_display(1,ibool(k,l,ispec))*flagrange_GLJ(k,i)*flagrange_GLJ(l,j)
Uzinterp(i,j) = Uzinterp(i,j) + vector_field_display(2,ibool(k,l,ispec))*flagrange_GLJ(k,i)*flagrange_GLJ(l,j)

Check warning on line 1531 in src/specfem2D/plot_post.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/plot_post.F90#L1529-L1531

Added lines #L1529 - L1531 were not covered by tests
else
Uxinterp(i,j) = Uxinterp(i,j) + vector_field_display(1,ibool(k,l,ispec))*flagrange(k,i)*flagrange(l,j)
Uzinterp(i,j) = Uzinterp(i,j) + vector_field_display(2,ibool(k,l,ispec))*flagrange(k,i)*flagrange(l,j)

Check warning on line 1534 in src/specfem2D/plot_post.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/plot_post.F90#L1533-L1534

Added lines #L1533 - L1534 were not covered by tests
endif
else
Uxinterp(i,j) = Uxinterp(i,j) + vector_field_display(1,ibool(k,l,ispec))*flagrange(k,i)*flagrange(l,j)
Uzinterp(i,j) = Uzinterp(i,j) + vector_field_display(2,ibool(k,l,ispec))*flagrange(k,i)*flagrange(l,j)
endif
else
Uxinterp(i,j) = Uxinterp(i,j) + vector_field_display(1,ibool(k,l,ispec))*flagrange(k,i)*flagrange(l,j)
Uzinterp(i,j) = Uzinterp(i,j) + vector_field_display(2,ibool(k,l,ispec))*flagrange(k,i)*flagrange(l,j)
endif
enddo
enddo
enddo
else
! SH (membrane) waves, plot y-component
do k = 1,NGLLX
do l= 1,NGLLX
if (AXISYM) then
if (is_on_the_axis(ispec)) then
Uxinterp(i,j) = Uxinterp(i,j) + vector_field_display(1,ibool(k,l,ispec))*flagrange_GLJ(k,i)*flagrange_GLJ(l,j)

Check warning on line 1548 in src/specfem2D/plot_post.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/plot_post.F90#L1544-L1548

Added lines #L1544 - L1548 were not covered by tests
else
Uxinterp(i,j) = Uxinterp(i,j) + vector_field_display(1,ibool(k,l,ispec))*flagrange(k,i)*flagrange(l,j)

Check warning on line 1550 in src/specfem2D/plot_post.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/plot_post.F90#L1550

Added line #L1550 was not covered by tests
endif
else
Uxinterp(i,j) = Uxinterp(i,j) + vector_field_display(1,ibool(k,l,ispec))*flagrange(k,i)*flagrange(l,j)

Check warning on line 1553 in src/specfem2D/plot_post.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/plot_post.F90#L1553

Added line #L1553 was not covered by tests
endif
enddo
enddo
endif

x1 =(xinterp(i,j)-xmin)*ratio_page
z1 =(zinterp(i,j)-zmin)*ratio_page
Expand Down Expand Up @@ -1672,8 +1695,14 @@
z1 =(coord(2,ipoin)-zmin)*ratio_page

if (dispmax > 0.d0) then
x2 = vector_field_display(1,ipoin)*sizemax_arrows/dispmax
z2 = vector_field_display(2,ipoin)*sizemax_arrows/dispmax
if (P_SV) then
x2 = vector_field_display(1,ipoin)*sizemax_arrows/dispmax
z2 = vector_field_display(2,ipoin)*sizemax_arrows/dispmax

Check warning on line 1700 in src/specfem2D/plot_post.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/plot_post.F90#L1698-L1700

Added lines #L1698 - L1700 were not covered by tests
else
! SH (membrane) waves, plot y-component
x2 = vector_field_display(1,ipoin)*sizemax_arrows/dispmax
z2 = 0.d0

Check warning on line 1704 in src/specfem2D/plot_post.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/plot_post.F90#L1703-L1704

Added lines #L1703 - L1704 were not covered by tests
endif
else
x2 = 0.d0
z2 = 0.d0
Expand Down
52 changes: 38 additions & 14 deletions src/specfem2D/setup_mesh.F90
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
#else
write(IMAIN,*) 'Exact total number of grid points in the mesh: ',nglob_total
#endif
write(IMAIN,*)

! percentage of elements with 2 degrees of freedom per point
ratio_2DOFs = (nspec_total - nspec_acoustic_total) / dble(nspec_total)
Expand All @@ -145,7 +146,6 @@
nb_elastic_DOFs = nint(nglob_total*ratio_2DOFs*2)

if (P_SV) then
write(IMAIN,*)
write(IMAIN,*) 'Approximate number of acoustic degrees of freedom in the mesh: ',nb_acoustic_DOFs
write(IMAIN,*) 'Approximate number of elastic degrees of freedom in the mesh: ',nb_elastic_DOFs
write(IMAIN,*) ' (there are 2 degrees of freedom per point for elastic elements)'
Expand Down Expand Up @@ -350,7 +350,7 @@
! local parameters
integer :: ispec,i,j,iglob,iglob2,ier
double precision :: xmaxval,xminval,ymaxval,yminval,xtol,xtypdist
integer :: counter
integer :: counter,counter_all

! allocate an array to make sure that an acoustic free surface is not enforced on periodic edges
allocate(this_ibool_is_a_periodic_edge(NGLOB),stat=ier)
Expand All @@ -362,19 +362,20 @@
if (ADD_PERIODIC_CONDITIONS) then
! user output
if (myrank == 0) then
write(IMAIN,*)
write(IMAIN,*) 'implementing periodic boundary conditions'
write(IMAIN,*) 'in the horizontal direction with a periodicity distance of ',PERIODIC_HORIZ_DIST,' m'
write(IMAIN,*) 'Periodic boundary conditions:'
write(IMAIN,*) ' implementing periodic boundary conditions'
write(IMAIN,*) ' in the horizontal direction with a periodicity distance of ',sngl(PERIODIC_HORIZ_DIST),' m'

Check warning on line 367 in src/specfem2D/setup_mesh.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/setup_mesh.F90#L365-L367

Added lines #L365 - L367 were not covered by tests
if (PERIODIC_HORIZ_DIST <= 0.d0) call stop_the_code( &
'PERIODIC_HORIZ_DIST should be greater than zero when using ADD_PERIODIC_CONDITIONS')
write(IMAIN,*)
write(IMAIN,*) '*****************************************************************'
write(IMAIN,*) '*****************************************************************'
write(IMAIN,*) '**** BEWARE: because of periodic conditions, values computed ****'
write(IMAIN,*) '**** by check_grid() below will not be reliable ****'
write(IMAIN,*) '*****************************************************************'
write(IMAIN,*) '*****************************************************************'
write(IMAIN,*) ' *****************************************************************'
write(IMAIN,*) ' *****************************************************************'
write(IMAIN,*) ' **** BEWARE: because of periodic conditions, values computed ****'
write(IMAIN,*) ' **** by check_grid() below will not be reliable ****'
write(IMAIN,*) ' *****************************************************************'
write(IMAIN,*) ' *****************************************************************'

Check warning on line 376 in src/specfem2D/setup_mesh.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/setup_mesh.F90#L371-L376

Added lines #L371 - L376 were not covered by tests
write(IMAIN,*)
call flush_IMAIN()

Check warning on line 378 in src/specfem2D/setup_mesh.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/setup_mesh.F90#L378

Added line #L378 was not covered by tests
endif

! set up a local geometric tolerance
Expand Down Expand Up @@ -419,8 +420,9 @@
! (as implemented in routine createnum_fast() elsewhere in the code). This could be done one day if needed instead
! of the very simple double loop below.
if (myrank == 0) then
write(IMAIN,*) 'start detecting points for periodic boundary conditions '// &
write(IMAIN,*) ' start detecting points for periodic boundary conditions '// &
'(the current algorithm can be slow and could be improved)...'
call flush_IMAIN()

Check warning on line 425 in src/specfem2D/setup_mesh.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/setup_mesh.F90#L425

Added line #L425 was not covered by tests
endif

counter = 0
Expand All @@ -447,9 +449,31 @@
enddo
enddo

if (myrank == 0) write(IMAIN,*) 'done detecting points for periodic boundary conditions.'
if (myrank == 0) then
write(IMAIN,*) ' done detecting points for periodic boundary conditions.'
write(IMAIN,*)
call flush_IMAIN()

Check warning on line 455 in src/specfem2D/setup_mesh.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/setup_mesh.F90#L452-L455

Added lines #L452 - L455 were not covered by tests
endif

if (counter > 0) write(IMAIN,*) 'implemented periodic conditions on ',counter,' grid points on proc ',myrank
if (counter > 0) then
write(IMAIN,*) ' implemented periodic conditions on ',counter,' grid points on proc ',myrank

Check warning on line 459 in src/specfem2D/setup_mesh.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/setup_mesh.F90#L458-L459

Added lines #L458 - L459 were not covered by tests
endif

! check if any points found
call sum_all_i(counter,counter_all)

Check warning on line 463 in src/specfem2D/setup_mesh.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/setup_mesh.F90#L463

Added line #L463 was not covered by tests

if (myrank == 0) then
write(IMAIN,*) ' total number of grid points found for periodic conditions = ',counter_all
write(IMAIN,*)
if (counter_all == 0) then
write(IMAIN,*) ' No grid points found for periodic conditions.'
write(IMAIN,*) ' Detection uses a typical element size ',xtypdist,'and position tolerance ',xtol
write(IMAIN,*) ' Please check if periodic horizontal distance ',sngl(PERIODIC_HORIZ_DIST), &
'is coherent with mesh dimensions'
write(IMAIN,*)

Check warning on line 473 in src/specfem2D/setup_mesh.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/setup_mesh.F90#L465-L473

Added lines #L465 - L473 were not covered by tests
endif
call flush_IMAIN()

Check warning on line 475 in src/specfem2D/setup_mesh.F90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/setup_mesh.F90#L475

Added line #L475 was not covered by tests
endif

endif ! of if (ADD_PERIODIC_CONDITIONS)

Expand Down
44 changes: 22 additions & 22 deletions src/specfem2D/write_postscript_snapshot.f90
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,31 @@
endif

! determines postscript output type
if (P_SV) then
select case (imagetype_postscript)
case (1)
! displacement
if (myrank == 0) write(IMAIN,*) 'drawing displacement vector as small arrows...'
call compute_vector_whole_medium(potential_acoustic,displ_elastic,displs_poroelastic)
case (2)
! velocity
if (myrank == 0) write(IMAIN,*) 'drawing velocity vector as small arrows...'
call compute_vector_whole_medium(potential_dot_acoustic,veloc_elastic,velocs_poroelastic)
case (3)
! acceleration
if (myrank == 0) write(IMAIN,*) 'drawing acceleration vector as small arrows...'
call compute_vector_whole_medium(potential_dot_dot_acoustic,accel_elastic,accels_poroelastic)
case default
call exit_MPI(myrank,'wrong type for PostScript snapshots')
end select
select case (imagetype_postscript)
case (1)
! displacement
if (myrank == 0) write(IMAIN,*) 'drawing displacement vector as small arrows...'
call compute_vector_whole_medium(potential_acoustic,displ_elastic,displs_poroelastic)
case (2)
! velocity
if (myrank == 0) write(IMAIN,*) 'drawing velocity vector as small arrows...'
call compute_vector_whole_medium(potential_dot_acoustic,veloc_elastic,velocs_poroelastic)

Check warning on line 63 in src/specfem2D/write_postscript_snapshot.f90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/write_postscript_snapshot.f90#L62-L63

Added lines #L62 - L63 were not covered by tests
case (3)
! acceleration
if (myrank == 0) write(IMAIN,*) 'drawing acceleration vector as small arrows...'
call compute_vector_whole_medium(potential_dot_dot_acoustic,accel_elastic,accels_poroelastic)

Check warning on line 67 in src/specfem2D/write_postscript_snapshot.f90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/write_postscript_snapshot.f90#L66-L67

Added lines #L66 - L67 were not covered by tests
case default
call exit_MPI(myrank,'wrong type for PostScript snapshots')
end select

! postscript plotting
call plot_post()

else
call exit_MPI(myrank,'cannot draw a SH scalar field as a vector plot, turn PostScript plots off')
! info for SH simulations
if (.not. P_SV) then
write(IMAIN,*) 'drawing a SH scalar field as a vector plot oriented along x-direction'

Check warning on line 74 in src/specfem2D/write_postscript_snapshot.f90

View check run for this annotation

Codecov / codecov/patch

src/specfem2D/write_postscript_snapshot.f90#L74

Added line #L74 was not covered by tests
endif

! postscript plotting
call plot_post()

! user output
if (myrank == 0) then
write(IMAIN,*) 'PostScript file written'
Expand Down