def laplace(p): grad = gradient(p, type(velocity)) grad *= hard_bcs grad = grad.with_( extrapolation=domain.boundaries['near_vector_extrapolation']) div = divergence(grad) lap = where(active, div, p) return lap
def masked_laplace(pressure: CenteredGrid, hard_bcs: Grid, active: CenteredGrid): grad = spatial_gradient(pressure, hard_bcs.extrapolation, type=type(hard_bcs)) grad *= hard_bcs div = divergence(grad) lap = where(active, div, pressure) return lap
def matrix_eq(p): return field.where(occupied_centered, field.divergence(field.spatial_gradient(p, type=StaggeredGrid) * accessible), p)