def check_eq(self): """ Check the variables and equations and set the limiter flags. Reset differential equation values based on limiter flags. Notes ----- The current implementation reallocates memory for `self.x_set` in each call. Consider improving for speed. (TODO) """ if not self.no_upper: self.zu[:] = np.logical_and( np.greater_equal(self.u.v, self.upper.v), np.greater_equal(self.state.e, 0)) if not self.no_lower: self.zl[:] = np.logical_and(np.less_equal(self.u.v, self.lower.v), np.less_equal(self.state.e, 0)) self.zi[:] = np.logical_not(np.logical_or(self.zu, self.zl)) # must flush the `x_set` list at the beginning self.x_set = list() if not np.all(self.zi): idx = np.where(self.zi == 0) self.state.e[:] = self.state.e * self.zi self.state.v[:] = self.state.v * self.zi + self.upper.v * self.zu + self.lower.v * self.zl self.x_set.append((self.state.a[idx], self.state.v[idx], 0)) # (address, var. values, eqn. values)
def check_eq(self): """ Check the variables and equations and set the limiter flags. """ self.zu[:] = np.logical_and(np.greater_equal(self.u.v, self.upper.v), np.greater_equal(self.state.e, 0)) self.zl[:] = np.logical_and(np.less_equal(self.u.v, self.lower.v), np.less_equal(self.state.e, 0)) self.zi[:] = np.logical_not(np.logical_or(self.zu, self.zl))
def __init__(self, u, value=0.0, flag=1, equal=False, name=None, tex_name=None, info=None, cache=True): self.value = dummify(value) self.equal = equal if self.equal is True: self.func = lambda x: np.greater_equal(x, self.value.v) else: self.func = lambda x: np.greater(x, self.value.v) FlagCondition.__init__( self, u, func=self.func, flag=flag, name=name, tex_name=tex_name, info=info, cache=cache, )
def check_var(self): """ Evaluate `self.zu` and `self.zl` Returns ------- """ if not self.enable: return self.zu[:] = np.greater_equal(self.u.v, self.upper.v) self.zl[:] = np.less_equal(self.u.v, self.lower.v) self.zi[:] = np.logical_not(np.logical_or(self.zu, self.zl))
def check_var(self, *args, **kwargs): """ Evaluate the flags. """ if not self.enable: return if not self.no_upper: self.zu[:] = np.greater_equal(self.u.v, self.upper.v) if not self.no_lower: self.zl[:] = np.less_equal(self.u.v, self.lower.v) self.zi[:] = np.logical_not(np.logical_or(self.zu, self.zl))