puncproject / PUNCpp

Particles-in-UNstructured-Cells, C++ version
https://punc.readthedocs.io
GNU General Public License v3.0
12 stars 6 forks source link

Avoid reinitializing phi? #43

Closed sigvaldm closed 6 years ago

sigvaldm commented 6 years ago

It is perhaps most convenient the way PoissonSolver::solve() works today, but perhaps it should be tested how much performance gain we would get by not making a new df::Function phi each time? It could be made outside the time-loop and passed as a reference argument to solve(). Not as nice, perhaps, but it wouldn't be unusual in a high performance code (or any C++ code, really).

diakodarian commented 6 years ago

Just tested this for a Laframboise simulation with 1000 time-steps. The timings are 28 sec (reinitialize and return by value) vs. 17 sec (initialize outside the time-loop and pass by reference) for poisson solver.

sigvaldm commented 6 years ago

Absolutely awesome! Add changes to the PoissonSolver to the "objects" branch (now pushed to origin) before this is merged to develop, as it contains significant changes to the PoissonSolver already.

sigvaldm commented 6 years ago

Perhaps also check EField (any others?) while you're at it?

diakodarian commented 6 years ago

Done.