Skip to content
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

Merged
merged 3 commits into from
Jan 10, 2018
Merged

[VTU] Fixed pvd output #2036

merged 3 commits into from
Jan 10, 2018

Conversation

wenqing
Copy link
Member

@wenqing wenqing commented Jan 9, 2018

This PR fixes #2020.

Copy link
Collaborator

@chleh chleh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only small things.

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()));
Copy link
Collaborator

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?

Copy link
Member Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks.

SingleProcessData* spd_ptr = nullptr;
for (auto spd_it=spd_range.first; spd_it!=spd_range.second; ++spd_it)
{
if(counter == process_id)
Copy link
Collaborator

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?

Copy link
Member Author

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,

  1. struct Output::SingleProcessData can be removed by enabling MeshLib::IO::PVDFile pvd_file as a member of class Output directly.
  2. std::multimap<Process const*, SingleProcessData> _single_process_data; can be dropped too.

Copy link
Collaborator

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.

Copy link
Member Author

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.

Copy link
Collaborator

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.

Copy link
Member Author

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.

@@ -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()));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also be simplified.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

BaseLib::RunTime time_output;
time_output.start();

findSingleProcessData(process, process_id);
auto spd_range = _single_process_data.equal_range(&process);
Copy link
Collaborator

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.

Copy link
Member Author

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.

!(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,
Copy link
Collaborator

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

Copy link
Member Author

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.

Copy link
Collaborator

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.

@wenqing
Copy link
Member Author

wenqing commented Jan 9, 2018

@endJunction It is OK if all benchmarks pass the test.

@bilke
Copy link
Member

bilke commented Jan 9, 2018

@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)
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

@endJunction endJunction left a 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

@wenqing
Copy link
Member Author

wenqing commented Jan 10, 2018

@bilke Thanks.

@wenqing wenqing merged commit 8df3818 into ufz:master Jan 10, 2018
@Thomas-TK
Copy link
Member

Thank you!

@ogsbot
Copy link
Member

ogsbot commented Jun 19, 2020

OpenGeoSys development has been moved to GitLab.

See this pull request on GitLab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pvd contains only last step
6 participants