Overwrite vector in assembly
Hello everyone!
I am trying to overwrite a previously computed vector, say u, and assign some new values to it. My previous question is related to this same subject, but I think this example might provide further understanding!
from dolfin import *
mesh = UnitSquare(5, 5)
mf = FacetFunction(
mf.set_all(0)
V = VectorFunctionS
v = TestFunction(V)
u = Function(V)
#We set u to some value, just so it is initialized
u.vector()[:] = 1.
class DomainBoundary(
def inside(self, x, on_boundary):
return on_boundary
DomainBoundary(
#Say I want to set all values on the boundary to (0.2, 0.), I was thinking on doing:
f = Constant((0.2,0.))
L = inner(f, v)*ds(1)
assemble(L, tensor=u.vector(), exterior_
File('u_end.pvd') << u
But I do not get the expected result... Is there another way I could achieve this?
Note that this is a really simple example, and f would be generic in my case. In fact, it depends on u.
Thanks,
Marcos
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Mikael Mortensen
- Solved:
- Last query:
- Last reply: