Skip to content
This repository has been archived by the owner on Dec 22, 2022. It is now read-only.

fv_subgridz refactoring #142

Open
jdahm opened this issue Oct 14, 2020 · 0 comments
Open

fv_subgridz refactoring #142

jdahm opened this issue Oct 14, 2020 · 0 comments

Comments

@jdahm
Copy link
Contributor

jdahm commented Oct 14, 2020

Here is some python code for the fv_subgridz idea:

import numpy as np

nk = 6

shape = (nk, )

mc = np.ones(shape)
ri = np.ones(shape)
delp = np.ones(shape)
q = [1., 2., 3., 2., 1., 0.]

ri_ref = 2

ri[1] = ri_ref
ri[-1] = ri_ref

print(q)
for k in range(1, nk):
    if ri[k] < ri_ref:
        h0 = mc[k] * (q[k] - q[k-1])
        q[k-1] += h0 / delp[k-1]
        q[k]   -= h0 / delp[k]
print(q)

anbd here is how a stencil might compute that:

with interval(1, None):
    k_ind = index(K)
    with interval(k_ind, None):
        k_inner = index(K)
        h0 = mc[0, 0, 0] * (q[0, 0, 0] - q[0, 0, -1])
        if mod(k_inner, 2):
            q += h0 / delp[0, 0, 0]
        else:
            q -= h0 / delp[0, 0, 0]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant