Skip to content

Commit

Permalink
Merge pull request #166 from ketch/meson-build
Browse files Browse the repository at this point in the history
Complete meson build.
  • Loading branch information
mandli authored Oct 26, 2023
2 parents 1ba4457 + e892198 commit a6d5b0b
Show file tree
Hide file tree
Showing 17 changed files with 323 additions and 136 deletions.
217 changes: 195 additions & 22 deletions riemann/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,228 @@ pkg_dir = join_paths(package.split('.'))

python_sources = [
'__init__.py',
'mhd_1D_constants.py',
'acoustics_1D_constants.py',
'nonlinear_elasticity_1D_py.py',
'acoustics_1D_py.py',
'nonlinear_elasticity_fwave_1D_constants.py',
'acoustics_2D_constants.py',
'psystem_2D_constants.py',
'acoustics_mapped_2D_constants.py',
'reactive_euler_with_efix_1D_constants.py',
'acoustics_ptwise_2D_constants.py',
'riemann_interactive.py',
'acoustics_variable_1D_constants.py',
'riemann_tools.py',
'advection_1D_constants.py',
'advection_1D_py.py',
'shallow_1D_py.py',
'advection_2D_constants.py',
'shallow_roe_tracer_1D_constants.py',
'advection_color_1D_constants.py',
'shallow_roe_with_efix_1D_constants.py',
'burgers_1D_constants.py',
'shallow_roe_with_efix_2D_constants.py',
'burgers_1D_py.py',
'shallow_sphere_2D_constants.py',
'burgers_2D_constants.py',
'static.py',
'burgers_3D_constants.py',
'traffic_1D_constants.py',
'cubic_1D_constants.py',
'traffic_vc_1D_constants.py',
'euler_1D_py.py',
'traffic_vc_tracer_1D_constants.py',
'euler_3D_constants.py',
'vc_acoustics_2D_constants.py',
'euler_4wave_2D_constants.py',
'vc_acoustics_3D_constants.py',
'euler_5wave_2D_constants.py',
'vc_advection_1D_py.py',
'euler_mapgrid_2D_constants.py',
'vc_advection_2D_constants.py',
'euler_with_efix_1D_constants.py',
'vc_advection_3D_constants.py',
'kpp_2D_constants.py',
'vc_elasticity_2D_constants.py',
'layered_shallow_water_1D_constants.py',
'mhd_1D_constants.py',
'nonlinear_elasticity_1D_py.py',
'nonlinear_elasticity_fwave_1D_constants.py',
'psystem_2D_constants.py',
'reactive_euler_with_efix_1D_constants.py',
'riemann_interactive.py',
'riemann_tools.py',
'setup.py',
'shallow_1D_py.py',
'shallow_roe_tracer_1D_constants.py',
'shallow_roe_with_efix_1D_constants.py',
'shallow_roe_with_efix_2D_constants.py',
'shallow_sphere_2D_constants.py',
'static.py',
'traffic_1D_constants.py',
'traffic_vc_1D_constants.py',
'traffic_vc_tracer_1D_constants.py',
'vc_acoustics_2D_constants.py',
'vc_acoustics_3D_constants.py',
'vc_advection_1D_py.py',
'vc_advection_2D_constants.py',
'vc_advection_3D_constants.py',
'vc_elasticity_2D_constants.py',
'write_constants.py',
]

py.install_sources(
python_sources,
subdir: pkg_dir,
)

srcdir = '..' / 'src'
sep = '_'

riemann_1D_ptwise = [
'acoustics',
'advection',
]

riemann_2D_ptwise = [
'acoustics',
]

riemann_1D = [
'acoustics',
'acoustics_variable',
'advection',
'advection_color',
'burgers',
'cubic',
'traffic',
'traffic_vc',
'traffic_vc_fwave',
'traffic_vc_tracer',
'euler_with_efix',
'euler_hlle',
'mhd_roe',
'nonlinear_elasticity_fwave',
'reactive_euler_with_efix',
'shallow_hlle',
'shallow_roe_with_efix',
'shallow_bathymetry_fwave',
'shallow_roe_tracer',
]

riemann_2D = [
'acoustics',
'acoustics_mapped',
'advection',
'burgers',
'euler_5wave',
'psystem',
'shallow_roe_with_efix',
'shallow_bathymetry_fwave',
'sw_aug',
'shallow_sphere',
'vc_acoustics',
'vc_advection',
'vc_elasticity',
]

riemann_3D = [
'vc_acoustics',
'euler',
'burgers',
'vc_advection',
]

riemann_ptwise = {
'1D': riemann_1D_ptwise,
'2D': riemann_2D_ptwise,
}

riemann = {
'1D': riemann_1D,
'2D': riemann_2D,
'3D': riemann_3D,
}

prefixes = {
'1D': ['rp1'],
'2D': ['rpn2', 'rpt2'],
'3D': ['rpn3', 'rpt3', 'rptt3'],
}

foreach suffix, names: riemann_ptwise
foreach name: names
ext_name = sep.join(name, suffix, 'ptwise')
ext_srcs = []
foreach prefix: prefixes[suffix]
ext_srcs += srcdir / sep.join(prefix, 'ptwise.f90')
ext_srcs += srcdir / sep.join(prefix, name, 'ptwise.f90')
endforeach
f2py_srcs = custom_target(
command: [f2py, ext_name],
input: ext_srcs,
output: [ext_name + 'module.c', ext_name + '-f2pywrappers.f'],
)
py.extension_module(
ext_name, [ext_srcs, f2py_srcs],
incdir_f2py / 'fortranobject.c',
include_directories: inc_np,
dependencies : py_dep,
subdir: pkg_dir,
install : true
)
endforeach
endforeach

foreach suffix, names: riemann
foreach name: names
ext_name = sep.join(name, suffix)
ext_srcs = []
foreach prefix: prefixes[suffix]
ext_srcs += srcdir / sep.join(prefix, name + '.f90')
endforeach
f2py_srcs = custom_target(
command: [f2py, ext_name],
input: ext_srcs,
output: [ext_name + 'module.c', ext_name + '-f2pywrappers.f'],
)
py.extension_module(
ext_name, [ext_srcs, f2py_srcs],
incdir_f2py / 'fortranobject.c',
include_directories: inc_np,
dependencies : py_dep,
subdir: pkg_dir,
install : true
)
endforeach
endforeach


special_extensions = {
'kpp_2D': [
'rpn2_kpp.f90',
'rpt2_dummy.f90',
],
'shallow_hlle_2D': [
'rpn2_shallow_hlle.f90',
'rpt2_dummy.f90',
],
'euler_hlle_2D': [
'rpn2_euler_hlle.f90',
'rpt2_dummy.f90',
],
'euler_hlle_with_walls_2D': [
'rpn2_euler_hlle_with_walls.f90',
'rpt2_dummy.f90',
],
'euler_mapgrid_2D': [
'rpn2_euler_mapgrid.f90',
'rpt2_euler_mapgrid.f90',
'euler_roe_solver_mapgrid.f90',
'getquadinfo_mapgrid.f90',
],
'euler_4wave_2D': [
'rpn2_euler_4wave.f90',
'rpt2_euler.f90',
],
}

foreach name, sources: special_extensions
ext_name = name
ext_srcs = []
foreach src: sources
ext_srcs += srcdir / src
endforeach
f2py_srcs = custom_target(
command: [f2py, ext_name],
input: ext_srcs,
output: [ext_name + 'module.c', ext_name + '-f2pywrappers.f'],
)
py.extension_module(
ext_name, [ext_srcs, f2py_srcs],
incdir_f2py / 'fortranobject.c',
include_directories: inc_np,
dependencies : py_dep,
subdir: pkg_dir,
install : true
)
endforeach
7 changes: 4 additions & 3 deletions src/rp1_acoustics.f90
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ subroutine rp1(maxm,meqn,mwaves,maux,mbc,mx,ql,qr,auxl,auxr,wave,s,amdq,apdq)
! # compute the leftgoing and rightgoing flux differences:
! # Note s(1,i) < 0 and s(2,i) > 0.

do 220 m=1,meqn
do 220 i = 2-mbc, mx+mbc
do m=1,meqn
do i = 2-mbc, mx+mbc
amdq(m,i) = s(1,i)*wave(m,1,i)
apdq(m,i) = s(2,i)*wave(m,2,i)
220 END DO
end do
end do

return
end subroutine rp1
57 changes: 28 additions & 29 deletions src/rp1_acoustics_variable.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,23 @@ subroutine rp1(maxm,meqn,mwaves,maux,mbc,mx,ql,qr,auxl,auxr,wave,s,amdq,apdq)
! 1 impedance
! 2 sound_speed

! # auxl(1,i) should contain the impedance Z in cell i
! # auxl(2,i) should contain the sound speed c in cell i
! auxl(1,i) should contain the impedance Z in cell i
! auxl(2,i) should contain the sound speed c in cell i

! # On input, ql contains the state vector at the left edge of each cell
! # qr contains the state vector at the right edge of each cell
! On input, ql contains the state vector at the left edge of each cell
! qr contains the state vector at the right edge of each cell

! # On output, wave contains the waves,
! # s the speeds,
! #
! # amdq = A^- Delta q,
! # apdq = A^+ Delta q,
! # the decomposition of the flux difference
! # f(qr(i-1)) - f(ql(i))
! # into leftgoing and rightgoing parts respectively.
! #
! On output, wave contains the waves,
! s the speeds,
!
! amdq = A^- Delta q,
! apdq = A^+ Delta q,
! the decomposition of the flux difference
! f(qr(i-1)) - f(ql(i))
! into leftgoing and rightgoing parts respectively.

! # Note that the i'th Riemann problem has left state qr(:,i-1)
! # and right state ql(:,i)
! # From the basic clawpack routines, this routine is called with ql = qr
! Note that the i'th Riemann problem has left state qr(:,i-1) and right state ql(:,i)
! From the basic clawpack routines, this routine is called with ql = qr


implicit double precision (a-h,o-z)
Expand All @@ -49,26 +47,26 @@ subroutine rp1(maxm,meqn,mwaves,maux,mbc,mx,ql,qr,auxl,auxr,wave,s,amdq,apdq)
dimension apdq(meqn, 1-mbc:maxm+mbc)
dimension amdq(meqn, 1-mbc:maxm+mbc)

! local arrays
! ------------
! local arrays
! ------------
dimension delta(2)


! # split the jump in q at each interface into waves
! split the jump in q at each interface into waves

! # find a1 and a2, the coefficients of the 2 eigenvectors:
do 20 i = 2-mbc, mx+mbc
! find a1 and a2, the coefficients of the 2 eigenvectors:
do i = 2-mbc, mx+mbc
delta(1) = ql(1,i) - qr(1,i-1)
delta(2) = ql(2,i) - qr(2,i-1)

! # impedances:
! impedances:
zi = auxl(1,i)
zim = auxr(1,i-1)

a1 = (-delta(1) + zi*delta(2)) / (zim + zi)
a2 = (delta(1) + zim*delta(2)) / (zim + zi)

! # Compute the waves.
! Compute the waves.

wave(1,1,i) = -a1*zim
wave(2,1,i) = a1
Expand All @@ -78,16 +76,17 @@ subroutine rp1(maxm,meqn,mwaves,maux,mbc,mx,ql,qr,auxl,auxr,wave,s,amdq,apdq)
wave(2,2,i) = a2
s(2,i) = auxl(2,i)

20 END DO
end do

! # compute the leftgoing and rightgoing fluctuations:
! # Note s(1,i) < 0 and s(2,i) > 0.
! compute the leftgoing and rightgoing fluctuations:
! Note that s(1,i) < 0 and s(2,i) > 0.

do 220 m=1,meqn
do 220 i = 2-mbc, mx+mbc
do m=1,meqn
do i = 2-mbc, mx+mbc
amdq(m,i) = s(1,i)*wave(m,1,i)
apdq(m,i) = s(2,i)*wave(m,2,i)
220 END DO
end do
end do

return
end subroutine rp1
2 changes: 1 addition & 1 deletion src/rp1_burgers.f90
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ subroutine rp1(maxmx,meqn,mwaves,maux,mbc,mx,ql,qr,auxl,auxr,wave,s,amdq,apdq)
amdq(1,i) = dmin1(s(1,i), 0.d0) * wave(1,1,i)
apdq(1,i) = dmax1(s(1,i), 0.d0) * wave(1,1,i)

if (efix) then
if (efix) then
if (ql(1,i).gt.0.d0 .and. qr(1,i-1).lt.0.d0) then
amdq(1,i) = - 1.d0/2.d0 * qr(1,i-1)**2
apdq(1,i) = 1.d0/2.d0 * ql(1,i)**2
Expand Down
Loading

0 comments on commit a6d5b0b

Please sign in to comment.