In [5]:
import petsc4py
import sys
petsc4py.init(sys.argv)
from petsc4py import PETSc
import mshr
from dolfin import *
import sympy as sy
import numpy as np
import ExactSol
import MatrixOperations as MO
import CheckPetsc4py as CP
n = 4
# domain = mshr.Rectangle(Point(-1., -1.), Point(1., 1.)) - mshr.Rectangle(Point(0., -1.), Point(1., 0.) )
# mesh = mshr.generate_mesh(domain, n)
mesh = RectangleMesh(-1,-1,1,1,n,n, 'crossed')
cell_f = CellFunction('size_t', mesh, 0)
for cell in cells(mesh):
v = cell.get_vertex_coordinates()
y = v[np.arange(0,6,2)]
x = v[np.arange(1,6,2)]
xone = np.ones(3)
xone[x > 0] = 0
yone = np.ones(3)
yone[y < 0] = 0
if np.sum(xone)+ np.sum(yone)>5.5:
cell_f[cell] = 1
mesh = SubMesh(mesh, cell_f, 0)
In [6]:
plot(mesh)
Out[6]:
In [ ]: