Ejemplo n.º 1
0
def test_mass_geo_3d():
    kv = bspline.make_knots(2, 0.0, 1.0, 10)
    geo = geometry.twisted_box()
    M = mass((kv,kv,kv), geo)
    M_ref = read_sparse_matrix(os.path.join(os.path.dirname(__file__),
        "poisson_neu_d3_p2_n10_mass.mtx.gz"))
    assert abs(M - M_ref).max() < 1e-14
Ejemplo n.º 2
0
def test_fast_stiffness_geo_3d():
    kv = bspline.make_knots(2, 0.0, 1.0, 10)
    geo = geometry.twisted_box()
    A = stiffness_fast((kv,kv,kv), geo, verbose=0)
    A_ref = read_sparse_matrix(os.path.join(os.path.dirname(__file__),
        "poisson_neu_d3_p2_n10_stiff.mtx.gz"))
    assert abs(A - A_ref).max() < 1e-9
Ejemplo n.º 3
0
def test_inner_products():
    kvs = [bspline.make_knots(p, 0.0, 1.0, 8+p) for p in range(3,6)]
    def f(x,y,z): return np.cos(x) * np.exp(y) * np.sin(z)
    inp = inner_products(kvs, f)
    assert inp.shape == tuple(kv.numdofs for kv in kvs)
    inp2 = inner_products(kvs, f, geo=geometry.unit_cube())
    assert np.allclose(inp, inp2)

    # compare to autogenerated assemblers when using geometry
    geo = geometry.twisted_box()
    import pyiga.assemblers

    # physical=False
    asm = pyiga.assemblers.L2FunctionalAssembler3D(kvs, geo, f=f)
    inp = asm.assemble_vector()
    inp2 = inner_products(kvs, f, geo=geo)
    assert np.allclose(inp, inp2)

    # physical=True
    asm = pyiga.assemblers.L2FunctionalAssemblerPhys3D(kvs, geo, f=f)
    inp = asm.assemble_vector()
    inp2 = inner_products(kvs, f, f_physical=True, geo=geo)
    assert np.allclose(inp, inp2)