Beispiel #1
0
def test_eval_field_2d_1():
    # ...
    args = [dx1(u), dx2(u)]

    # TODO improve
    stmts = [AugAssign(ProductGenerator(MatrixQuadrature(i), index_quad),
                                        '+', Mul(coeff,AtomicNode(i)))
             for i in args]
    # ...

    # ...
    nderiv = 1
    body = construct_logical_expressions(u, nderiv)
    # ...

    # ...
    stmts = body + stmts
    loop  = Loop((l_quad, a_basis), index_quad, stmts)
    # ...

    # ...
    stmts = [loop]
    loop  = Loop((l_basis, l_coeff), index_dof, stmts)
    # ...

    # TODO do we need nderiv here?
    stmt = parse(loop, settings={'dim': domain.dim, 'nderiv': nderiv})
    print(pycode(stmt))
    print()
Beispiel #2
0
def test_global_quad_basis_span_2d_2():
    # ...
    nderiv = 2
    stmts = construct_logical_expressions(u, nderiv)

    expressions = [dx(u), dx(dy(u)), dy(dy(u))]
    stmts  += [ComputePhysicalBasis(i) for i in expressions]
    # ...

    # ...
    stmts  += [Reduction('+', ComputePhysicalBasis(dx(u)*dx(v)))]
    # ...

    # ...
    loop  = Loop((l_quad, a_basis), index_quad, stmts)
    # ...

    # ...
    stmts = [loop]
    loop  = Loop(l_basis, index_dof, stmts)
    # ...

    # ...
    stmts = [loop]
    loop  = Loop((g_quad, g_basis, g_span), index_element, stmts)
    # ...

    stmt = parse(loop, settings={'dim': domain.dim, 'nderiv': nderiv})
    print(pycode(stmt))
    print()
Beispiel #3
0
def test_loop_global_local_quad_2d_1():
    # ...
    stmts = []
    loop  = Loop(l_quad, index_quad, stmts)
    # ...

    # ...
    stmts = [loop]
    loop  = Loop(g_quad, index_element, stmts)
    # ...

    stmt = parse(loop, settings={'dim': domain.dim, 'nderiv': 2})
    print(pycode(stmt))
    print()
Beispiel #4
0
def test_loop_local_dof_quad_2d_1():
    # ...
    stmts = []
    loop  = Loop((l_quad, a_basis), index_quad, stmts)
    # ...

    # ...
    stmts = [loop]
    loop  = Loop(l_basis, index_dof, stmts)
    # ...

    # TODO bug when nderiv=0
    stmt = parse(loop, settings={'dim': domain.dim, 'nderiv': 1})
    print()
    print(pycode(stmt))
    print()
Beispiel #5
0
def test_loop_local_quad_2d_1():
    stmts = []
    loop  = Loop(l_quad, index_quad, stmts)

    stmt = parse(loop, settings={'dim': domain.dim})
    print(pycode(stmt))
    print()
Beispiel #6
0
    def _visit_Reduce(self, expr, **kwargs):
        op = expr.op
        lhs = expr.lhs
        rhs = expr.rhs
        loop = expr.loop

        stmts = list(loop.stmts) + [Reduction(op, rhs, lhs)]
        loop = Loop(loop.iterable, loop.index, stmts=stmts)
        return self._visit(loop, **kwargs)
Beispiel #7
0
def test_global_quad_basis_span_2d_matrix_2():
    # ...
    nderiv = 1
    stmts = construct_logical_expressions(u, nderiv)

    expressions = [dx(v), dy(v), dx(u), dy(u)]
    stmts  += [ComputePhysicalBasis(i) for i in expressions]
    # ...

    # ...
    loop  = Loop((l_quad, a_basis, GeometryExpressions(M, nderiv)), index_quad, stmts)
    # ...

    # ...
    loop = Reduce('+', ComputeKernelExpr(dx(u)*dx(v)), ElementOf(l_mat), loop)
    # ...

    # ... loop over trials
    stmts = [loop]
    loop  = Loop(l_basis, index_dof_trial, stmts)
    # ...

    # ... loop over tests
    stmts = [loop]
    loop  = Loop(l_basis_v, index_dof_test, stmts)
    # ...

    # ...
    body  = (Reset(l_mat), loop)
    stmts = Block(body)
    # ...

    # ...
    loop  = Loop((g_quad, g_basis, g_basis_v, g_span), index_element, stmts)
    # ...

    # ...
    body = (Reset(g_mat), Reduce('+', l_mat, g_mat, loop))
    stmt = Block(body)
    # ...

    stmt = parse(stmt, settings={'dim': domain.dim, 'nderiv': nderiv, 'mapping': M})
    print(pycode(stmt))
    print()
Beispiel #8
0
def test_global_quad_basis_span_2d_1():
    # ...
    stmts = []
    loop  = Loop((g_quad, g_basis, g_span), index_element, stmts)
    # ...

    # TODO do we need nderiv here?
    stmt = parse(loop, settings={'dim': domain.dim, 'nderiv': 2})
    print(pycode(stmt))
    print()
Beispiel #9
0
def test_loop_local_dof_quad_2d_3():
    # ...
    stmts  = [dx1(u)]
    stmts  = [ComputeLogicalBasis(i) for i in stmts]
    # ...

    # ...
    loop  = Loop((l_quad, a_basis), index_quad, stmts)
    # ...

    # ...
    stmts = [loop]
    loop  = Loop(l_basis, index_dof, stmts)
    # ...

    stmt = parse(loop, settings={'dim': domain.dim, 'nderiv': 3})
    print()
    print(pycode(stmt))
    print()
Beispiel #10
0
def test_global_quad_basis_span_2d_vector_2():
    # ...
    nderiv = 1
    stmts = construct_logical_expressions(v, nderiv)

#    expressions = [dx(v), v]  # TODO Wrong result
    expressions = [dx(v), dy(v)]
    stmts  += [ComputePhysicalBasis(i) for i in expressions]
    # ...

    # ... case with mapping <> identity
    loop  = Loop((l_quad, a_basis, GeometryExpressions(M, nderiv)), index_quad, stmts)
    # ...

    # ...
    loop = Reduce('+', ComputeKernelExpr(dx(v)*cos(x+y)), ElementOf(l_vec), loop)
    # ...

    # ... loop over tests
    stmts = [loop]
    loop  = Loop(l_basis_v, index_dof_test, stmts)
    # ...

    # ...
    body  = (Reset(l_vec), loop)
    stmts = Block(body)
    # ...

    # ...
    loop  = Loop((g_quad, g_basis_v, g_span), index_element, stmts)
    # ...

    # ...
    body = (Reset(g_vec), Reduce('+', l_vec, g_vec, loop))
    stmt = Block(body)
    # ...

    stmt = parse(stmt, settings={'dim': domain.dim, 'nderiv': nderiv, 'mapping': M})
    print(pycode(stmt))
    print()
Beispiel #11
0
def test_global_quad_basis_span_2d_vector_1():
    # ...
    nderiv = 2
    stmts = construct_logical_expressions(v, nderiv)

    expressions = [dx(v), dx(dy(v)), dy(dy(v))]
    stmts  += [ComputePhysicalBasis(i) for i in expressions]
    # ...

    # ...
    loop  = Loop((l_quad, a_basis), index_quad, stmts)
    # ...

    # ...
    loop = Reduce('+', ComputeKernelExpr(dx(v)*cos(x+y)), ElementOf(l_vec), loop)
    # ...

    # ... loop over tests
    stmts = [loop]
    loop  = Loop(l_basis_v, index_dof_test, stmts)
    # ...

    # ...
    body  = (Reset(l_vec), loop)
    stmts = Block(body)
    # ...

    # ...
    loop  = Loop((g_quad, g_basis_v, g_span), index_element, stmts)
    # ...

    # ...
    body = (Reset(g_vec), Reduce('+', l_vec, g_vec, loop))
    stmt = Block(body)
    # ...

    stmt = parse(stmt, settings={'dim': domain.dim, 'nderiv': nderiv})
    print(pycode(stmt))
    print()
Beispiel #12
0
def test_loop_local_quad_geometry_2d_1():
    # ...
    nderiv = 1
    stmts = []
    loop  = Loop((l_quad, GeometryExpressions(M, nderiv)), index_quad, stmts)
    # ...

    settings = {'dim': domain.dim, 'nderiv': nderiv, 'mapping': M}
    _parse = lambda expr: parse(expr, settings=settings)

    stmt = _parse(loop)
    print()
    print(pycode(stmt))

    print()