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

Add VolumeHistogram vector postprocessor #7803

Merged
merged 3 commits into from Oct 6, 2016

Conversation

dschwen
Copy link
Member

@dschwen dschwen commented Oct 3, 2016

Let's the user obtain a histogram of the volume fractions occupied by a certain variable value.

Closes #7801

virtual void initialize();
virtual void execute();
virtual void finalize();
virtual void threadJoin(const UserObject & y);
Copy link
Member

Choose a reason for hiding this comment

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

It's interesting that this new test failed. Before diving in, make sure these are all getting called properly (i.e. declare them override)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, right, general vs. element vector postprocessors is still a bit muddy to me. Technically those are just user objects, right, so they should work as expected. I'll investigate.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, element types should have threadJoin defined and called on them.

_max_value(getParam<Real>("max_value")),
_deltaV((_max_value - _min_value) / _nbins),
_value(coupledValue("variable")),
_bin_center(declareVector(getVar("variable", 0)->name())),
Copy link
Member

Choose a reason for hiding this comment

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

Interesting that you've chosen to make the name dynamic. That's pretty cool for seeing different column names in your output file. The downside of this is that it makes it a little trickier to couple to this vector from another object should you need that. Are you sure you want to do it this way?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, I don't really have a strong opinion on it. I thought it was nice to have the data file self-document.

Copy link
Member

Choose a reason for hiding this comment

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

It is, it's just that if you plan to couple to this vector having the name change out from underneath you will be a bit of a pain. If that's not your use case, no problem. Just a suggestion.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, let's keep it as it is. The same pattern is uses in SamplerBase and similarly in VectorOfPostprocessors.

Copy link
Member

@permcody permcody left a comment

Choose a reason for hiding this comment

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

Looks ok, You'll have to dig a little deeper to figure out why this doesn't work with threads.

VolumeHistogram::initialize()
{
// reset the histogram
_volume.assign(_nbins, 0.0);
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

void
VolumeHistogram::finalize()
{
gatherSum(_volume);
Copy link
Member

Choose a reason for hiding this comment

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

I hate gatherSum!

Copy link
Member Author

Choose a reason for hiding this comment

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

but.. but.. you not only allow it, you provide it. It is a freaking MOOSE function!!!!

Copy link
Member

Choose a reason for hiding this comment

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

I'm just complaining. I plan to deprecate it moving forward.

Copy link
Member Author

Choose a reason for hiding this comment

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

And replace it by what?

Copy link
Member

Choose a reason for hiding this comment

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

To be clear, I'm not asking you to change this on this PR.

To answer your question:
_communicator.sum()
I don't see any purpose to wrapping a very, very small subset of the methods available on the communicator. It doesn't make anything "easier" or clearer. I'd rather see that the communicator object is involved and just go look at the available methods. Also if you need to do a sum and then some other operation that's not wrapped in the same post processor should you mix these styles?

Copy link
Contributor

Choose a reason for hiding this comment

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

See my thoughts on these convenience functions here: #7820

const VolumeHistogram & uo = static_cast<const VolumeHistogram &>(y);
mooseAssert(uo._volume.size() == _volume.size(), "Inconsistent volume vector lengths across threads.");

for (unsigned int i = 0; i < _volume.size(); ++i)
Copy link
Member

Choose a reason for hiding this comment

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

Not going to use beginindex()?

Copy link
Member

Choose a reason for hiding this comment

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

In fact this could just be done with a range based for loop

Copy link
Member Author

Choose a reason for hiding this comment

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

and std::distance?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, missed that, scratch the range based suggestion. I don't think std::distance should be used for things like this.

@permcody permcody self-assigned this Oct 5, 2016
VectorPostprocessorValue _volume_tmp;

/// aggregated global volume vector
VectorPostprocessorValue & _volume;
Copy link
Member

Choose a reason for hiding this comment

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

@friedmud - Look at the implementation here:

This is basically the correct way to implement a VectorPostprocessor given the current system constraints. We have to (or probably should) create one or more VectorPostprocessorValue members to use for processing information during execute() and/or threadJoin(), then we have the final member that we hold a reference to from the call to declareVector().

See the rest of my comments and a suggestion for an alternative design on #7809.

Copy link
Member

@permcody permcody left a comment

Choose a reason for hiding this comment

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

This looks good, Thanks

@permcody permcody merged commit 617cb76 into idaholab:devel Oct 6, 2016
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.

None yet

3 participants