예제 #1
0
    def accessible_tensor(self, extend=0):
        """
        Scalar channel encoding cells that are accessible, i.e. not solid, as ones and obstacles as zero.

        :param extend: Extend the grid in all directions beyond the grid size specified by the domain
        """
        pad_values = struct.map(lambda solid: int(not solid), Material.solid(self.domain.boundaries))
        if isinstance(pad_values, (list, tuple)):
            pad_values = [0] + list(pad_values) + [0]
        result = math.pad(self.accessible.data, [[0,0]] + [[extend, extend]] * self.rank + [[0,0]], constant_values=pad_values)
        return result
예제 #2
0
파일: geom.py 프로젝트: syyunn/PhiFlow
 def apply_A(pressure):
     from phi.physics.material import Material
     mode = 'replicate' if Material.solid(domain.domain.boundaries) else 'constant'
     padded = math.pad(pressure, [[0,0]] + [[1,1]]*(math.ndims(pressure)-2) + [[0,0]], mode=mode)
     return _weighted_sliced_laplace_nd(padded, weights=fluid_mask)