示例#1
0
# PDE and solver settings
f = lambda x, y: 1.0
# right hand side of equation is constant
n = 3
# Order n of numerical integration


# --------------------- Loop over mesh widths --------------------------
for k in range(0, J):

    # Mesh generation:
    h = h_0 * 2 ** (-k / 2)
    meshwidths[k] = h
    print("using mesh width h = " + str(meshwidths[k]) + ":")
    # define the mesh using gmsh (corners and singular points are explicitly included as nodes)
    p, t, be = mesh.grid_unstr_sheet10(1.0, 0.5 * h ** 2, h, "meshes/10_4A_" + str(k))
    # generate graded mesh

    # node and element numbers
    N = np.shape(p)[0]
    M = np.shape(t)[0]
    BE = np.shape(be)[0]

    nodes[k] = N
    elements[k] = M
    print("  ", nodes[k], "nodes,", elements[k], "elements")

    # -------- Identify nodes on the Dirichlet boundary ------------
    insideflags = np.ones((N, 1), dtype=bool)
    # will be true for all "Dirichlet-inner" points,
    # i.e., points not contained in the Dirichlet boundary
示例#2
0
energynorms = [None]*J;	# ... energy norms of the discrete solutions

# PDE and solver settings
f = lambda x, y: 1.;	# right hand side of equation is constant
n = 3; 	# Order n of numerical integration


# --------------------- Loop over mesh widths --------------------------
for k in range(0, J):

  # Mesh generation:
  h = h_0*2**(-k/2);
  meshwidths[k] = h;
  print('using mesh width h = '+str(meshwidths[k])+':');
  # define the mesh using gmsh (corners and singular points are explicitly included as nodes)
  p,t,be = mesh.grid_unstr_sheet10(1., h, h, 'meshes/10_3_'+str(k));	# generate quasi-uniform, unstructured mesh
  
  # node and element numbers 
  N = np.shape(p)[0];
  M = np.shape(t)[0];
  BE = np.shape(be)[0];
  
  nodes[k] = N;
  elements[k] = M;
  print('  ',nodes[k],'nodes,',elements[k],'elements')



  # -------- Identify nodes on the Dirichlet boundary ------------
  insideflags = np.ones((N, 1), dtype=bool);	# will be true for all "Dirichlet-inner" points,
						# i.e., points not contained in the Dirichlet boundary