Unable to access vector of degrees of freedom fro function.
I am iterating a non-linear problem using simple 'Picard' iteration (as per the example
at http://
Incidentally, this example does not work with the current version of FEniCS - and needs updating to reflect the
change to the VariationalProb
Anyway, my problem is as follows. I have a MixedFunctionSpace, and I wish to access one of the vectors, to calculate
the norm.
#!/usr/bin/python
from dolfin import *
import numpy
# Parameters
Ra=100.0
XX = 2.0
# uniform mesh
mesh=Rectangle(
V = VectorFunctionS
Q = FunctionSpace(mesh, "CG", 1)
X = MixedFunctionSp
u,p,T = TrialFunctions(X)
w,q,S = TestFunctions(X)
u0=Function(V)
# bilinear form - try to put trial function first...
a = ( inner(grad(
- div(w)*p \
- w[1]*T*Ra \
- q*div(u) \
+ S*dot(u0,grad(T)) \
- dot(grad(
)*dx
f = Constant(0.0)
L = q*f*dx
# Define boundaries
def bound0(
return x[0] < DOLFIN_EPS and on_boundary
def bound1(
return x[0] > XX*(1.0-DOLFIN_EPS) and on_boundary
def bound2(
return x[1] < DOLFIN_EPS and on_boundary
def bound3(
return x[1] > (1.0-DOLFIN_EPS) and on_boundary
## Define BCs for velocity
vzero = Constant((0.0,0.0))
zero = Constant(0.0)
Hsource=
Vbc0 = DirichletBC(
Vbc1 = DirichletBC(
Vbc2 = DirichletBC(
Vbc3 = DirichletBC(
Vbc4 = DirichletBC(
Vbc5 = DirichletBC(
Vbc6 = DirichletBC(
Vbcs = [ Vbc0, Vbc1, Vbc2, Vbc3, Vbc4, Vbc5, Vbc6 ]
U=Function(X)
u,p,T=U.split()
PP = LinearVariation
solver= LinearVariation
#iterate, changing the velocity field each step
for i in range(10):
solver.solve()
diff = u.vector().array() - u0.vector().array()
eps = numpy.linalg.
print eps
u0.assign(u)
*** -------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
*** https:/
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------
*** Error: Unable to access vector of degrees of freedom fro function.
*** Reason: Cannot access a non-const vector from a subfunction.
*** Where: This error was encountered inside Function.cpp.
*** -------
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Praveen C
- Solved:
- Last query:
- Last reply: