-
Notifications
You must be signed in to change notification settings - Fork 83
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
Changes for coupling with ERF using MultiBlock #1297
base: main
Are you sure you want to change the base?
Conversation
@@ -58,6 +63,14 @@ public: | |||
SimTime& time() { return m_time; } | |||
const SimTime& time() const { return m_time; } | |||
|
|||
#ifdef ERF_AW_MULTIBLOCK | |||
void set_mbc(MultiBlockContainer* mbc) { m_mbc = mbc; } |
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.
raw pointers make me nervous. Is there some way we could be using unique_ptr instead?
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.
Okay thanks for the suggestion.. I'll surely look into this, it's always good to have a more robust code.
@@ -7,6 +7,10 @@ | |||
#include "amr-wind/utilities/ncutils/nc_interface.H" | |||
#include <AMReX_BndryRegister.H> | |||
|
|||
#ifdef ERF_AW_MULTIBLOCK | |||
#include "amr-wind/wind_energy/ABLReadERFFcn.H" | |||
class MultiBlockContainer; |
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.
are these needed? Like the build breaks without them? I see you do it in a bunch of places.
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.
do you mean the ifdefs? I could remove them from all places where they are not strictly required. My thinking was that maybe you would prefer using the ifdefs to keep out the multiblock stuff as much as possible.
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.
Sorry, I mean the forward declarations.
@@ -47,6 +47,20 @@ public: | |||
void init_tke(const amrex::Geometry& geom, amrex::MultiFab& tke) const; | |||
|
|||
private: | |||
// ABL-with-bubble |
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 the bubble thing something you want to keep? Or was this just a debug thing? If you want to keep it, it might be better to move this to the physics
folder/class. Would you be ok with that?
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.
It is a debug thing where Bruce was using temperature in lieu of a scalar. I would like to use the scalar instead so I'll make that change at some point.
Good work, @mukul1992 ! Left a bunch of questions mostly. |
Thanks for the comments @marchdf @jrood-nrel. I should have referenced this while creating the PR, but here's the driver repo for the ERF/AMR-Wind coupling. This may clarify the cmake related changes and some of the code changes. |
nc += fld->num_comp(); | ||
} | ||
|
||
// FIXME: need to generalize to lev > 0 somehow |
Check notice
Code scanning / CodeQL
FIXME comment
const int lev = 0; | ||
for (amrex::OrientationIter oit; oit != nullptr; ++oit) { | ||
auto ori = oit(); | ||
// FIXME: would be safer and less storage to not allocate all of |
Check notice
Code scanning / CodeQL
FIXME comment
@@ -758,6 +809,19 @@ | |||
return; | |||
} | |||
|
|||
#ifdef ERF_AMR_WIND_MULTIBLOCK | |||
if (m_out_fmt == "erf-multiblock") { | |||
// m_read_erf = sim.get_read_erf(); |
Check notice
Code scanning / CodeQL
Commented-out code
nc += fld->num_comp(); | ||
} | ||
|
||
// FIXME: need to generalize to lev > 0 somehow |
Check notice
Code scanning / CodeQL
FIXME comment Note
const int lev = 0; | ||
for (amrex::OrientationIter oit; oit != nullptr; ++oit) { | ||
auto ori = oit(); | ||
// FIXME: would be safer and less storage to not allocate all of |
Check notice
Code scanning / CodeQL
FIXME comment Note
@@ -758,6 +809,19 @@ | |||
return; | |||
} | |||
|
|||
#ifdef ERF_AMR_WIND_MULTIBLOCK | |||
if (m_out_fmt == "erf-multiblock") { | |||
// m_read_erf = sim.get_read_erf(); |
Check notice
Code scanning / CodeQL
Commented-out code Note
Sounds good! Let us know how we can help get the CI passing for you or any other issues that we can help with. |
9e5f85b
to
b8d3e94
Compare
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 work! Have a couple of quick comments.
AMREX_FORCE_INLINE int closest_index_lbound( | ||
const amrex::Vector<amrex::Real>& vec, const amrex::Real value) | ||
{ | ||
amrex::Real one_minus_eps = 1.0 - 1.e-8; |
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 there a reason for the hardcoded
1e-8
here? should this be closer tostd::numeric_limits<amrex::Real>::epsilon();
? - I'm wondering why this is necessary in the first place for
lower_bound
? Wouldn't you always be guaranteed thatvec[idx -1] < value <= vec[idx]
(foridx > 1
, andvalue <= vec[0]
otherwise)?
{ | ||
const size_t nc = fld->num_comp(); | ||
const int nstart = | ||
static_cast<int>(m_components[static_cast<int>(fld->id())]); | ||
|
||
const int idx = utils::closest_index(times, time); | ||
int idx; |
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 the intention here to have
times[idx] < time <= times[idx+1]
for multiblock instead oftimes[idx] <= time < times[idx+1]
? - I'm a bit confused but the
1+eps
checks below, are they necessary withlbound
?
@@ -758,6 +780,35 @@ void ABLBoundaryPlane::read_header() | |||
m_in_data.define_level_data(ori, pbx, nc); | |||
} | |||
} | |||
} else if (m_out_fmt == "erf-multiblock") { | |||
|
|||
m_in_times.push_back(-1.0e13); // create space for storing time at erf |
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.
would std::numeric_limits<amrex::Real>::epsilon()
work instead of 1e-13?
Summary
These changes allow coupling with ERF via the MultiBlock mechanism. It includes maintaining a pointer to the multiblock container which is defined in the coupling driver. For reading ERF data, it uses the ABL boundary plane mechanism by defining a
read_erf
function in the driver and passing it to a function pointer in AMR-Wind.Pull request type
Please check the type of change introduced:
Checklist
The following is included:
This PR was tested by running: