def scftmodel2d_options(nspecies=2, nblend=1, nblock=2, ndeg=100, fA=0.2, chiAB=0.25, dim=2, T0=4, T1=16, nupdate=1, order=1, integrator=TriangleQuadrature(3)): """ Get the options used in model. """ # the parameter for scft model options = { 'nspecies': nspecies, 'nblend': nblend, 'nblock': nblock, 'ndeg': ndeg, 'fA': fA, 'chiAB': chiAB, 'dim': dim, 'T0': T0, 'T1': T1, 'nupdate': nupdate, 'order': order, 'integrator': integrator } options['chiN'] = options['chiAB'] * options['ndeg'] return options
if m == 1: model = ObstacleData1() quadtree = model.init_mesh(n=3, meshtype='quadtree') elif m == 2: model = ObstacleData2() #mesh = load_mesh('nonconvexpmesh1.mat') #h0 = 0.2 #mesh = distmesh2d(fd, h0, bbox, pfix, meshtype='polygon') n = 20 mesh = rectangledomainmesh([-2, 2, -2, 2], nx=n, ny=n, meshtype='polygon') errorType = [ '$\| u - \Pi^\\nabla u_h\|_0$', '$\|\\nabla u - \\nabla \Pi^\\nabla u_h\|$' ] integrator = TriangleQuadrature(3) vem = ObstacleVEMModel2d(model, mesh, p=p, integrator=integrator) Ndof = np.zeros((maxit, ), dtype=np.int) errorMatrix = np.zeros((len(errorType), maxit), dtype=np.float) data = {} for i in range(maxit): print('step:', i) vem.solve(solver='direct') Ndof[i] = vem.vemspace.number_of_global_dofs() errorMatrix[0, i] = vem.L2_error() errorMatrix[1, i] = vem.H1_semi_error() data['uh{}'.format(i + 1)] = vem.uh data['elem{}'.format(i + 1)] = mesh.ds.cell
def integrator(self, k): return TriangleQuadrature()
from fealpy.quadrature import FEMMeshIntegralAlg integralalg = FEMMeshIntegralAlg(mesh, 3) integralalg.mesh_integral(u, q=3, power=2) integralalg.error(u, uh, q=3, power=2) from fealpy.quadrature import TriangleQuadrature qf = TriangleQuadrature(3) bcs, ws = qf.get_quadrature_points_and_weights()