Skip to content
Snippets Groups Projects

replicate_along_axes

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Matt Wala
    replicate_along_axes.py 825 B
    def replicate_along_axes(mesh, shape, sep_ratio):
        """
        :arg shape: Replication shape, e.g. (1, 2, 1) for 2 copies along y axis
        :arg sep_ratio: Distance between copies as a ratio of the bounding box size
        """
        from meshmode.mesh.processing import (
                find_bounding_box, affine_map, merge_disjoint_meshes)
    
        bbox = find_bounding_box(mesh)
        sizes = bbox[1] - bbox[0]
    
        meshes = [mesh]
    
        for i in range(mesh.ambient_dim):
            for j in range(1, shape[i]):
                vec = np.zeros(mesh.ambient_dim)
                vec[i] = j * sizes[i] * (1 + sep_ratio)
                meshes.append(affine_map(mesh, A=None, b=vec))
    
            # FIXME: https://gitlab.tiker.net/inducer/pytential/issues/6
            mesh = merge_disjoint_meshes(meshes, single_group=True)
            meshes = [mesh]
    
        return mesh
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment