solve_pressure_test.py 837 Bytes
Newer Older
mashun1's avatar
veros  
mashun1 committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from veros.core import external, utilities
from veros.pyom_compat import get_random_state

from test_base import compare_state

TEST_SETTINGS = dict(
    nx=60,
    ny=40,
    nz=30,
    dt_tracer=12000,
    dt_mom=3600,
    enable_cyclic_x=True,
    enable_streamfunction=False,
)


def test_solve_pressure(pyom2_lib):
    vs_state, pyom_obj = get_random_state(pyom2_lib, extra_settings=TEST_SETTINGS)

    vs = vs_state.variables
    settings = vs_state.settings

    # results are only identical if initial guess is already cyclic
    m = pyom_obj.main_module
    m.psi[...] = utilities.enforce_boundaries(m.psi, settings.enable_cyclic_x)
    vs.psi = utilities.enforce_boundaries(vs.psi, settings.enable_cyclic_x)

    vs.update(external.solve_pressure(vs_state))
    pyom_obj.solve_pressure()

    compare_state(vs_state, pyom_obj)