Newer
Older
import numpy as np
import numpy.linalg as la # noqa: F401
import pyopencl as cl # noqa: F401
import pyopencl.array # noqa
import pyopencl.tools # noqa
import pyopencl.clrandom # noqa
import loopy as lp # noqa
def weno_weights(oscillation, frozen_metric):
linear = np.array([0.1, 0.6, 0.3])
eps = 1e-6*frozen_metric
raw_weights = np.empty((5,3))
for i in range(5):
for j in range(3):
raw_weights[i,j] = linear[j]/(oscillation[i,j] + eps)**2
weight_sum = raw_weights.sum(axis=1)
weights = np.empty((5,3))
for i in range(5):
for j in range(3):
weights[i,j] = raw_weights[i,j]/weight_sum[i]
return weights