How to use the meshzoo.cube function in meshzoo

To help you get started, we’ve selected a few meshzoo 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 / pyfvm / test / test_reaction.py View on Github external
def get_mesh(self, k):
        n = 2 ** (k + 1)
        vertices, cells = meshzoo.cube(
            0.0, 1.0, 0.0, 1.0, 0.0, 1.0, n + 1, n + 1, n + 1
        )
        return meshplex.MeshTetra(vertices, cells)
github nschloe / pyfvm / tests / test_convection / test_convection_cube.py View on Github external
def get_mesh(k):
    n = 2**(k+1)
    vertices, cells = meshzoo.cube(
            0.0, 1.0,
            0.0, 1.0,
            0.0, 1.0,
            n+1, n+1, n+1
            )
    return voropy.mesh_tetra.MeshTetra(vertices, cells, mode='algebraic')
github nschloe / pyfvm / test / test_convection.py View on Github external
def get_mesh(self, k):
        n = 2 ** (k + 1)
        vertices, cells = meshzoo.cube(
            0.0, 1.0, 0.0, 1.0, 0.0, 1.0, n + 1, n + 1, n + 1
        )
        return meshplex.MeshTetra(vertices, cells)
github nschloe / pyfvm / tests / test_reaction / test_reaction_cube.py View on Github external
def get_mesh(k):
    n = 2**(k+1)
    vertices, cells = meshzoo.cube(
            0.0, 1.0,
            0.0, 1.0,
            0.0, 1.0,
            n+1, n+1, n+1
            )
    return voropy.mesh_tetra.MeshTetra(vertices, cells, mode='algebraic')
github nschloe / pyfvm / examples / test_poisson.py View on Github external
def apply(self, u):
            return integrate(lambda x: -n_dot_grad(u(x)), dS) \
                 - integrate(lambda x: 50 * sin(2*pi*x[0]), dV)

        def dirichlet(self, u):
            return [
                (lambda x: u(x) - 0.0, Gamma0()),
                (lambda x: u(x) - 1.0, Gamma1())
                ]

    # # Read the mesh from file
    # mesh, _, _ = pyfvm.reader.read('circle.vtu')

    # Create mesh using meshzoo
    import meshzoo
    vertices, cells = meshzoo.cube(0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 30, 30, 30)
    mesh = voropy.mesh_tetra.MeshTetra(vertices, cells)
    # vertices, cells = meshzoo.rectangle(0.0, 2.0, 0.0, 1.0, 401, 201)
    # mesh = voropy.mesh_tri.MeshTri(vertices, cells)
    print(len(vertices))

    # import mshr
    # import dolfin
    # # h = 2.5e-3
    # h = 1.e-1
    # # cell_size = 2 * pi / num_boundary_points
    # c = mshr.Circle(dolfin.Point(0., 0., 0.), 1, int(2*pi / h))
    # # cell_size = 2 * bounding_box_radius / res
    # m = mshr.generate_mesh(c, 2.0 / h)
    # coords = m.coordinates()
    # coords = numpy.c_[coords, numpy.zeros(len(coords))]
    # cells = m.cells().copy()
github nschloe / pyfvm / tests / test_bratu / test_bratu_cube.py View on Github external
def get_mesh(k):
    n = 2**(k+1)
    vertices, cells = meshzoo.cube(
            0.0, 1.0,
            0.0, 1.0,
            0.0, 1.0,
            n+1, n+1, n+1
            )
    # return voropy.mesh_tetra.MeshTetra(vertices, cells, mode='algebraic')
    return voropy.mesh_tetra.MeshTetra(vertices, cells, mode='geometric')
github nschloe / pyfvm / tests / test_poisson / test_poisson_cube.py View on Github external
def get_mesh(k):
    n = 2**(k+1)
    vertices, cells = meshzoo.cube(
            0.0, 1.0,
            0.0, 1.0,
            0.0, 1.0,
            n+1, n+1, n+1
            )
    # return voropy.mesh_tetra.MeshTetra(vertices, cells, mode='algebraic')
    return voropy.mesh_tetra.MeshTetra(vertices, cells, mode='geometric')
github nschloe / orthopy / orthopy / hexahedron / tools.py View on Github external
def write(filename, f):
    import meshio
    import meshzoo

    points, cells = meshzoo.cube(-1, +1, -1, +1, -1, +1, 50, 50, 50)
    vals = f(points)
    meshio.write(filename, points, {"tetra": cells}, point_data={"f": vals})
    return
github nschloe / colorio / colorio / _color_space.py View on Github external
def save_srgb_gamut(self, filename, n=50, cut_000=False):
        import meshio
        import meshzoo

        points, cells = meshzoo.cube(nx=n, ny=n, nz=n)

        if cut_000:
            # cut off [0, 0, 0] to avoid division by 0 in the xyz conversion
            points = points[1:]
            cells = cells[~numpy.any(cells == 0, axis=1)]
            cells -= 1

        srgb_linear = SrgbLinear()
        pts = self.from_xyz100(srgb_linear.to_xyz100(points.T)).T
        assert pts.shape[1] == 3
        rgb = srgb_linear.to_srgb1(points)
        meshio.write_points_cells(
            filename, pts, {"tetra": cells}, point_data={"srgb": rgb}
        )