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 isFci for fields #2887

Open
wants to merge 12 commits into
base: next
Choose a base branch
from
12 changes: 12 additions & 0 deletions include/bout/field.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,18 @@ inline bool areFieldsCompatible(const Field& field1, const Field& field2) {
#define ASSERT1_FIELDS_COMPATIBLE(field1, field2) ;
#endif

template <typename F>
inline bool isFci(const F& f) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe canBeFieldAligned? Not sure.

Also, should this be a member function instead? Then it wouldn't need to be templated. If it should really be a free function, it would be good to add a static_assert (see emptyFrom etc) to give a nicer error message if passed the wrong type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe canBeFieldAligned? Not sure.

But I want to know whether it is FCI. If we ever have a different, non-field aligned, non FCI method, we might need to reconsider, but I think isFci (or isFCI) is better, as you can use BOUT++ also for non magnetic simulations, and that is also not field aligned, but not FCI either.

Also, should this be a member function instead? Then it wouldn't need to be templated. If it should really be a free function, it would be good to add a static_assert (see emptyFrom etc) to give a nicer error message if passed the wrong type.

Good point, will make it a member function 👍

const auto coords = f.getCoordinates();
if (coords == nullptr) {
return false;
}
if (not coords->hasParallelTransform()) {
return false;
}
return not coords->getParallelTransform().canToFromFieldAligned();
}

/// Return an empty shell field of some type derived from Field, with metadata
/// copied and a data array that is allocated but not initialised.
template <typename T>
Expand Down