SimVascular / svOneDSolver

A C++ solver for blood flow and pressure in deformable 1D hemodynamic networks
Other
15 stars 18 forks source link

Prevent simulations from randomly crashing #78

Closed mrp089 closed 3 years ago

mrp089 commented 3 years ago

What the user sees:

What happens in svOneDSolver for elements with NaN residual:

This is strange for several reasons:

mrp089 commented 3 years ago

Turns out there is a vector K that is initialized with length 1000 for good measure:

https://github.com/SimVascular/svOneDSolver/blob/0f63379bf5207ab56dadebc4acc72b9803e07d61/Code/Source/cvOneDSubdomain.cxx#L58-L61

A function SaveK stores new values in K:

https://github.com/SimVascular/svOneDSolver/blob/0f63379bf5207ab56dadebc4acc72b9803e07d61/Code/Source/cvOneDSubdomain.cxx#L411-L413

This function is then used in N_MinorLoss and assigns values to K at the current time step:

https://github.com/SimVascular/svOneDSolver/blob/0f63379bf5207ab56dadebc4acc72b9803e07d61/Code/Source/cvOneDMthSegmentModel.cxx#L318

So if the time step exceeds the length of K (i.e. 1000) -> Trouble!

There is only one other place where K is used (within post-processing): https://github.com/SimVascular/svOneDSolver/blob/0f63379bf5207ab56dadebc4acc72b9803e07d61/Code/Source/cvOneDBFSolver.cxx#L218-L219

However, val is not used. So... I'll just delete any occurrence of K.