Skip to content

Commit

Permalink
Parallelise test_barotropic_mes and test_baroclinic_mms
Browse files Browse the repository at this point in the history
  • Loading branch information
jwallwork23 committed Nov 26, 2021
1 parent 8f52f7f commit ba32653
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions test/solver3d/test_baroclinic_mms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"""
from thetis import *
from scipy import stats
import pytest


field_metadata['uv_full'] = dict(field_metadata['uv_3d'])

Expand Down Expand Up @@ -341,6 +343,8 @@ def run(setup, refinement, polynomial_degree, do_export=True, **options):

def run_convergence(setup, ref_list, saveplot=False, **options):
"""Runs test for a list of refinements and computes error convergence rate"""
if saveplot and COMM_WORLD.size > 1:
raise Exception('Cannot use matplotlib in parallel')
polynomial_degree = options.get('polynomial_degree', 1)
space_str = options.get('element_family')
l2_err = []
Expand Down Expand Up @@ -417,6 +421,7 @@ def expected_rate(v):
plt.savefig(imgfile, dpi=200, bbox_inches='tight')


@pytest.mark.parallel(nprocs=2)
def test_baroclinic_mms():
run_convergence(setup5, [1, 2, 4],
polynomial_degree=1, element_family='dg-dg',
Expand Down
6 changes: 5 additions & 1 deletion test/solver3d/test_barotropic_mes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""
from thetis import *
from scipy import stats
import pytest


def run(refinement=1, ncycles=2, **kwargs):
Expand Down Expand Up @@ -98,6 +99,8 @@ def run(refinement=1, ncycles=2, **kwargs):

def run_convergence(ref_list, saveplot=False, **options):
"""Runs test for a list of refinements and computes error convergence rate"""
if saveplot and COMM_WORLD.size > 1:
raise Exception('Cannot use matplotlib in parallel')
polynomial_degree = options.get('polynomial_degree', 1)
space_str = options.get('element_family')
l2_err = []
Expand Down Expand Up @@ -161,6 +164,7 @@ def check_convergence(x_log, y_log, expected_slope, field_str, saveplot, ax):
plt.savefig(imgfile, dpi=200, bbox_inches='tight')


@pytest.mark.parallel(nprocs=2)
def test_standing_wave():
run_convergence([1, 2, 4, 8],
polynomial_degree=1, element_family='dg-dg',
Expand All @@ -170,4 +174,4 @@ def test_standing_wave():
if __name__ == '__main__':
run_convergence([1, 2, 4, 6, 8, 10],
polynomial_degree=1, element_family='dg-dg',
saveplot=True, no_exports=True)
saveplot=False, no_exports=True)

0 comments on commit ba32653

Please sign in to comment.