How to set a value in a GenericMatrix
Hello,
i want to set a value in a GenericMatrix, but using i following approach doesn't work.
from dolfin import*
import numpy as numpy
n = 10
mesh = UnitSquareMesh(n, n)
V = VectorFunctionS
n = FacetNormal(mesh)
trace_n = TrialFunction(V)
phi = TestFunction(V)
a = inner(trace_
L = inner(n,phi)*ds
A = assemble(a)
B = assemble(L)
size = A.array().shape[0]
for i in range(0, size-1):
if A.array(
A.array()[i,i] = 1
trace_n = Function(V)
solve(A, trace_n.vector(), B)
The command A.array()[i,i] = 1 doesn't assign the 1 to the postion (i,i) of the Matrix A.
Does it only works with A.set() command and is there an example for using it in python?
(The meaning of the code is to avoid the ident_zeros() function, because it produces
a known bug, which will be fixed in the next release of dolfin. I know that there exits a
fix by jan blechta, but trying to complie this dolfin development version with just using
cmake ., make install on an ubuntu 12.04 system causes a lot of compilation errors. So I
thought looking for an alternative might be easier.)
Thank you very much
edwin
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Edwin Mai
- Solved:
- Last query:
- Last reply: