DG upwind crashes in 2D
I have working 1D code, it works fine:
-------
from dolfin import *
# Load mesh
mesh = UnitInterval(14)
# Defining the function spaces
V_dg = FunctionSpace(mesh, "DG", 8)
V_cg = FunctionSpace(mesh, "CG", 5)
V_u = FunctionSpace(mesh, "CG", 2)
# Create velocity Function
vel= Expression(
u = project(vel, V_u)
plot(u)
# Test and trial functions
v = TestFunction(V_dg)
phi = TrialFunction(V_dg)
# Diffusivity
kappa = Constant(8E-8)
# Source term
f1 = Expression(
f2 = kappa*pi*
f = f1+f2
F = project(f, V_cg)
plot(F)
# Penalty term
alpha = Constant(5.0)
gamma = Constant(12.0)
# Mesh-related functions
n = FacetNormal(mesh)
h = CellSize(mesh)
h_avg = (h('+') + h('-'))/2
fi = -(dot(u, n) - abs(dot(u, n)))/(2.0*dot(u,n))
boundary = Expression(
sigma = - div(u)
#sigma = Constant('0')
# Bilinear form
a_int = dot(grad(v), kappa*grad(phi))*dx + dot(grad(v), u)*phi*dx - v*phi*sigma*dx
a_fac = 0*kappa(
- dot(avg(
+ dot(jump(v, n), avg(kappa*
a_vel = dot((v('+')*n('+') + v('-')*
a_bound = gamma/h*v*phi*ds
#a_bound = dot(kappa*
a = a_int + a_fac + a_vel + a_bound
# Linear form
L = v*f*dx + gamma/h*
#L = v*f*dx + dot(kappa*
# Solution function
phi_h = Function(V_dg)
# Assemble and apply boundary conditions
A = assemble(a)
b = assemble(L)
# Solve system
solve(A, phi_h.vector(), b)
# Plot solution
plot(phi_h)
interactive()
-------
I've changed mesh and velocity:
mesh = UnitSquare(30,60)
V_u = VectorFunctionS
vel = Expression (('x[0]-0.5','0'))
and I've got error massege:
-------
plot(phi_h)
File "/usr/lib/
return viper_dolfin.
File "/usr/lib/
fig = _plotter.plot(data, **kwargs)
File "/usr/lib/
return self.autoplot(
File "/usr/lib/
plotter = Viper(plot_object, *args, **kwargs)
File "/usr/lib/
self.plot(data, *args, **kwargs)
File "/usr/lib/
plot_
File "/usr/lib/
assert vmax >= vmin, "Empty range, please specify vmin and/or vmax"
AssertionError: Empty range, please specify vmin and/or vmax
-------
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Michał Wichrowski
- Solved:
- Last query:
- Last reply: