예제 #1
0
        else:
            # Fixed quadrature with 64 points gives absolute errors below 1e-13
            # for a quantity of order 1e-3.
            v, _ = integrate.fixed_quad(D_integrand, theta_0, angles[ii], n=64)
            val[ii] = -(R / g) * v
    return val


# Get coordinates to pass to Dval function
D0 = Function(W0)
W = VectorFunctionSpace(mesh, D0.ufl_element())
X = interpolate(mesh.coordinates, W)
D0.dat.data[:] = Dval(X.dat.data_ro)

# Adjust mean value of initial D
C = Function(D0.function_space()).assign(Constant(1.0))
area = assemble(C * dx)
Dmean = assemble(D0 * dx) / area
D0 -= Dmean
D0 += Constant(D_mean)

# Dpert
D_p = Function(W0)
Dpert = D_bump * cos(theta) * exp(-(lamda / a)**2) * exp(-(
    (theta_2 - theta) / b)**2)
D_p.interpolate(Dpert)
# Dexpr = Dbar + Dpert
Dexpr = D0 + D_p
bexpr = Constant(0)

# Set up functions
    }
}
""", "splat_coords")

    op2.par_loop(kernel, crds_latlon.cell_set,
                 crds_latlon.dat(op2.RW, crds_latlon.cell_node_map()))
    return Mesh(crds_latlon)


if write_latlon:
    outfile_ll = File('{0}_ll.pvd'.format(fname))
    field_output_ll = []
    mesh_ll = get_latlon_mesh(mesh)
    for f in field_output:
        FSpwG = functionspaceimpl.WithGeometry
        field_ll = Function(FSpwG(f.function_space(), mesh_ll),
                            val=f.topological,
                            name=f.name() + '_ll')
        field_output_ll.append(field_ll)
else:
    outfile_ll = None
    field_output_ll = None

nc_temp = zeros((nc_h5_dumpfreq, len(nc_diag)))

# Create checkpoint
chkpt = DumbCheckpoint("chkpt_{0}".format(fname), mode=FILE_CREATE)
if h5_safe:
    chkpt_bckp = DumbCheckpoint("chkpt_bckp_{0}".format(fname),
                                mode=FILE_CREATE)