4#include "AMReX_ParallelDescriptor.H"
8#ifdef REMORA_USE_NETCDF
60 amrex::Print() <<
"Setting up boundary data for " <<
field_name <<
" coming from NetCDF file " << std::endl;
70 int ioproc = amrex::ParallelDescriptor::IOProcessorNumber();
79 if (amrex::ParallelDescriptor::IOProcessor())
81 if (
unit_str.find(
"days") == std::string::npos) {
82 amrex::Print() <<
"Units of ocean_time given as: " <<
unit_str << std::endl;
83 amrex::Abort(
"Units must be in days.");
87 amrex::Warning(
"Units attribute not found on time variable " +
time_name +
". Assuming days");
93 if (amrex::ParallelDescriptor::IOProcessor())
99 bry_times.push_back((*(
array_ts[0].get_data() + nt)) * amrex::Real(60.0) * amrex::Real(60.0) * amrex::Real(24.0));
108 if (amrex::ParallelDescriptor::IOProcessor()) {
111 amrex::Error(
"Time series of boundary data must be given at at least two times");
115 if (!(amrex::ParallelDescriptor::IOProcessor())) {
162 if (
var_need_data[amrex::Orientation(amrex::Direction::x,amrex::Orientation::low)] ==
true) {
165 if (
var_need_data[amrex::Orientation(amrex::Direction::x,amrex::Orientation::high)] ==
true) {
168 if (
var_need_data[amrex::Orientation(amrex::Direction::y,amrex::Orientation::low)] ==
true) {
171 if (
var_need_data[amrex::Orientation(amrex::Direction::y,amrex::Orientation::high)] ==
true) {
186 std::string
msg =
"Boundary file " +
file_name +
" does not contain all of:";
190 msg +=
". The boundary condition requested for " +
field_name +
191 " reads from file (clamped, chapman, flather, or orlanski_rad_nudg)."
192 " Either add the missing variable(s) to the file, or give " +
field_name +
193 " a boundary condition that needs no file data, such as outflow.";
213 amrex::Arena*
Arena_Used = amrex::The_Arena();
222 for (
int nt=0; nt <
bry_times.size()-1; nt++) {
285 amrex::Gpu::streamSynchronize();
319 amrex::Gpu::streamSynchronize();
341 if (
var_need_data[amrex::Orientation(amrex::Direction::x,amrex::Orientation::low)] ==
true) {
348 if (
var_need_data[amrex::Orientation(amrex::Direction::x,amrex::Orientation::high)] ==
true) {
355 if (
var_need_data[amrex::Orientation(amrex::Direction::y,amrex::Orientation::low)] ==
true) {
362 if (
var_need_data[amrex::Orientation(amrex::Direction::y,amrex::Orientation::high)] ==
true) {
384 amrex::Gpu::streamSynchronize();
395 if (amrex::ParallelDescriptor::IOProcessor())
401 if (
last4 ==
"west") {
418 for (
int n(0); n <
n_plane; n++) {
423 }
else if (
last4 ==
"east") {
439 for (
int n(0); n <
n_plane; n++) {
444 }
else if (
last5 ==
"south") {
460 for (
int n(0); n <
n_plane; n++) {
465 }
else if (
last5 ==
"north") {
481 for (
int n(0); n <
n_plane; n++) {
490 amrex::ParallelDescriptor::Barrier();
495 int ioproc = amrex::ParallelDescriptor::IOProcessorNumber();
518 amrex::Real
xfac =
one /
static_cast<amrex::Real
>(
rx);
519 amrex::Real
yfac =
one /
static_cast<amrex::Real
>(
ry);
522 if (
dat_crse.box().length(0) == 1) {
524 if (
dat_crse.box().ixType()[1] == 0) {
527 int i_f = (
i == -1) ? -1 :
rx*
i;
533 for (
int n = 1; n <
ry; n++) {
542 int i_f = (
i == -1) ? -1 :
rx*
i;
548 for (
int n = 1; n <
ry; n++) {
555 }
else if (
dat_crse.box().length(1) == 1) {
558 if (
dat_crse.box().ixType()[0] == 0) {
561 int j_f = (
j == -1) ? -1 :
ry*
j;
567 for (
int n = 1; n <
rx; n++) {
576 int j_f = (
j == -1) ? -1 :
ry*
j;
582 for (
int n = 1; n <
rx; n++) {
590 amrex::Abort(
" What am I doing here??");
constexpr amrex::Real one
mf_h setVal(geomdata.ProbHi(2))
AMREX_ALWAYS_ASSERT(!NSPeriodic||!EWPeriodic)
void ReadNetCDFFile(const std::string &fname, amrex::Vector< std::string > names, amrex::Vector< NDArray< DType > > &arrays, bool one_time=false, int fill_time=0)
Read in data from netcdf file and save to data arrays.
bool QueryNetCDFHasVars(const std::string &fname, const amrex::Vector< std::string > &var_names)
Helper function for testing whether a file carries every named variable.
bool QueryNetCDFVarAttrStr(const std::string &fname, const std::string &var_name, const std::string &attr_name)
Helper function for testing for the presence of a single variable attribute.
std::string ReadNetCDFVarAttrStr(const std::string &fname, const std::string &var_name, const std::string &attr_name)
Helper function for reading a single variable attribute.
amrex::FArrayBox yhi_dat_before
FArrayBox to store data at time_before at yhi boundary.
amrex::FArrayBox yhi_dat_after
FArrayBox to store data at time_after at yhi boundary.
amrex::GpuArray< bool, AMREX_SPACEDIM *2 > var_need_data
Array over boundaries indicating whether we need physical data for this variable.
void interp_fab(amrex::FArrayBox &dat_crse, amrex::FArrayBox &dat_fine)
spatially interpolate boundary fabs from level 0 data (read in) to current level
amrex::FArrayBox ylo_dat_before
FArrayBox to store data at time_before at ylo boundary.
amrex::FArrayBox xlo_dat_after
FArrayBox to store data at time_after at xlo boundary.
amrex::Vector< std::string > nc_var_names
Variable names that will be read from file.
amrex::FArrayBox ylo_dat_after
FArrayBox to store data at time_after at ylo boundary.
amrex::Real time_before
Time in ocean_times immediately before the last time interpolated to.
void Initialize()
Read in time array from file and allocate data arrays.
amrex::FArrayBox yhi_dat_interp
FArrayBox to store data at inteprolated time at yhi boundary */.
amrex::FArrayBox xlo_dat_interp
FArrayBox to store data at inteprolated time at xlo boundary */.
amrex::Vector< amrex::Real > bry_times
Time points in netcdf file.
std::string time_name
Field name for time series in netcdf file.
amrex::FArrayBox xhi_dat_interp
FArrayBox to store data at inteprolated time at xhi boundary */.
amrex::IntVect index_type
Index type for field to fill.
int i_time_before
Time index immediately before the last time interpolated to.
std::string field_name
Field name in netcdf file.
amrex::FArrayBox ylo_dat_interp
FArrayBox to store data at inteprolated time at ylo boundary */.
amrex::Vector< amrex::Geometry > m_geom
Geometry at all levels.
amrex::FArrayBox xhi_dat_after
FArrayBox to store data at time_after at xhi boundary.
NCTimeSeriesBoundary(int a_lev, const amrex::Vector< amrex::Geometry > a_geom, const amrex::Vector< std::string > &a_file_name, const std::string a_field_name, const std::string a_time_name, const amrex::IntVect a_index_type, const amrex::GpuArray< bool, AMREX_SPACEDIM *2 > &a_var_need_data, bool a_is2d, int rx, int ry)
Constructor.
void read_in_at_time(amrex::FArrayBox &fab_xlo, amrex::FArrayBox &fab_xhi, amrex::FArrayBox &fab_ylo, amrex::FArrayBox &fab_yhi, int itime)
Read in data from file at time index itime and fill into mf.
amrex::Vector< std::string > file_names
File name to read from.
amrex::Vector< int > file_itime_offset
Offset to access a particular time within its file.
amrex::FArrayBox xhi_dat_before
FArrayBox to store data at time_before at xhi boundary.
bool is2d
Whether the field we're reading in is 2d.
void update_interpolated_to_time(amrex::Real time)
Calculate interpolated values at time, reading in data as necessary.
int m_lev
Level at which we are holding the boundary data.
int m_rx
Refinement ratios relative to level 0.
amrex::FArrayBox xlo_dat_before
FArrayBox to store data at time_before at xlo boundary.
amrex::Real time_after
Time in ocean_times immediately after the last time interpolated to.
amrex::Vector< int > file_for_time
File index to access a particular time.
NDArray is the datatype designed to hold any data, including scalars, multidimensional arrays,...