Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Truong,
I saw your post on cfdonline.com. As the other commenters pointed out, there are some inefficiencies in your code.
Although i am not very experienced in software development either, i applied my current experience with this pull request.
Most changes are regarding changing copying objects to copying their reference only. Moreover, I applied std algorithms where I think they apply. This reduced the call graph by about a magnitude, and reduced the run time by about a half (1.2 seconds to 0.66 seconds on my machine). The serial parts such as writing could be accelerated by avoiding std::endl since this always contains a std::flush. I replaced it with '\n' to keep it in memory as long as possible. Though there is the disadvantage that it leads to higher memory consumption. For very large files, there might be more intermittent flushes necessary.
The slowest part is now the FvmMesh2D::detectNearestNeighbor() method. The current changes to that method are worth about half of the performance gains mentioned above. I believe, this state seems to be not optimal. I didn't attempt to think this part through though...
Additum:
I added a cmake file for my convenience. Since I did not know how you label the executable, I set the placeholder "gmshToX", lacking any good ideas, here =)
Best,
Sebastian