Skip to content

Commit

Permalink
add another starfish from Greengard paper
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfikl authored and inducer committed Oct 14, 2022
1 parent f09fdd4 commit b65cc60
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions meshmode/mesh/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@
.. autofunction:: circle
.. autofunction:: ellipse
.. autofunction:: cloverleaf
.. data :: starfish
.. autofunction:: drop
.. autofunction:: n_gon
.. autofunction:: qbx_peanut
.. autofunction:: apple
.. autoclass:: WobblyCircle
.. autoclass:: NArmedStarfish
.. data:: starfish3
.. data:: starfish5
Surfaces
--------
Expand Down Expand Up @@ -204,8 +205,9 @@ class WobblyCircle:
.. automethod:: random
.. automethod:: __call__
"""
def __init__(self, coeffs: np.ndarray):
def __init__(self, coeffs: np.ndarray, phase: float = 0.0) -> None:
self.coeffs = coeffs
self.phase = phase

@staticmethod
def random(ncoeffs: int, seed: int):
Expand All @@ -227,7 +229,7 @@ def __call__(self, t: np.ndarray):

wave = 1
for i, coeff in enumerate(self.coeffs):
wave = wave + coeff*np.sin((i+1)*t)
wave = wave + coeff*np.sin((i+1)*t + self.phase)

return np.vstack([
np.cos(t)*wave,
Expand All @@ -240,13 +242,16 @@ class NArmedStarfish(WobblyCircle):
.. automethod:: __call__
"""
def __init__(self, n_arms: int, amplitude: float):
def __init__(self, n_arms: int, amplitude: float, phase: float = 0.0) -> None:
coeffs = np.zeros(n_arms)
coeffs[-1] = amplitude
super().__init__(coeffs)
super().__init__(coeffs, phase=phase)


starfish = NArmedStarfish(5, 0.25)
starfish3 = NArmedStarfish(3, 1 / 2, phase=np.pi / 2)
starfish5 = NArmedStarfish(5, 0.25)

starfish = starfish5

# }}}

Expand Down

0 comments on commit b65cc60

Please sign in to comment.