Change coefficient of an assembled matrix
Hi all,
I am trying to implement a well model in a program for biphasic flow in porous media.
I assemble the matrix for the potential (pressure) problem as below:
def Galerkin(self, delfineVar, parameter):
# Get data from case initialization
.
.
.
# Create function space
V = FunctionSpace(mesh, "CG", order)
# Define distributed source terms (not wells)
f = Source()
# Define Neumman boundary conditions (vel.n=0 on borders)
g = Expression("0.0")
# Define variational problem
v = TestFunction(V)
u = TrialFunction(V)
a = inner(grad(v), K*mob*grad(u))*dx
L = v*f*dx - g*v*ds
# Assemble matrices and vectors
A, rhs = assemble_system(a, L)
After that, I would like to change the coefficient of the 'A' matrix relative to a specific vertex representing the well. I already managed to find the index of this vertex, so everything I would like to do is something like:
A[index][index] += value
For example, if my vertex index is 3, in finite differences it would look like:
-- --
|1 1 0 0 0|
|1 -2 -1 0 0|
|0 1 (-2+value) 1 0|
|0 0 1 -2 1|
|0 0 0 1 1|
-- --
How could I do that?? I am using uBlas as the linear algebra backend.
Thank you in advance,
Bruno
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Garth Wells
- Solved:
- Last query:
- Last reply: