示例#1
0
def test_mixed_fides_dg(tempdir, dim, simplex):
    """Test saving a DG function with Fides"""
    mesh = generate_mesh(dim, simplex)
    q = Function(FunctionSpace(mesh, ("DG", 1)))
    filename = os.path.join(tempdir, "v.bp")
    with pytest.raises(RuntimeError):
        FidesWriter(mesh.comm, filename, q)
示例#2
0
def test_fides_mesh(tempdir, dim, simplex):
    """ Test writing of a single Fides mesh with changing geometry"""
    filename = os.path.join(tempdir, "mesh_fides.bp")
    mesh = generate_mesh(dim, simplex)
    with FidesWriter(mesh.comm, filename, mesh) as f:
        f.write(0.0)
        mesh.geometry.x[:, 1] += 0.1
        f.write(0.1)
示例#3
0
def test_mixed_fides_functions(tempdir, dim, simplex):
    """Test saving P2 and P1 functions with Fides"""
    mesh = generate_mesh(dim, simplex)
    v = Function(VectorFunctionSpace(mesh, ("Lagrange", 2)))
    q = Function(FunctionSpace(mesh, ("Lagrange", 1)))
    filename = os.path.join(tempdir, "v.bp")
    with pytest.raises(RuntimeError):
        FidesWriter(mesh.comm, filename, [v, q])
示例#4
0
def test_functions_from_different_meshes_fides(tempdir):
    """Check that the underlying ADIOS2Writer catches sending in
    functions on different meshes"""
    filename = os.path.join(tempdir, "mesh_fides.bp")
    mesh0 = create_unit_square(MPI.COMM_WORLD, 5, 5)
    mesh1 = create_unit_square(MPI.COMM_WORLD, 10, 2)
    u0 = Function(FunctionSpace(mesh0, ("Lagrange", 1)))
    u1 = Function(FunctionSpace(mesh1, ("Lagrange", 1)))
    with pytest.raises(RuntimeError):
        FidesWriter(mesh0.comm, filename, [u0, u1])
示例#5
0
def test_second_order_fides(tempdir):
    """Check that fides throws error on second order mesh"""
    filename = os.path.join(tempdir, "mesh_fides.bp")
    points = np.array([[0, 0, 0], [1, 0, 0], [0.5, 0, 0]], dtype=np.float64)
    cells = np.array([[0, 1, 2]], dtype=np.int32)
    cell = ufl.Cell("interval", geometric_dimension=points.shape[1])
    domain = ufl.Mesh(ufl.VectorElement("Lagrange", cell, 2))
    mesh = create_mesh(MPI.COMM_WORLD, cells, points, domain)
    with pytest.raises(RuntimeError):
        FidesWriter(mesh.comm, filename, mesh)
示例#6
0
def test_findes_single_function(tempdir, dim, simplex):
    "Test saving a single first order Lagrange functions"
    mesh = generate_mesh(dim, simplex)
    v = Function(FunctionSpace(mesh, ("Lagrange", 1)))
    filename = os.path.join(tempdir, "v.bp")
    writer = FidesWriter(mesh.comm, filename, v)
    writer.write(0)
    writer.close()
示例#7
0
def test_two_fides_functions(tempdir, dim, simplex):
    """Test saving two functions with Fides"""
    mesh = generate_mesh(dim, simplex)
    v = Function(VectorFunctionSpace(mesh, ("Lagrange", 1)))
    q = Function(FunctionSpace(mesh, ("Lagrange", 1)))
    filename = os.path.join(tempdir, "v.bp")
    with FidesWriter(mesh.comm, filename, [v._cpp_object, q]) as f:
        f.write(0)

        def vel(x):
            values = np.zeros((dim, x.shape[1]))
            values[0] = x[1]
            values[1] = x[0]
            return values

        v.interpolate(vel)
        q.interpolate(lambda x: x[0])
        f.write(1)
示例#8
0
def test_fides_function_at_nodes(tempdir, dim, simplex):
    """Test saving P1 functions with Fides (with changing geometry)"""
    mesh = generate_mesh(dim, simplex)
    v = Function(VectorFunctionSpace(mesh, ("Lagrange", 1)))
    v.name = "v"
    q = Function(FunctionSpace(mesh, ("Lagrange", 1)))
    q.name = "q"
    filename = os.path.join(tempdir, "v.bp")
    with FidesWriter(mesh.comm, filename, [v, q]) as f:
        for t in [0.1, 0.5, 1]:
            # Only change one function
            q.interpolate(lambda x: t * (x[0] - 0.5)**2)
            f.write(t)

            mesh.geometry.x[:, :2] += 0.1
            if mesh.geometry.dim == 2:
                v.interpolate(lambda x: (t * x[0], x[1] + x[1] * 1j))
            elif mesh.geometry.dim == 3:
                v.interpolate(lambda x: (t * x[2], x[0] + x[2] * 2j, x[1]))
            f.write(t)