Access a vector of a subfunction
Hi,
I'm trying to access a vector of a subfunction to be used by normalize().
V = VectorFunctionS
Q = FunctionSpace(mesh, "CG", 1)
R = FunctionSpace(mesh, "CG", 1)
W = MixedFunctionSp
w = Function(W)
normalize(
AttributeError: 'Indexed' object has no attribute 'vector'
normalize(
TypeError: expected an int, slice, list or numpy array of integers
#W.sub(
(u, p, theta) = w.split()
normalize(
*** 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.
I've found few another ways. One could for example deepcopy p and then interpolate back to w. But it's an extra interpolate instead of simple algebraic operation and it could reduce accuraccy of normalization.
Or it has been suggested here that one could get indeces of w.vector() belonging to p-part by V.dim(), Q.dim() or by num_vertices(). But it will not work in parallel and also num_vertices work-around depends on chosen FunctionSpaces.
Is there any clean way to do it? Thanks
Jan Blechta
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Jan Blechta for more information if necessary.