Return the Reynolds Number for a general cross section.
355009
def re_general(Vel, Area, PerimWetted, Nu):
    """"""
    #Checking input validity - inputs not checked here are checked by
    #functions this function calls.
    ut.check_range([Vel, ">=0", "Velocity"], [Nu, ">0", "Nu"])
    return 4 * radius_hydraulic_general(Area, PerimWetted).magnitude * Vel / Nu
111299
def mesh(self):
        """"""
        triangles = np.empty((self.f.shape[0], 4))
        triangles[:, -3:] = self.f
        triangles[:, 0] = 3
        return vtki.PolyData(self.v, triangles, deep=False)
1022960
def particle_number_concentration(ConcMat, material):
    
    return ConcMat.to(material.Density.units) / ((material.Density * np.pi * material.Diameter**3) / 6)
1009087
def vec(self):
        
        return np.r_[self.fx, self.fy, self.cx, self.cy, self.skew, self.height, self.width]
157439
def numdiff(fun, args):
    """"""

    # vectorized version

    epsilon = 1e-8
    args = list(args)
    v0 = fun(*args)
    N = v0.shape[0]
    l_v = len(v0)
    dvs = []
    for i, a in enumerate(args):
        l_a = (a).shape[1]
        dv = numpy.zeros((N, l_v, l_a))
        nargs = list(args)  #.copy()
        for j in range(l_a):
            xx = args[i].copy()
            xx[:, j] += epsilon
            nargs[i] = xx
            dv[:, :, j] = (fun(*nargs) - v0) / epsilon
        dvs.append(dv)
    return [v0] + dvs
471561
def partsphere(self, x):
        """"""
        self.counter += 1
        # return np.random.rand(1)[0]**0 * sum(x**2) + 1 * np.random.rand(1)[0]
        dim = len(x)
        x = array([x[i % dim] for i in xrange(2 * dim)])
        N = 8
        i = self.counter % dim
        # f = sum(x[i:i + N]**2)
        f = sum(x[np.random.randint(dim, size=N)]**2)
        return f
803731
def flow_ramp(self):
        """"""
        return np.linspace(1 / self.n_rows, 1, self.n_rows)*self.q
276058
def get_forces(self, a):
        """"""
        f = np.zeros( [ len(a), 3 ], dtype=float )
        for c in self.calcs:
            f += c.get_forces(a)
        return f
156971
def accel_fl(q: np.ndarray):
    """"""
    # Infer number of dimensions from q
    dims: int = len(q)
    # Number of celestial bodies
    B: int = dims // 3

    # The force given the positions q of the bodies
    f = force(q)

    # The accelerations from this force
    a = np.zeros(dims)
    for i in range(B):
        a[slices[i]] = f[slices[i]] / mass[i]
    
    return a
1096690
def shape(self):
        """"""
        if not self.data:
            return (0, 0)
        return (len(self.data), len(self.dimensions))
620441
def accel_ES_fl(q: np.ndarray):
    """"""
    # Number of celestial bodies
    num_bodies: int = 2
    # Number of dimensions in arrays; 3 spatial dimensions times the number of bodies
    dims = 3 * num_bodies

    # The force given the positions q of the bodies
    f = force_ES(q)

    # The accelerations from this force
    a = np.zeros(dims)
    a[slices[0]] = f[slices[0]] / mass[0]
    a[slices[1]] = f[slices[1]] / mass[1]
    
    return a
662823
def _affine_inv_mult(c, m):
    ""
    size = c.flow.size()
    h,w = c.size
    m[0,1] *= h/w
    m[1,0] *= w/h
    c.flow = c.flow.view(-1,2)
    a = torch.inverse(m[:2,:2].t())
    c.flow = torch.mm(c.flow - m[:2,2], a).view(size)
    return c
615880
def _call(self, x):
        """"""
        if self.prior is None:
            tmp = self.domain.element((np.exp(x) - 1)).inner(self.domain.one())
        else:
            tmp = (self.prior * (np.exp(x) - 1)).inner(self.domain.one())
        return tmp
20068
def point_stokes(self, context):
        
        stokes = np.empty(context.shape, context.dtype)
        stokes[:,:,0] = 1
        stokes[:,:,1:4] = 0
        return stokes
619447
def default_stokes(self, context):
    
    A = np.empty(context.shape, context.dtype)
    A[:,:,:] = [[[1,0,0,0]]]
    return A
871071
def get_forces(self, a=None):
        """"""
        if a is None:
            a = self.a
        forces = np.zeros([len(a), 3], dtype=float)
        if self.mask is None:
            forces[self.mask] = self.force
        else:
            forces[:] = self.force
        return forces
335852
def length(self):
        """"""
        return np.sqrt(np.sum(self**2, axis=1)).view(np.ndarray)