Example #1
0
 def set_probe_points(self, pts):
     self.probes = StatisticsProbes(pts.flatten(), self.V, True)
     if self.h5fp_str is not None:
         self.probes_p = StatisticsProbes(pts.flatten(), self.V, False)
     if self.compute_stress:
         self.probes_grad_u = dict()
         for dim in xrange(3):
             self.probes_grad_u[dim] = StatisticsProbes(
                 pts.flatten(), self.Vv)
Example #2
0
def test_StatisticsProbes_vector_3D(VF3):
    u0 = interpolate(Expression(('x[0]', 'x[1]', 'x[2]'), degree=1), VF3)
    x = array([[0.5, 0.25, 0.25], [0.4, 0.4, 0.4], [0.3, 0.3, 0.3]])
    probes = StatisticsProbes(x.flatten(), VF3)

    for i in range(5):
        probes(u0)

    p = probes.array()
    if MPI.rank(MPI.comm_world) == 0:
        assert round(p[0,0] - 2.5, 7) == 0
        assert round(p[0,4] - 0.3125, 7) == 0
Example #3
0
def test_StatisticsProbes_segregated_2D(V2):
    u0 = interpolate(Expression('x[0]', degree=1), V2)
    v0 = interpolate(Expression('x[1]', degree=1), V2)
    x = array([[0.5, 0.25], [0.4, 0.4], [0.3, 0.3]])
    probes = StatisticsProbes(x.flatten(), V2, True)

    for i in range(5):
        probes(u0, v0)

    p = probes.array()
    if MPI.rank(MPI.comm_world) == 0:
        assert round(p[0,0] - 2.5, 7) == 0
        assert round(p[0,4] - 0.625, 7) == 0
Example #4
0
def pre_solve_hook(mesh, V, **NS_namespace):
    # Normals and facets to compute flux at inlet and outlet
    normal = FacetNormal(mesh)
    Inlet = AutoSubDomain(inlet)
    Outlet = AutoSubDomain(outlet)
    Walls = AutoSubDomain(walls)
    Centerline = AutoSubDomain(centerline)
    facets = FacetFunction('size_t', mesh, 0)
    Inlet.mark(facets, 1)
    Outlet.mark(facets, 2)
    Walls.mark(facets, 3)
    Centerline.mark(facets, 4)

    z_senterline = linspace(-0.18269, 0.320, 1000)
    x = array([[i, 0.0] for i in z_senterline])
    senterline = StatisticsProbes(x.flatten(), V)

    return dict(uv=Function(V), senterline=senterline, facets=facets,
                normal=normal)
Example #5
0
def pre_solve_hook(u_, Lx, D, V, Q, mesh, restart_folder, velocity_degree, AssignedVectorFunction, newfolder, MPI, **NS_namespace):
    """Called prior to time loop"""
    if MPI.rank(MPI.comm_world) == 0:
        makedirs(path.join(newfolder, "Probes"))

    # set up probes
    eval_dict = {}
    # probe aloing y-direction from the centerline, we select middle point in terms of x-direction
    probe_points = np.linspace((Lx/2, 0, 0), (Lx/2, D/2, 0), 100)

    # Store points file in checkpoint
    if MPI.rank(MPI.comm_world) == 0:
        probe_points.dump(path.join(newfolder, "Probes", "points"))

    # setup StatisticsProbes for velocity and probes for pressure
    eval_dict["u_probes"] = StatisticsProbes(probe_points.flatten(), V, True)
    # eval_dict["p_probes"] = Probes(probe_points.flatten(), Q)

    uv = AssignedVectorFunction(u_)
    return dict(eval_dict=eval_dict, uv=uv)
Example #6
0
            radius.append(r_1)
        else:
            radius.append(r_0)

    # Container for all StatisticsProbes
    eval_dict = {}
    key_u = "slice_u_%s"

    eps = 1e-8
    n_slice = 200
    for i in range(len(z)):
        # Set up dict for the slices
        u_ = key_u % z[i]
        slices_points = linspace(-radius[i], radius[i], n_slice)
        points = array([[x, 0, z[i]] for x in slices_points])
        eval_dict[u_] = StatisticsProbes(points.flatten(), Pv, True)

        # Store points
        points.dump(path.join(newfolder, "Stats", "Points", "slice_%s" % z[i]))

    # Setup probes in the centerline and at the wall
    N = 10000
    z_senterline = linspace(start + eps, stop - eps, N)
    eval_senter = array([[0.0, 0.0, i] for i in z_senterline])
    eval_senter.dump(path.join(newfolder, "Stats", "Points", "senterline"))
    eval_wall = []

    cone_length = 0.022685
    for z_ in z_senterline:
        # first and last cylinder
        if z_ < -0.062685 or z_ > 0.0: