def test_pmesh2Domain_using_dummy_tsh(self):
        filename = tempfile.mktemp("test.1.tsh")
        fid = open(filename, "w")
        fid.write("4 3 # <vertex #> <x> <y> [attributes]\n \
0 0.0 0.0 0.1 0.01 0.0\n \
1 1.0 0.0 1.0 0.02 0.0\n \
2 0.0 1.0 0.2 0.03 0.0\n \
3 0.5 0.25 8.0 0.04 0.0\n \
# Vert attribute title\n \
elevation\n \
friction\n \
stage\n\
2 # <triangle #> [<vertex #>] [<neighbouring triangle #>]\n \
0 0 3 2 -1 -1 1\n \
1 0 1 3 -1 0 -1\n \
4 # <segment #> <vertex #> [boundary tag]\n\
0 1 0 a\n\
1 0 2 b\n\
2 2 3 c\n\
3 3 1 d\n")
        fid.close()

        mesh_instance = importMeshFromFile(filename)
        domain = pmesh_to_domain_instance(mesh_instance, Domain)
        os.remove(filename)

        answer = [[0.1,8.0,0.2],
                [0.1,1.0,8.0]]
        assert np.allclose(domain.quantities["elevation"].vertex_values, answer)

        answer = [[0.0,0.0,0.0],
                [0.0,0.0,0.0]]
        assert np.allclose(domain.quantities["stage"].vertex_values, answer)

        answer = [[0.01,0.04,0.03],
                [0.01,0.02,0.04]]
        assert np.allclose(domain.quantities["friction"].vertex_values, answer)

        # undefined but somehow default value is zero
        answer = [[0.0,0.0,0.0],
                [0.0,0.0,0.0]]
        assert np.allclose(domain.quantities["xmomentum"].vertex_values, answer)
Example #2
0
store_unique_vertices = project.store_unique_vertices
is_varying_manning = project.is_varying_manning

# -----------------------------------------------------------------------------
# SET UP DOMAIN AND INITIAL CONDITION
# -----------------------------------------------------------------------------

if myid == 0:
    zelv = helper.data.get_elevation(f_elv)
    xmom = helper.data.get_xmomentum(f_elv)
    ymom = helper.data.get_ymomentum(f_elv)
    inistage = helper.data.get_stage(f_elv)
    man_n = helper.data.get_manning(f_man, is_varying_manning, default_man_n)

    mesh_instance = importMeshFromFile(f_mesh)
    domain = anuga.pmesh_to_domain_instance(mesh_instance, Domain)

    print domain.statistics()
    print domain.geo_reference

    domain.set_quantity('elevation', zelv)
    domain.set_quantity('stage', inistage)
    domain.set_quantity('xmomentum', xmom)
    domain.set_quantity('ymomentum', ymom)
    domain.set_quantity('friction', man_n)

else:
    domain = None

if myid == 0 and verbose:
    print 'Distributing domain ...'
 def test_pmesh2Domain_using_simple_tsh(self):
     f_tsh = "/home/somat/ir_flood/ciliwung/pre/test/data/simple/box.1.tsh"
     mesh_instance = importMeshFromFile(f_tsh)
     domain = pmesh_to_domain_instance(mesh_instance, Domain)