From 3d0e07798fb85107a7f0af0a41588906d2acc7df Mon Sep 17 00:00:00 2001
From: Matt Wala <wala1@illinois.edu>
Date: Sun, 23 Jul 2017 15:05:11 -0500
Subject: [PATCH] Add an 'apple' test geometry.

---
 meshmode/mesh/generation.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/meshmode/mesh/generation.py b/meshmode/mesh/generation.py
index f08d5a76..8e9b8665 100644
--- a/meshmode/mesh/generation.py
+++ b/meshmode/mesh/generation.py
@@ -45,6 +45,7 @@ Curve parametrizations
 .. autofunction:: drop
 .. autofunction:: n_gon
 .. autofunction:: qbx_peanut
+.. autofunction:: apple
 .. autoclass:: WobblyCircle
 
 Surfaces
@@ -155,6 +156,24 @@ def qbx_peanut(t):
         ])
 
 
+def apple(a, t):
+    """
+    :arg a: 0 <= a <= 1; roundedness: 0 returns a circle, 1 returns a cardioid
+    :arg t: the parametrization, runs from [0,1)
+    :return: an array of shape *(2, npoints)*
+    """
+    ilength = 2*np.pi
+    t = t*ilength
+
+    sin = np.sin
+    cos = np.cos
+
+    return np.vstack([
+        cos(t) + a*cos(2*t),
+        sin(t) + a*sin(2*t)
+        ])
+
+
 class WobblyCircle(object):
     """
     .. automethod:: random
-- 
GitLab