-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[VTU] Fixed pvd output #2036
[VTU] Fixed pvd output #2036
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only small things.
ProcessLib/Output.cpp
Outdated
void Output::doOutputAlways(Process const& process, | ||
const int process_id, | ||
ProcessOutput const& process_output, | ||
unsigned timestep, | ||
const double t, | ||
GlobalVector const& x) | ||
{ | ||
const bool make_output = | ||
!(process_id < static_cast<int>(_single_process_data.size()) - 1 && | ||
!(process.isMonolithicSchemeUsed())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the expression would be more readable if it was rephrased as:
process_id == static_cast<int>(_single_process_data.size()) - 1
|| process.isMonolithicSchemeUsed();
Btw.: Is there a special reason why the last process writes output (i.e. process_id == static_cast<int>(_single_process_data.size()) - 1
), and not the first one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed. A comment was added as the reason as
// For the staggered scheme for the coupling, only the last process, which
// gives the latest solution within a coupling loop, is allowed to make
// output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks.
ProcessLib/Output.cpp
Outdated
SingleProcessData* spd_ptr = nullptr; | ||
for (auto spd_it=spd_range.first; spd_it!=spd_range.second; ++spd_it) | ||
{ | ||
if(counter == process_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious: Is there a one-to-one correspondence between a process_id
and a process
in _single_process_data
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, they are. However In the present code, each process outputs VTU file with all variables of all processes. We may need an option that allows one process only output its own variables in future. Therefore, I keep Output::SingleProcessData for this purpose. Otherwise,
- struct Output::SingleProcessData can be removed by enabling MeshLib::IO::PVDFile pvd_file as a member of class Output directly.
std::multimap<Process const*, SingleProcessData> _single_process_data;
can be dropped too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However In the present code, each process outputs VTU file with all variables of all processes.
But since only the last process writes output, everything is written only once, right?
We may need an option that allows one process only output its own variables in future.
Not sure, because then the grid would be written even more often than it's written now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However In the present code, each process outputs VTU file with all variables of all processes.
But since only the last process writes output, everything is written only once, right?
Yes, it is.
We may need an option that allows one process only output its own variables in future.
Not sure, because then the grid would be written even more often than it's written now.
If it is not needed, I can remove struct Output::SingleProcessData
in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, a later PR is fine. Maybe, once everything settled, a cleanup of the output logic would be appropriate anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good. Another PR to clean up the output logic including to remove struct Output::SingleProcessData
.
ProcessLib/Output.cpp
Outdated
@@ -249,10 +235,32 @@ void Output::doOutputNonlinearIteration(Process const& process, | |||
return; | |||
} | |||
|
|||
const bool make_output = | |||
!(process_id < static_cast<int>(_single_process_data.size()) - 1 && | |||
!(process.isMonolithicSchemeUsed())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also be simplified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
ProcessLib/Output.cpp
Outdated
BaseLib::RunTime time_output; | ||
time_output.start(); | ||
|
||
findSingleProcessData(process, process_id); | ||
auto spd_range = _single_process_data.equal_range(&process); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this entire green block could be moved to a separate method SPD* getSingleProcessData(int process_id)
and also used above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a new member function for that. Since the new member can not have const modifier, the const modifer of doOutputNonlinearIteration
was dropped.
ProcessLib/Output.cpp
Outdated
!(process_id < static_cast<int>(_single_process_data.size()) - 1 && | ||
!(process.isMonolithicSchemeUsed())); | ||
doProcessOutput(output_file_path, make_out, _output_file_compression, | ||
doProcessOutput(output_file_path, make_output, _output_file_compression, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really/still necessary that doProcessOutput()
is passed the argument make_output
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added it again. Because doProcessOutput adds variable to vtu although the output can be skipped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see: Writing the output file is skipped if it's not the last process.
Anyway, thanks for your effort.
@endJunction It is OK if all benchmarks pass the test. |
@wenqing Jenkins is fine again. |
auto spd_range = _single_process_data.equal_range(&process); | ||
unsigned counter = 0; | ||
int counter = 0; | ||
SingleProcessData* spd_ptr = nullptr; | ||
for (auto spd_it=spd_range.first; spd_it!=spd_range.second; ++spd_it) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is safe_advance
solution on SO https://stackoverflow.com/a/1057782 .
Could be implemented in BaseLib or be done later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This loop will be remove after removing Output::SingleProcessData
, which will be presented in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
safe advance algorithm can be implemented optionally; can be merged
@bilke Thanks. |
Thank you! |
OpenGeoSys development has been moved to GitLab. |
This PR fixes #2020.