How to use the pygalmesh.DomainBase function in pygalmesh

To help you get started, we’ve selected a few pygalmesh examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nschloe / pygalmesh / test / test_volume_mesh.py View on Github external
def test_heart():
    class Heart(pygalmesh.DomainBase):
        def __init__(self, edge_size):
            super(Heart, self).__init__()
            return

        def eval(self, x):
            return (
                (x[0] ** 2 + 9.0 / 4.0 * x[1] ** 2 + x[2] ** 2 - 1) ** 3
                - x[0] ** 2 * x[2] ** 3
                - 9.0 / 80.0 * x[1] ** 2 * x[2] ** 3
            )

        def get_bounding_sphere_squared_radius(self):
            return 10.0

    edge_size = 0.1
    d = Heart(edge_size)
github nschloe / pygalmesh / test / test_volume_mesh.py View on Github external
def test_custom_function():
    class Hyperboloid(pygalmesh.DomainBase):
        def __init__(self, edge_size):
            super(Hyperboloid, self).__init__()
            self.z0 = -1.0
            self.z1 = 1.0
            self.waist_radius = 0.5
            self.edge_size = edge_size
            return

        def eval(self, x):
            if self.z0 < x[2] and x[2] < self.z1:
                return x[0] ** 2 + x[1] ** 2 - (x[2] ** 2 + self.waist_radius) ** 2
            return 1.0

        def get_bounding_sphere_squared_radius(self):
            z_max = max(abs(self.z0), abs(self.z1))
            r_max = z_max ** 2 + self.waist_radius
github nschloe / pygalmesh / test / test_periodic.py View on Github external
def test_schwarz():
    class Schwarz(pygalmesh.DomainBase):
        def __init__(self):
            super(Schwarz, self).__init__()
            return

        def eval(self, x):
            x2 = numpy.cos(x[0] * 2 * numpy.pi)
            y2 = numpy.cos(x[1] * 2 * numpy.pi)
            z2 = numpy.cos(x[2] * 2 * numpy.pi)
            return x2 + y2 + z2

    mesh = pygalmesh.generate_periodic_mesh(
        Schwarz(),
        [0, 0, 0, 1, 1, 1],
        cell_size=0.05,
        facet_angle=30,
        facet_size=0.05,