import matplotlib.pyplot as plt

from fealpy.mesh.level_set_function import Sphere
from fealpy.model.surface_parabolic_model_3d import SinSinSinExpData
from fealpy.femmodel.SurfaceHeatFEMModel import SurfaceHeatFEMModel
from fealpy.quadrature import TriangleQuadrature

from fealpy.tools.show import showmultirate

m = int(sys.argv[1])
p = int(sys.argv[2])
q = int(sys.argv[3])

if m == 1:
    model = SinSinSinExpData()
    surface = Sphere()
    mesh = surface.init_mesh()
    mesh.uniform_refine(n=0, surface=surface)

initTime = 0.0
stopTime = 1.0
N = 4000

integrator = TriangleQuadrature(q)
fem = SurfaceHeatFEMModel(mesh,
                          surface,
                          model,
                          initTime,
                          stopTime,
                          N,
                          method='FM',
Beispiel #2
0
        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())
Beispiel #3
0
from time import time

import numpy as np

import pylab as pl
import mpl_toolkits.mplot3d as a3

from fealpy.mesh.level_set_function import Sphere
from fealpy.mesh.level_set_function import DistDomain3d
from fealpy.mesh.distmesh import DistMesh3d
from fealpy.mesh.sizing_function import huniform

fd = Sphere()
fh = huniform
bbox = [-1, 1, -1, 1, -1, 1]
h = 0.1

domain = DistDomain3d(fd, fh, bbox)
distmesh3d = DistMesh3d(domain, h)
distmesh3d.run(100)
mesh = distmesh3d.mesh
ax0 = a3.Axes3D(pl.figure())
mesh.add_plot(ax0)
pl.show()
Beispiel #4
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)