Hi,
I’m trying to know the value of the solution sigma. I would like to view its values. Can someone help me please.
from dolfin import *
import matplotlib.pyplot as plt
n = 4
mesh = UnitSquareMesh(n, n)
BDM = FiniteElement(“RT”, mesh.ufl_cell(), 1)
DG = FiniteElement(“DG”, mesh.ufl_cell(), 0)
W = FunctionSpace(mesh, BDM * DG)
(sigma, u) = TrialFunctions(W)
(tau, v) = TestFunctions(W)
f = Expression(“10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)”, degree=2)
a = (dot(sigma, tau) + div(tau)*u + div(sigma)v)dx
L = - fvdx
class BoundarySource(UserExpression):
def init(self, mesh, **kwargs):
self.mesh = mesh
super().init(**kwargs)
def eval_cell(self, values, x, ufc_cell):
cell = Cell(self.mesh, ufc_cell.index)
n = cell.normal(ufc_cell.local_facet)
g = sin(5x[0])
values[0] = gn[0]
values[1] = g*n[1]
def value_shape(self):
return (2,)
G = BoundarySource(mesh, degree=2)
def boundary(x):
return x[1] < DOLFIN_EPS or x[1] > 1.0 - DOLFIN_EPS
bc = DirichletBC(W.sub(0), G, boundary)
w = Function(W)
solve(a == L, w, bc)
(sigma, u) = w.split()
print(sigma)
print(u)