MixedFunctionSpace with boundary function spaces
Hi, I am trying to solve a non-linear three-dimensional problem coupling elasticity and solvent diffusion. The state variables, defined over a three-dimensional body, are the displacement vector u, the pressure p and the solvent concentration c. To enforce the boundary conditions I have to define additional degrees of freedom (corresponding to a Lagrange multiplier) on the boundary. So, in the end, I have a mixed function space consisting of three spaces (for u, c and p) over the three-dimensional body and one function space over the boundary. When I run the script (see below) I get this error:
Sub elements must live in the same top level domain.
Traceback (most recent call last):
File "swelling_
W = MixedFunctionSp
File "/Applications/
element = ufl.MixedElemen
File "/Applications/
error("Sub elements must live in the same top level domain.")
File "/Applications/
raise self._exception
ufl.log.
My guess is that I cannot define a mixed function space combining function spaces over the 3D domain and function spaces over the boundary: is it right? Is there a workaround for this problem, in case this feature is not supported?
Thanks a lot! AL
==BEGIN SCRIPT==
from dolfin import *
import math
import ufl
mesh = UnitCubeMesh(1,1,1)
V = VectorFunctionS
Q = FunctionSpace(
R = FunctionSpace(
boundary_mesh = BoundaryMesh(mesh, "exterior")
M = FunctionSpace(
W = MixedFunctionSp
# Test and trial functions
vqrm = TestFunction(W) # Test function in the mixed space
v,q,r,tcs = split(vqrm)
dupccs = TrialFunction(W) # Trial function in the mixed space (solution increment)
upccs = Function(W) # Function in the mixed space to store the solution
u,p,c,cs = split(upccs) # Function in each subspace to write the functional
# nonlinear effective diffusion coefficient
def g(c):
return D*((2*chi-
def dmudc(c):
return -(Rg*T)
# Parameters
Omega = 6.023e-5
D = 1E-1
Gdry = 4E5
Rg = 8.314
T = 293.0
lamo = 1.001
Jo = lamo**3
cod = (lamo**3-1.0)/Omega
co = cod/Jo
chi = 0.2
po = Gdry/lamo
muo = Rg*T*(math.
+Omega*po
mus = muo
mutop = -10000
# Kinematics
I = Identity(3)
F = I + grad(u)
J = det(F)
# Constitutive equations
S = (Gdry/lamo)
mu = Rg*T*(ufl.
h = g(c)*grad(
dmudp = Omega
dmu = mu-mus
# Boundary conditions
def left_boundary(x, on_boundary): # x = 0
return on_boundary and abs(x[0]) < DOLFIN_EPS
def back_boundary(x, on_boundary): # y = 0
return on_boundary and abs(x[1]) < DOLFIN_EPS
def bottom_boundary(x, on_boundary): # z = 0
return on_boundary and abs(x[2]) < DOLFIN_EPS
bcl = DirichletBC(
bcb = DirichletBC(
bcbo = DirichletBC(
bc = [bcl,bcb,bcbo]
# WEAK FORM OF BALANCE EQUATIONS
a = inner(S,grad(v))*dx + q*(J-(1.
+ inner(dmudc(
Jac = derivative(
problem = NonlinearVariat
solver = NonlinearVariat
# Initial guess for unknowns
c = interpolate(
p = interpolate(
cs = interpolate(
# solve non-linear problem
solver.solve()
# plot solvent concentration
w = Function(V)
w = upccs.split()[2]
plot(w)
interactive()
==END SCRIPT==
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- al6
- Solved:
- Last query:
- Last reply: