KVSlab / turtleFSI

Monolithic Fluid-Structure Interaction (FSI) solver
https://turtlefsi2.readthedocs.io/en/latest/
GNU General Public License v3.0
63 stars 23 forks source link

right hand side vector `b` newly created at every time step? #78

Closed keiyamamo closed 1 year ago

keiyamamo commented 1 year ago

I noticed that right hand side vector b is newly created in every time step as it is not returned at the end of newton iteration. Here is the print of ID from first five time step

ID of b: 4335405648 at time step 0
ID of b: 6296605200 at time step 1
ID of b: 6309206976 at time step 2
ID of b: 6311653712 at time step 3
ID of b: 6305607536 at time step 4
ID of b: 6413148672 at time step 5

Since b is originally set to None inside solver_setup function, b becomes None again after completing one time step, and turtle assign new b in every time step as b is None at the beginning of every time step. Specifically, line 85 of newtonsolver.py gets called at the beginning of every time step instead of line 87

https://github.com/KVSlab/turtleFSI/blob/34925bed03008e463ce6ddc82b875287fc866177/turtleFSI/modules/newtonsolver.py#L84-L87

I do not know how much impact it has, but I assume it is a waste of memory to create new b. Just adding b as a part of return arguments at the end of newton iteration should fix the problem. https://github.com/KVSlab/turtleFSI/blob/34925bed03008e463ce6ddc82b875287fc866177/turtleFSI/modules/newtonsolver.py#L114

- return dict(up_sol=up_sol, A=A)
+ return dict(up_sol=up_sol, A=A, b=b)
keiyamamo commented 1 year ago

Could I have your opinion on this @jorgensd when you have time ?