Пример #1
0
def setupStepGauss():
    import numpy as np
    from math import sin,cos,pi,sqrt,exp
    #set up a fake LiDAR point set
    nPoints_x = nPoints_y = 51
    delta_x = 2.0/float(nPoints_x-1)
    delta_y = 2.0/float(nPoints_y-1)
    bathy = np.zeros((nPoints_x*nPoints_y,3),'d')
    for i in range(nPoints_y):
        for j in range(nPoints_x):
            x = -0.5+j*delta_x
            y = -0.5+i*delta_y
            #z = 1.0
            if y > x:
                z = 1.0
            else:
                if y < x - 0.25:
                    r = sqrt((y - 0.25)**2 + (x - 0.8)**2)
                    z = exp(-50.0*r**2)
                else:
                    z = 0.0
            #z = y
            #z += sin(2.0*pi*x)*cos(2.0*pi*y)
            bathy[i*nPoints_x+j,0] = x
            bathy[i*nPoints_x+j,1] = y
            bathy[i*nPoints_x+j,2] = z
    domain = InterpolatedBathymetryDomain(vertices=[[0.0,0.0],
                                                    [0.0,1.0],
                                                    [0.5,1.5],
                                                    [1.0,1.0],
                                                    [1.5,-0.5]],
                                          vertexFlags=[1,2,3,2,1],
                                          segments=[[0,1],
                                                    [1,2],
                                                    [2,3],
                                                    [3,4],
                                                    [4,0]],
                                          segmentFlags=[1,2,3,3,1],
                                          regions=[(0.5,0.5)],
                                          regionFlags=[1],
                                          name="interpolatedBathySimpleTest",
                                          units='m',
                                          tol=max(delta_x,delta_y),
                                          bathy = bathy)
    domain.writePoly(domain.name)
    return domain
Пример #2
0
def setupStepGauss():
    import numpy as np
    from math import sin, cos, pi, sqrt, exp
    #set up a fake LiDAR point set
    nPoints_x = nPoints_y = 21
    delta_x = 2.0 / float(nPoints_x - 1)
    delta_y = 2.0 / float(nPoints_y - 1)
    bathy = np.zeros((nPoints_x * nPoints_y, 3), 'd')
    for i in range(nPoints_y):
        for j in range(nPoints_x):
            x = -0.5 + j * delta_x
            y = -0.5 + i * delta_y
            #z = 1.0
            if y > x:
                z = 1.0
            else:
                if y < x - 0.25:
                    r = sqrt((y - 0.25)**2 + (x - 0.8)**2)
                    z = exp(-50.0 * r**2)
                else:
                    z = 0.0
            #z = y
            #z += sin(2.0*pi*x)*cos(2.0*pi*y)
            bathy[i * nPoints_x + j, 0] = x
            bathy[i * nPoints_x + j, 1] = y
            bathy[i * nPoints_x + j, 2] = z
    domain = InterpolatedBathymetryDomain(vertices=[[0.0, 0.0], [0.0, 1.0],
                                                    [0.5, 1.5], [1.0, 1.0],
                                                    [1.5, -0.5]],
                                          vertexFlags=[1, 2, 3, 2, 1],
                                          segments=[[0, 1], [1, 2], [2, 3],
                                                    [3, 4], [4, 0]],
                                          segmentFlags=[1, 2, 3, 3, 1],
                                          regions=[(0.5, 0.5)],
                                          regionFlags=[1],
                                          name="interpolatedBathySimpleTest",
                                          units='m',
                                          bathy=bathy,
                                          bathyGridDim=(nPoints_y, nPoints_x))
    domain.writePoly(domain.name)
    return domain
Пример #3
0
        ]
        boundaryTags = dict([(key, i + 1)
                             for (i, key) in enumerate(boundaries)])
        #
        #process 2D domain
        #
        bathy_points = np.vstack(
            (bathy[:, 7], bathy[:, 8], bathy[:, 9])).transpose()
        domain2D = InterpolatedBathymetryDomain(
            vertices=[[xmin, ymin], [xmin, ymax], [xmax, ymax], [xmax, ymin]],
            vertexFlags=[
                boundaryTags['left'], boundaryTags['left'],
                boundaryTags['right'], boundaryTags['right']
            ],
            segments=[[0, 1], [1, 2], [2, 3], [3, 0]],
            segmentFlags=[
                boundaryTags['left'], boundaryTags['back'],
                boundaryTags['right'], boundaryTags['front']
            ],
            regions=[(0.5 * (xmax + xmin), 0.5 * (ymax + ymin))],
            regionFlags=[1],
            name="frfDomain2D",
            units='m',
            bathy=bathy_points)
        domain2D.writePoly(domain2D.name)

        #now adaptively refine 2D mesh to interpolate bathy to desired accuracy
        mesh2D = InterpolatedBathymetryMesh(
            domain2D,
            triangleOptions="gVApq30Dena%8.8f" % ((1000.0**2) / 2.0, ),
            atol=1.0e-1,
            rtol=1.0e-1,