コード例 #1
0
ファイル: octree_test.py プロジェクト: pgh79/fealpy
        isBranchCell = np.zeros(NC, dtype=np.bool)
        isBranchCell[tree[isLeafCell, 0]] = True

        branchCell = cell[isBranchCell, :]
        isCoarsenCell = np.abs(
            np.sum(valueSign[branchCell], axis=1) +
            valueSign[cell[tree[isBranchCell, 1], 1]]) == 5
        idx, = np.nonzero(isBranchCell)

        return idx[isCoarsenCell]


point = 2 * np.array([[-1, -1, -1], [1, -1, -1], [1, 1, -1], [-1, 1, -1],
                      [-1, -1, 1], [1, -1, 1], [1, 1, 1], [-1, 1, 1]],
                     dtype=np.float)

cell = np.array([[0, 1, 2, 3, 4, 5, 6, 7]], dtype=np.int)
octree = Octree(point, cell)
phi = Sphere()
marker = AdaptiveMarker(phi)

for i in range(1):
    octree.uniform_refine()

for i in range(8):
    octree.refine(marker)

pmesh = octree.to_pmesh()
write_vtk_mesh(pmesh, 'pmesh.vtk')
print(pmesh.check())
コード例 #2
0
import sys
import numpy as np
import mpl_toolkits.mplot3d as a3

import pylab as pl

from mayavi import mlab

from fealpy.mesh.surface_mesh_generator import iso_surface
from fealpy.mesh.level_set_function import Sphere
from fealpy.mesh.TriangleMesh import TriangleMesh 

surface = Sphere()
mesh = surface.init_mesh()
mesh.uniform_refine(3, surface)

c, R = mesh.circumcenter()

f = pl.figure()
axes = a3.Axes3D(f)
mesh.add_plot(axes, showaxis=True)
mesh.find_node(axes, node=c, markersize=300)
pl.show()


コード例 #3
0
                np.minimum(d[phiSign < 0], 0)**2) + np.maximum(
                    np.maximum(e[phiSign < 0], 0)**2,
                    np.minimum(f[phiSign < 0], 0)**2))

    return hg


n = int(sys.argv[1])
nx = n
ny = n
nz = n

box = [-2, 2, -2, 2, -2, 2]
cxy = (0.0, 0.0, 0.0)
r = 1
interface0 = Sphere(cxy, r)

interface = lambda p: sphere(p, cxy, r)

mesh = StructureHexMesh(box, nx, ny, nz)

dx = (box[1] - box[0]) / nx
dy = (box[3] - box[2]) / ny
dz = (box[5] - box[4]) / nz

point = mesh.point
N = point.shape[0]
phi = interface(point)

phiSign = sign(phi)