Пример #1
0
def nested(mesh: Mesh, f_1: Field[Edge, dtype], f_2: Field[Vertex, dtype],
           f_3: Field[Edge, dtype]):
    with computation(FORWARD), interval(0, None):
        with location(Edge) as e:
            f_1 = 1
        with location(Vertex) as v:
            f_2 = 2
    with computation(FORWARD), interval(0, None), location(Edge) as e:
        f_3 = 3
Пример #2
0
def fvm_nabla(
    mesh: Mesh,
    S_MXX: Field[Edge, dtype],
    S_MYY: Field[Edge, dtype],
    pp: Field[Vertex, dtype],
    pnabla_MXX: Field[Vertex, dtype],
    pnabla_MYY: Field[Vertex, dtype],
    vol: Field[Vertex, dtype],
    sign: Field[Vertex, Local[Edge], dtype],
):
    with computation(FORWARD), interval(0, None):
        with location(Edge) as e:
            zavg = 0.5 * sum(pp[v] for v in vertices(e))
            zavg = sum(pp[v] for v in vertices(e))
            zavgS_MXX = S_MXX * zavg
            zavgS_MYY = S_MYY * zavg
        with location(Vertex) as v:
            pnabla_MXX = sum(zavgS_MXX[e] * sign[v, e] for e in edges(v))
            pnabla_MYY = sum(zavgS_MYY[e] * sign[v, e] for e in edges(v))
            pnabla_MXX = pnabla_MXX / vol
            pnabla_MYY = pnabla_MYY / vol
Пример #3
0
def sten(mesh: Mesh, field_in: Field[Vertex, dtype], field_out: Field[Edge,
                                                                      dtype]):
    with computation(FORWARD), location(Edge) as e:
        field_out[e] = sum(field_in[v] for v in vertices(e))
Пример #4
0
def sten(mesh: Mesh, field_in: Field[Cell, dtype], field_out: Field[Cell,
                                                                    dtype]):
    with computation(FORWARD), location(Cell):
        tmp = field_in
    with computation(FORWARD), location(Cell):
        field_out = tmp  # noqa: F841
Пример #5
0
def temporary_field(mesh: Mesh, out: Field[Vertex, dtype]):
    with computation(FORWARD), interval(0, None), location(Vertex) as e:
        tmp = 1
    with computation(FORWARD), interval(0, None), location(Vertex) as v:
        out = tmp
Пример #6
0
def sparse_ex(mesh: Mesh, edge_field: Field[Edge, dtype],
              sparse_field: Field[Edge, Local[Vertex], dtype]):
    with computation(FORWARD), interval(0, None), location(Edge) as e:
        edge_field = sum(sparse_field[e, v] for v in vertices(e))
Пример #7
0
def edge_reduction(mesh: Mesh, edge_field: Field[Edge, dtype],
                   vertex_field: Field[Vertex, dtype]):
    with computation(FORWARD), interval(0, None), location(Edge) as e:
        edge_field = 0.5 * sum(vertex_field[v] for v in vertices(e))
Пример #8
0
def copy(mesh: Mesh, field_in: Field[Vertex, dtype], field_out: Field[Vertex,
                                                                      dtype]):
    with computation(FORWARD), interval(0, None), location(Vertex) as v:
        field_in = field_out
Пример #9
0
def sten(mesh: Mesh, field_in: Field[Cell, dtype], field_out: Field[Cell,
                                                                    dtype]):
    with computation(FORWARD), location(Cell) as c1:
        field_out[c1] = sum(field_in[c1] + field_in[c2] for c2 in cells(c1))