Beispiel #1
0
def testCubedSphere3():
    from igCubedSphere import CubedSphere

    n = 10
    cs = CubedSphere(n)
    grid = cs.getUnstructuredGrid()

    fc = FluxCalculator(grid, edgeIntegral)

    numSegments = 20

    piHalf = 0.5 * math.pi
    lamA, lamB = -numpy.pi, numpy.pi
    theA, theB = 0.9 * piHalf, 0.9 * piHalf

    dLam, dThe = (lamB - lamA) / float(numSegments), (
        theB - theA) / float(numSegments)

    # expression for the contour in lon-lat coordinates
    line = numpy.array([
        (lamA + i * dLam, theA + i * dThe) for i in range(numSegments + 1)
    ]).reshape(numSegments + 1, 2)
    fc.setLine(line)

    totFlux = fc.computeFlux()
    print('fc.polyline2Flux = {}'.format(fc.polyline2Flux))

    exact = psi(lamB, theB) - psi(lamA, theA)
    print('testCubedSphere3: Total flux: {} exact: {}'.format(totFlux, exact))
    assert abs(totFlux - exact) < 0.02
Beispiel #2
0
def testCubedSphere():

    from igCubedSphere import CubedSphere

    # create grid
    sphere = CubedSphere(numCellsPerTile=10, radius=1.0, coords='spherical')
    grd = sphere.getUnstructuredGrid()

    # compute vorticity
    vort = LineProjector(grd, edgeIntegral)

    lamA, theA = 0.0, math.pi / 5.
    lamB, theB = 2 * math.pi, math.pi / 5.
    vort.setLine([(lamA, theA), (lamB, theB)])

    totVort = vort.project()
    exact = psi(lamB, theB) - psi(lamA, theA)
    print('testPole: total integral = {} exact = {}'.format(totVort, exact))

    # check
    assert abs(totVort - exact) < 1.e-10
Beispiel #3
0
    x ~ longitude
    """
    return x

def integralFunction(xa, ya, xb, yb):
    """
    Compute flux attached to edge 
    x ~ longitude
    y ~ latitude
    a: starting point
    b: ending point
    """
    return psi(xb, yb) - psi(xa, ya)

n = 10
cs = CubedSphere(n)
cs.save('cs.vtk')
grid = cs.getUnstructuredGrid()

fc = FluxCalculator(grid, integralFunction)

# number of contour segments
numSegments = 100

# start longitude 	
lamMin, lamMax = 0.0, 0.5*2*numpy.pi

# increment in lambda
dx = (lamMax - lamMin) / numSegments

# fixed latitude, close to the north pole