velocity field over subdomains in 1 plot
Dear,
I am trying to solve an advection diffusion equation in which the given velocity field is defined over 3 subdomains. I have my own mesh files:
mesh = Mesh("domain.xml")
subdomains = MeshFunction(
boundaries = MeshFunction(
and on each subdomain I have a different velocity, for example:
class uone(Expression):
def eval(self, values, x):
xx=x[0]
yy=x[1]
cc=numpy.sin(xx)
cd=numpy.cos(yy)
def value_shape(self):
return (2,)
u0=Expression(
u1=uone()
u2=Expression(
With these different velocities I can solve an advection diffusion equation for T:
dx=Measure(
ds=Measure(
T = TrialFunction(TT)
w = TestFunction(TT)
f = Constant(0.0)
at = (u0[i]*T.dx(i)*w + w.dx(i)
(u1[
(u2[
Lt = f*w*dx(0) + f*w*dx(1) + f*w*dx(2)
A, bb = assemble_system(at, Lt, bcs)
T = Function(TT)
solve(A, T.vector(), bb)
I have two questions about this code. First of all, as also mentioned in the FEniCS book, defining class uone as I did above is slow. Is there a nice way to speed this up? The second question is, is there a way to plot the velocity field on the whole domain? I have been able to plot the solution on subdomains, but then I get 3 different plots:
sub_mesh0 = SubMesh(
sub_mesh1 = SubMesh(
sub_mesh2 = SubMesh(
sV0 = VectorFunctionS
sV1 = VectorFunctionS
sV2 = VectorFunctionS
Iv0=interpolate
Iv1=interpolate
Iv2=interpolate
plot(Iv0)
plot(Iv1)
plot(Iv2)
I was thinking, maybe there is a way to interpolate u0, u1, u2 to one vector U on the whole domain? The velocity, however, may be discontinuous across the subdomain boundaries, so maybe a DG space? Any help is appreciated.
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Sander Rhebergen
- Solved:
- Last query:
- Last reply: