Пример #1
0
    def flux(self):
        from grudge.flux import make_normal, FluxVectorPlaceholder

        v = FluxVectorPlaceholder(self.arg_count)

        normal = make_normal(self.dimensions)

        flux = 0
        idx = 0

        for i, i_enabled in enumerate(self.subset):
            if i_enabled and i < self.dimensions:
                flux += (v.int - v.avg)[idx] * normal[i]
                idx += 1

        return flux
Пример #2
0
    def get_advection_flux(self, velocity):
        from grudge.flux import make_normal, FluxScalarPlaceholder
        from pymbolic.primitives import IfPositive

        u = FluxScalarPlaceholder(0)
        normal = make_normal(self.method.dimensions)

        if self.flux_type == "central":
            return u.avg * np.dot(normal, velocity)
        elif self.flux_type == "lf":
            return u.avg*np.dot(normal, velocity) \
                    + 0.5*la.norm(v)*(u.int - u.ext)
        elif self.flux_type == "upwind":
            return (np.dot(normal, velocity) * IfPositive(
                np.dot(normal, velocity),
                u.int,  # outflow
                u.ext,  # inflow
            ))
        else:
            raise ValueError("invalid flux type")
Пример #3
0
    def flux(self):
        from grudge.flux import make_normal, FluxScalarPlaceholder
        u = FluxScalarPlaceholder()

        normal = make_normal(self.dimensions)
        return u.int * normal - u.avg * normal
Пример #4
0
 def normal_times_flux(self, flux):
     from grudge.flux import make_normal
     return self.vec_times(make_normal(self.dimensions), flux)