Esempio n. 1
0
 def show_frame_test(self):
     fig = plt.figure()
     axes = fig.gca(projection='3d')
     mfactory = MeshFactory()
     mesh = mfactory.one_tetrahedron_mesh()
     space = ScaledMonomialSpace3d(mesh, p=1)
     space.show_frame(axes)
     plt.show()
Esempio n. 2
0
 def diff_index_test(self, p=3):
     mfactory = MeshFactory()
     mesh = mfactory.one_tetrahedron_mesh()
     space = ScaledMonomialSpace3d(mesh, p=p)
     index = space.diff_index_1()
     print(index)
     index = space.diff_index_2()
     print(index)
Esempio n. 3
0
 def one_tet_mesh_test(self, p, plot=True):
     mfactory = MeshFactory()
     mesh = mfactory.one_tetrahedron_mesh()
     space = ScaledMonomialSpace3d(mesh, p=p)
     if plot:
         fig = plt.figure()
         axes = fig.gca(projection='3d')
         mesh.add_plot(axes)
         axes.set_axis_off()
         plt.show()
Esempio n. 4
0
    def cell_basis_test(self):
        mfactory = MeshFactory()
        mesh = mfactory.one_tetrahedron_mesh(ttype='iso')
        space = ScaledMonomialSpace3d(mesh, p=2)

        bc = np.array([[1, 0, 0, 0]])
        point = mesh.bc_to_point(bc, 'cell')
        print(point.shape)
        print(space.cellsize)
        phi = space.basis(point)
        print(phi)
Esempio n. 5
0
    def face_basis_test(self):
        mfactory = MeshFactory()
        mesh = mfactory.one_tetrahedron_mesh(ttype='iso')
        space = ScaledMonomialSpace3d(mesh, p=1)

        face = mesh.entity('face')
        print(face)
        print('frame:', space.faceframe)
        bc = np.array([[1 / 3, 1 / 3, 1 / 3]])
        bc = np.array([[1, 0, 0]])
        point = mesh.bc_to_point(bc, 'face')
        print(point.shape)
        phi = space.face_basis(point)
        print(phi)
Esempio n. 6
0
    def __init__(self,
                 vdata,
                 cdata,
                 mesh,
                 timeline,
                 p=0,
                 options={
                     'rdir': '/home/why/result',
                     'step': 1000,
                     'porosity': 0.2
                 }):

        self.options = options
        self.vdata = vdata
        self.cdata = cdata
        self.mesh = mesh
        self.timeline = timeline
        self.uspace = RaviartThomasFiniteElementSpace3d(mesh, p=p)
        self.cspace = ScaledMonomialSpace3d(mesh, p=p + 1)

        self.uh = self.uspace.function()  # 速度场自由度数组
        self.ph = self.uspace.smspace.function()  # 压力场自由度数组
        self.ch = self.cspace.function()  # 浓度场自由度数组

        # 初始浓度场设为 0
        ldof = self.cspace.number_of_local_dofs()

        print("cell_mass_matrix:")
        self.M = self.cspace.cell_mass_matrix()
        self.H = inv(self.M)
        self.set_init_velocity_field()  # 计算初始的速度场和压力场

        # vtk 文件输出
        node, cell, cellType, NC = self.mesh.to_vtk()
        self.points = vtk.vtkPoints()
        self.points.SetData(vnp.numpy_to_vtk(node))
        self.cells = vtk.vtkCellArray()
        self.cells.SetCells(NC, vnp.numpy_to_vtkIdTypeArray(cell))
        self.cellType = cellType
Esempio n. 7
0
 def show_face_basis_index_test(self):
     mfactory = MeshFactory()
     mesh = mfactory.one_tetrahedron_mesh()
     space = ScaledMonomialSpace3d(mesh, p=3)
     space.show_face_basis_index(p=3)
Esempio n. 8
0
 def face_index_test(self, p=3):
     mfactory = MeshFactory()
     mesh = mfactory.one_tetrahedron_mesh()
     space = ScaledMonomialSpace3d(mesh, p=p)
     space.face_diff_index_1()