This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Using non-integral in variational formulation with dg spaces

0 votes

mesh = UnitIntervalMesh(nx)

Define function spaces

V0 = FunctionSpace(mesh, "DG", 1)
W = MixedFunctionSpace([V0, V0])
...
c = Constant(1.0 / assemble(1.0 * dx(mesh)))

I obtain:
TypeError: unsupported operand type(s) for *: 'float' and 'Measure'
Thanks

closed with the note: Solved (old version of FEniCS)
asked Jan 27, 2016 by jesus FEniCS Novice (300 points)
closed Feb 4, 2016 by johannr

What version of fenics are you using? In fenics 1.6 your code works fine (maybe the error is produced in another line of your code).

And please include a complete minimal example.

Effectively, I had old version, with 1.6 no problem.
Thanks!

Hi:
I am trying to solve next problem:
enter image description here

in fact I add the equations in unique equation. I don't get the 4 summations following the previous idea with c * inner(I, V) * dx where c = Constant(1.0 / assemble(1.0 * dx(mesh)))

DG 1D using Cockburn

from dolfin import *
import sys, numpy

mesh = UnitIntervalMesh(4) # Define function spaces
V0 = FunctionSpace(mesh, "DG", 2)
W = MixedFunctionSpace([V0, V0])

Define boundary conditions

tol = DOLFIN_EPS
def left_boundary(x, on_boundary):
return on_boundary and abs(x[0]) < tol

def right_boundary(x, on_boundary):
return on_boundary and abs(x[0]-1.0) < tol
Gamma_0 = DirichletBC(W.sub(0), Constant(2.0), left_boundary)
Gamma_1 = DirichletBC(W.sub(0), Constant(1.0), right_boundary)
bcs = [Gamma_0, Gamma_1]

(u,q) = TrialFunctions(W)
(vu,vq) = TestFunctions(W)
w = Function(W)
u, q = (w[0],w1)

Define parameters

alfa = 0.00001
beta = alfa
auxv = as_vector((1.0, 1.0))

h = Expression('2.0 -x[0] ')
h2 = Expression('(2.0 -x[0])(2.0 -x[0]) ')
h3 = Expression('(2.0 -x[0])
(2.0 -x[0])*(2.0 -x[0])')
hdx = Expression('-1.0 ')

auxu = alfa + beta*u

aux1 = sqrt(h(alfa + betau))

aux2 = sqrt(halfa)
hu = u
(1.0-alfa) - betauu - qaux1
hq = (-2.0/(3
sqrt(betah)))(aux1aux1aux1 - aux2aux2aux2)

c = Constant(1.0 / assemble(1.0 * dx(mesh)))

f = Constant(0.0)
L = fvqdx
a = -inner(hu,vu.dx(0))dx
b = inner(q,vq)
dx - inner(hq,vq.dx(0))*dx
F = a + b - L

J = derivative(F,w)
problem = NonlinearVariationalProblem(F,w,bcs=bcs,J=J)
solver = NonlinearVariationalSolver(problem)
solver.solve()

extract solutions from our mixed-space function

(u,q) = w.leaf_node().split()

I'm sorry by the lenght of the code. Thanks

Please create a new question.

...