Exemple #1
0
boundaries.set_all(0)


class NeumanBoundary(SubDomain):
    def inside(self, x, on_boundary):
        return on_boundary and near(x[0], 1, tol)


NeumanBoundary().mark(boundaries, 1)

# Define outer surface measure aware of Dirichlet and Neumann boundaries
ds = Measure('ds', domain=mesh, subdomain_data=boundaries)

# Define variational problem
u = TrialFunction(V)
d = u.geometric_dimension()
v = TestFunction(V)
f = Constant((0, 0, 0))
T = Constant((10**3, 0, 0))
a = inner(sigma(u), epsilon(v)) * dx
L = dot(f, v) * dx + dot(T, v) * ds(1)

A = PETScMatrix()
b = PETScVector()
assemble_system(a, L, bc, A_tensor=A, b_tensor=b)

A = A.mat()
b = b.vec()
print('problem size: ', b.getSize())
# =========================================================================