Skip to content

More region#839

Merged
ZedThree merged 5 commits intonextfrom
more_region
Feb 23, 2018
Merged

More region#839
ZedThree merged 5 commits intonextfrom
more_region

Conversation

@dschwoerer
Copy link
Contributor

add the region to the interface of the min/max functions.

Part of #742

Also add dataiterator interface to fieldperp

bendudson
bendudson previously approved these changes Feb 6, 2018
Copy link
Contributor

@bendudson bendudson left a comment

Choose a reason for hiding this comment

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

This is really two changes, but they both look sensible.

@dschwoerer
Copy link
Contributor Author

Ok, i will make smaller PRs 👍
Wasn't sure how small they should be.

@bendudson
Copy link
Contributor

No problem; keep them coming ;)

@ZedThree
Copy link
Member

ZedThree commented Feb 6, 2018

Please could you add unit tests for the min/max functions? Should be easy enough to copy the existing ones in tests/unit/field/test_field3d.cxx but add regions and just check that they get the values in the boundaries.

ZedThree
ZedThree previously approved these changes Feb 6, 2018
0, nz-1};
break;
default:
throw BoutException("Field3D::region() : Requested region not implemented");
Copy link
Member

Choose a reason for hiding this comment

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

Exception message should use field perp rather than 3D I think.

const DataIterator begin() const;
const DataIterator end() const;

const IndexRange region(REGION rgn) const;
Copy link
Member

Choose a reason for hiding this comment

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

This seems separate from the addition of regions to min/max and doesn't seem to be used, is this in preparation for something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is unrelated.
It allows to iterate over a fieldperp - but I don't think I use it in the aiolos mesh.
It is rather to unify the fields.

@d7919
Copy link
Member

d7919 commented Feb 6, 2018

Is it worth doing a similar thing for checkData?

@dschwoerer
Copy link
Contributor Author

I am not sure - checkData is not a member function - so not sure that would work.
But we could implement checkData for Field, rather for the specific fields, if they all have the needed functions ...

@d7919
Copy link
Member

d7919 commented Feb 6, 2018

I think min and max aren't member functions either.

@bendudson
Copy link
Contributor

Generally I have tried to reduce the number of member functions: wherever possible code should use the class public API, and not depend on private implementation details. Reducing the size of the class helps make it more comprehensible. Proof by counterexample: the giant mess that is Mesh...

@dschwoerer
Copy link
Contributor Author

oh, you meant adding a REGION arguments?
Sorry, I thought you meant specifiing it in field.

But I think min, max, checkData and maybe more functions could equally well be defined over Field, rather than over the specific fields.

@d7919
Copy link
Member

d7919 commented Feb 6, 2018

Sorry I should have been clearer!

@bendudson
Copy link
Contributor

We could define Field versions, but then would need an efficient way to iterate over them without just casting back to Field2D/Field3D etc. If just the base class then indexing would be a virtual function call. We could perhaps make them template functions, but I don't think that has much advantage over the current scheme of using a consistent interface for the overloaded functions.

@dschwoerer
Copy link
Contributor Author

@bendudson How do the z boundaries work?
I cannot see zstart or zend in the mesh.

@bendudson
Copy link
Contributor

@dschwoerer At the moment Z boundaries are just done in an ad-hoc way e.g. https://github.com/bendudson/isothermal-4field/blob/master/isothermal-4field.cxx#L228
I'm not proud of it, but it works for now. Longer term, it would be nice to have a way to consistently introduce boundaries in Z.

*/
virtual int getNz() const;

/// Make region mendatory for all fields
Copy link
Member

Choose a reason for hiding this comment

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

Typo: "mandatory"

*
* @param[in] f The field to loop over
* @param[in] allpe Minimum over all processors?
* @param[in] rgn the boundaries that should be ignored
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be "rgn Calculate the minimum inside this region".

Currently it sounds like rgn should contain the points you want to ignore, rather than the points you want to consider

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rgn can only be used to ignore the boundaries - no general region.
maybe

rgn  The boundaries to be included in the calculation

?

Copy link
Member

Choose a reason for hiding this comment

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

What about RGN_ALL? We're also moving towards supporting very general regions which may even be some subset of the interior points, so this should be

* @param[in] rgn  The region to calculate the minimum over

and likewise for max

Copy link
Contributor Author

Choose a reason for hiding this comment

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

RGN_ALL means to include all boundaries - so matches the description as far as I understand.

I wrote the documentation for what is currently done - not what will be possible in the future.
I can change of course - but I am not the expert on the generalized region thing, am not sure whether or when it is going to get merged, when that function is adapted, so I didn't match it.

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.

4 participants