newCell[2 * NC:3 * NC, 0] = range(NN, NN + NC)
        newCell[2 * NC:3 * NC, 1:3] = cell[:, 2:4]

        newCell[3 * NC:4 * NC, 0] = range(NN, NN + NC)
        newCell[3 * NC:4 * NC, 1:3] = cell[:, [3, 0]]
        return TriangleMesh(newNode, newCell)


m = int(sys.argv[1])
meshtype = int(sys.argv[2])
n = int(sys.argv[3])
maxit = 4
box = [0, 1, 0, 1]
if m == 1:
    pde = CosCosData()
elif m == 2:
    pde = ExpData()
elif m == 3:
    pde = PolynomialData()
elif m == 4:
    pde = SinSinData()

Mesh = Meshtype()

ralg = FEMFunctionRecoveryAlg()

errorType = [  #'$|| u_I - u_h ||_{l_2}$',
    #'$|| u - u_h||_{0}$',
    #'$||\\nabla u - \\nabla u_h||_{0}$',
    '$||\\nabla u - G(\\nabla u_h)||_{0}sim$',
Пример #2
0
from fealpy.mesh.simple_mesh_generator import rectangledomainmesh, triangle
from fealpy.functionspace.tools import function_space
from fealpy.form.Form import LaplaceSymetricForm, SourceForm
from fealpy.boundarycondition import DirichletBC
from fealpy.solver import solve
from fealpy.functionspace.function import FiniteElementFunction
from fealpy.erroranalysis import L2_error
from fealpy.model.poisson_model_2d import CosCosData

degree = int(sys.argv[1]) 
qt = int(sys.argv[2])  
n = int(sys.argv[3])

box = [0, 1, 0, 1]

model = CosCosData()
mesh = rectangledomainmesh(box, nx=n, ny=n, meshtype='tri') 
maxit = 4 
Ndof = np.zeros(maxit, dtype=np.int)
error = np.zeros(maxit, dtype=np.float)
ratio = np.zeros(maxit, dtype=np.float)
for i in range(maxit):
    V = function_space(mesh, 'Lagrange', degree)
    uh = FiniteElementFunction(V)
    Ndof[i] = V.number_of_global_dofs() 
    a  = LaplaceSymetricForm(V, qt)
    L = SourceForm(V, model.source, qt)
    bc = DirichletBC(V, model.dirichlet, model.is_boundary)
    point = V.interpolation_points()
    solve(a, L, uh, dirichlet=bc, solver='direct')
    error[i] = L2_error(model.solution, uh, order=qt)