Skip to content

Commit

Permalink
Merge pull request #4 from carlosmunozmoncayo/implicit_none
Browse files Browse the repository at this point in the history
Update branch, add testing workflow, use implicit none in more Riemann solvers
  • Loading branch information
ketch authored Sep 19, 2024
2 parents b6a8635 + fcb7699 commit 2786fc4
Show file tree
Hide file tree
Showing 40 changed files with 907 additions and 352 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/amrclaw_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Test Riemann solvers with AMRClaw tests

on:
push:
branches: [ "implicit_none" ]
pull_request:
branches: [ "implicit_none" ]

workflow_dispatch:

permissions:
contents: read

env:
CLAW: ${{ github.workspace }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install gfortran
python -m pip install --upgrade pip
pip install 'numpy<2.0'
pip install matplotlib #Some imports require matplotlib
pip install scipy #To not skip tests
pip install nose
pip install flake8 meson-python ninja pytest
- name: Checkout Clawpack
uses: actions/[email protected]
with:
repository: clawpack/clawpack
submodules: true

- name: Checkout AMRClaw branch
uses: actions/[email protected]
with:
repository: clawpack/amrclaw #
path: amrclaw
ref: master

- name: Checkout implicit_none from this repo
uses: actions/[email protected]
with:
repository: ${{ github.repository }}
path: ${{ env.CLAW }}/riemann
ref: implicit_none

- name: Install Clawpack
run: |
cd ${CLAW}
pip install --no-build-isolation --editable .
- name: Test with pytest
run: |
cd ${CLAW}/riemann
bash collect_pytests_amrclaw.sh
66 changes: 66 additions & 0 deletions .github/workflows/classic_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Test Riemann solvers with Classic Clawpack tests

on:
push:
branches: [ "implicit_none" ]
pull_request:
branches: [ "implicit_none" ]

workflow_dispatch:

permissions:
contents: read

env:
CLAW: ${{ github.workspace }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install gfortran
python -m pip install --upgrade pip
pip install 'numpy<2.0'
pip install matplotlib #Some imports require matplotlib
pip install scipy #To not skip tests
pip install nose
pip install flake8 meson-python ninja pytest
- name: Checkout Clawpack
uses: actions/[email protected]
with:
repository: clawpack/clawpack
submodules: true

- name: Checkout Classic branch
uses: actions/[email protected]
with:
repository: clawpack/classic #
path: classic
ref: master

- name: Checkout implicit_none from this repo
uses: actions/[email protected]
with:
repository: ${{ github.repository }}
path: ${{ env.CLAW }}/riemann
ref: implicit_none

- name: Install Clawpack
run: |
cd ${CLAW}
pip install --no-build-isolation --editable .
- name: Test with pytest
run: |
cd ${CLAW}/classic
pytest tests
65 changes: 65 additions & 0 deletions .github/workflows/pyclaw_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Test Riemann solvers with PyClaw tests

on:
push:
branches: [ "implicit_none" ]
pull_request:
branches: [ "implicit_none" ]

workflow_dispatch:

permissions:
contents: read

env:
CLAW: ${{ github.workspace }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install gfortran
python -m pip install --upgrade pip
pip install 'numpy<2.0'
pip install matplotlib #Some imports require matplotlib
pip install scipy #To not skip tests
pip install flake8 meson-python ninja pytest
- name: Checkout Clawpack
uses: actions/[email protected]
with:
repository: clawpack/clawpack
submodules: true

- name: Checkout PyClaw branch
uses: actions/[email protected]
with:
repository: clawpack/pyclaw #
path: pyclaw
ref: master

- name: Checkout implicit_none from this repo
uses: actions/[email protected]
with:
repository: ${{ github.repository }}
path: ${{ env.CLAW }}/riemann
ref: implicit_none

- name: Install Clawpack
run: |
cd ${CLAW}
pip install --no-build-isolation --editable .
- name: Test with pytest
run: |
cd ${CLAW}/pyclaw
pytest --ignore=development --ignore=examples/shallow_sphere
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ When adding a new Riemann solver, in addition to adding the normal and
(optionally) transverse solver code files in src/, you should do the following
in order to ensure the new solver is importable in PyClaw. To make things
concrete, suppose you are committing a 2D elasticity solver, so your Fortran
files are named `rpn2_elasticity.f90` and `rpt2_elasticity.f90`. Then you should:
files are named `rpn2_vc_elasticity.f90` and `rpt2_vc_elasticity.f90`. Then you should:

1. Add the following to `clawpack/riemann/riemann/__init__.py`:
```
Expand Down
19 changes: 19 additions & 0 deletions collect_pytests_amrclaw.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#Collect Pytest tests for AMRClaw
cd ${CLAW}/amrclaw/tests
pathlist=()
for dir in $(ls -d */); do
cd $dir
#Check if there are any test files
#Capture the error message and check if it is empty
if [ -z "$(ls *test*.py 2>/dev/null )" ]; then
cd ..
continue
fi
for file in $(ls *test*.py); do
pathlist+=($(pwd)/$file)
done
cd ..
done

#Run the tests
pytest ${pathlist[@]}
4 changes: 3 additions & 1 deletion riemann/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from . import euler_3D_constants
from . import burgers_3D_constants
from . import vc_advection_3D_constants
from . import euler_mapgrid_3D


try:
Expand All @@ -65,12 +66,12 @@
from . import euler_hlle_1D
from . import mhd_roe_1D
from . import nonlinear_elasticity_fwave_1D
from . import psystem_fwave_1D
from . import reactive_euler_with_efix_1D
from . import shallow_hlle_1D
from . import shallow_roe_with_efix_1D
from . import shallow_bathymetry_fwave_1D
from . import shallow_roe_tracer_1D
#from . import sw_aug_1D
from . import traffic_1D
from . import traffic_vc_1D
from . import traffic_vc_fwave_1D
Expand Down Expand Up @@ -99,6 +100,7 @@
from . import euler_3D
from . import burgers_3D
from . import vc_advection_3D
from . import euler_mapgrid_3D
except ImportError as e:
import traceback
print("********************************************************************")
Expand Down
2 changes: 1 addition & 1 deletion riemann/euler_1D_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
Unless otherwise noted, the ideal gas equation of state is used:
.. math::
E = (\gamma - 1) \left (E - \frac{1}{2}\rho u^2 \right)
p = (\gamma - 1) \left (E - \frac{1}{2}\rho u^2 \right)
"""

import numpy as np
Expand Down
26 changes: 23 additions & 3 deletions riemann/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ riemann_1D = [
'euler_hlle',
'mhd_roe',
'nonlinear_elasticity_fwave',
'psystem_fwave',
'reactive_euler_with_efix',
'shallow_hlle',
'shallow_roe_with_efix',
Expand All @@ -110,6 +111,7 @@ riemann_2D = [
riemann_3D = [
'vc_acoustics',
'euler',
'euler_mapgrid',
'burgers',
'vc_advection',
]
Expand Down Expand Up @@ -148,7 +150,6 @@ foreach suffix, names: riemann_ptwise
ext_name, [ext_srcs, f2py_srcs],
incdir_f2py / 'fortranobject.c',
include_directories: inc_np,
dependencies : py_dep,
subdir: pkg_dir,
install : true
)
Expand All @@ -171,7 +172,6 @@ foreach suffix, names: riemann
ext_name, [ext_srcs, f2py_srcs],
incdir_f2py / 'fortranobject.c',
include_directories: inc_np,
dependencies : py_dep,
subdir: pkg_dir,
install : true
)
Expand Down Expand Up @@ -223,8 +223,28 @@ foreach name, sources: special_extensions
ext_name, [ext_srcs, f2py_srcs],
incdir_f2py / 'fortranobject.c',
include_directories: inc_np,
dependencies : py_dep,
subdir: pkg_dir,
install : true
)
endforeach

ext_name = 'mappedGrid'
ext_srcs = [
srcdir / 'euler3d_mappedGrid.f90',
]
f2py_srcs = custom_target(
'f2py_mappedGrid',
command: [f2py, ext_name],
input: ext_srcs,
output: [ext_name + 'module.c', ext_name + '-f2pywrappers2.f90'],
build_by_default: true,
)

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
)
3 changes: 1 addition & 2 deletions riemann/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
'euler_hlle',
'mhd_roe',
'nonlinear_elasticity_fwave',
'psystem_fwave',
'reactive_euler_with_efix',
'shallow_hlle',
'shallow_roe_with_efix',
'shallow_bathymetry_fwave',
'sw_aug',
'shallow_roe_tracer']

two_d_ptwise_riemann = ['acoustics']
Expand All @@ -37,7 +37,6 @@
'psystem',
'shallow_roe_with_efix',
'shallow_bathymetry_fwave',
'sw_aug',
'shallow_sphere',
'vc_acoustics',
'vc_advection',
Expand Down
6 changes: 4 additions & 2 deletions riemann/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
'euler_hlle_1D' : 3,
'mhd_roe_1D' : 8,
'nonlinear_elasticity_fwave_1D' : 2,
'psystem_fwave_1D' : 2,
'nonlinear_elasticity_1D' : 2,
'reactive_euler_with_efix_1D' : 4,
'shallow_roe_with_efix_1D' : 2,
Expand All @@ -26,13 +27,13 @@
'shallow_hll_1D' : 2,
'shallow_hlle_1D' : 2,
'shallow_bathymetry_fwave_1D' : 2,
'sw_aug_1D' : 2,
'shallow_1D_py' : 2,
'vc_advection_1D' : 1,
'layered_shallow_water_1D' : 4,
'acoustics_2D' : 3,
'acoustics_mapped_2D' : 3,
'advection_2D' : 1,
'burgers_2D' : 1,
'euler_mapgrid_2D' : 4,
'euler_5wave_2D' : 5,
'euler_4wave_2D' : 4,
Expand Down Expand Up @@ -73,20 +74,21 @@
'mhd_roe_1D' : 7,
'nonlinear_elasticity_fwave_1D' : 2,
'nonlinear_elasticity_1D' : 2,
'psystem_fwave_1D' : 2,
'reactive_euler_with_efix_1D' : 4,
'shallow_roe_with_efix_1D' : 2,
'shallow_roe_tracer_1D' : 3,
'shallow_roe_1D' : 2,
'shallow_hll_1D' : 2,
'shallow_hlle_1D' : 2,
'shallow_bathymetry_fwave_1D' : 2,
'sw_aug_1D' : 2,
'shallow_1D_py' : 2,
'vc_advection_1D' : 1,
'layered_shallow_water_1D' : 4,
'acoustics_2D' : 2,
'acoustics_mapped_2D' : 2,
'advection_2D' : 1,
'burgers_2D' : 1,
'euler_mapgrid_2D' : 4,
'euler_5wave_2D' : 5,
'euler_4wave_2D' : 4,
Expand Down
Loading

0 comments on commit 2786fc4

Please sign in to comment.