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
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))
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))
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))