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

fv_subgridz refactoring #142

@jdahm

Description

@jdahm

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions