kaipartmann / Peridynamics.jl

A Julia package for parallel peridynamics simulations
https://kaipartmann.github.io/Peridynamics.jl/
MIT License
32 stars 8 forks source link

Question on damage computation #11

Closed vavrines closed 1 year ago

vavrines commented 1 year ago

Since multithreading is explicitly configured in the current code (with tid in most cases), should this line be explicit about the specific thread as well?

https://github.com/kfrb/Peridynamics.jl/blob/4110dd2c62853464314eb617e95b84697f5276c1/src/peridynamics_base.jl#L869

vavrines commented 1 year ago

This can lead to unconsistent sequential and parallel results in computing the damage

kaipartmann commented 1 year ago

Hello @vavrines,

Thank you for reaching out - you have a valid point here. The calculation of the damage with calc_damage is in the current form, one of the functions that only is correct after an update of the body with update_thread_cache! or update_thread_cache_contact!, respectively. All the values of the tid dimensions are added to the first index.

https://github.com/kfrb/Peridynamics.jl/blob/9e26b578d00c27668ff9a3865f89f2116ab1c2c9/src/peridynamics_base.jl#L1121-L1136

Unfortunately, the current version of the main branch had a bug, which resulted in inconsistent damage results for the reference results because the update functions were missing.

Please do not hesitate to contact me if you have further questions.

vavrines commented 1 year ago

Got it. Overall, I think the package is very well written, thanks for creating it! I guess we can close this now.