replicate_along_axes
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
Please register or sign in to comment