- Thank you received: 0
Changing the Bilinear Sparse Matrix values
5 years 4 months ago #1666
by Elsakori
Changing the Bilinear Sparse Matrix values was created by Elsakori
Hi,
I am trying to change some of the values of the bilinear sparse matrix (a.mat) after the assemble statement (a.Assemble()) by making them equal zeros.
This is what I tried to do:
print('a.mat.nze1=',a.mat.nze)
if fes.ndof > edges_no:
for i in range(edges_no):
for j in range(edges_no,fes.ndof+1):
if a.mat[i,j] != 0:
a.mat[i,j]=0
a.mat.Update()
print('a.mat.nze2=',a.mat.nze)
But the number of non zeros of the matrix, before and after, is the same the change, which should be change.
I appreciate any clarification and help.
Note: Find attached a copy of the code
I am trying to change some of the values of the bilinear sparse matrix (a.mat) after the assemble statement (a.Assemble()) by making them equal zeros.
This is what I tried to do:
print('a.mat.nze1=',a.mat.nze)
if fes.ndof > edges_no:
for i in range(edges_no):
for j in range(edges_no,fes.ndof+1):
if a.mat[i,j] != 0:
a.mat[i,j]=0
a.mat.Update()
print('a.mat.nze2=',a.mat.nze)
But the number of non zeros of the matrix, before and after, is the same the change, which should be change.
I appreciate any clarification and help.
Note: Find attached a copy of the code
Attachments:
- mneunteufel
- Offline
- Premium Member
Less
More
- Thank you received: 59
5 years 4 months ago #1669
by mneunteufel
Replied by mneunteufel on topic Changing the Bilinear Sparse Matrix values
Hi Elsakori,
the a.mat.Update() call does not recompute the sparsity pattern.
The Update() method is used to refactor the inverse or to update a preconditioner .
In your case the method does nothing, as far as I know.
Best
Michael
the a.mat.Update() call does not recompute the sparsity pattern.
The Update() method is used to refactor the inverse or to update a preconditioner .
In your case the method does nothing, as far as I know.
Best
Michael
5 years 4 months ago #1671
by Elsakori
Replied by Elsakori on topic Changing the Bilinear Sparse Matrix values
Thank you Michael for the explanation. I hope someone give me alternative way to do this.
5 years 4 months ago #1672
by joachim
Replied by joachim on topic Changing the Bilinear Sparse Matrix values
the matrix entries are set to zero, as you wish.
nze gives you the number of potentially non-zero entries of the sparse matrix, but does does not check if they are actually zero numerically
nze gives you the number of potentially non-zero entries of the sparse matrix, but does does not check if they are actually zero numerically
Time to create page: 0.104 seconds