ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_TerrainFileChecks.H File Reference
#include <AMReX_Array.H>
#include <AMReX_Array4.H>
#include <AMReX_Geometry.H>
#include <AMReX_MultiFab.H>
#include <AMReX_GpuQualifiers.H>
#include <AMReX_Extension.H>
#include <AMReX_Math.H>
#include <AMReX_REAL.H>
#include <AMReX_Vector.H>
#include "ERF_TerrainDiffusionLimits.H"
#include <cmath>
#include <string>
#include <AMReX_Print.H>
#include <sstream>
#include <type_traits>
Include dependency graph for ERF_TerrainFileChecks.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  erf_terrain_file::HeightTable
 

Namespaces

 erf_terrain_file
 

Functions

template<typename T >
T erf_get_single_value (std::istream &is, int n, const std::string &fname)
 
const HeightTable & erf_terrain_file::ReadHeightTable (const std::string &fname, bool is_usgs, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &prob_lo, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &prob_hi, bool require_domain_coverage=true)
 
std::string erf_terrain_file::TableProblem (bool is_usgs, int nx, int ny, const amrex::Vector< amrex::Real > &x, const amrex::Vector< amrex::Real > &y, const amrex::Vector< amrex::Real > &z, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &prob_lo, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &prob_hi, bool require_domain_coverage=true)
 
std::string erf_terrain_file::TableSummary (const std::string &fname, bool is_usgs, int nx, int ny, const amrex::Vector< amrex::Real > &x, const amrex::Vector< amrex::Real > &y, const amrex::Vector< amrex::Real > &z)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_terrain_file::CellTerrainSlope (int i, int j, int k, const amrex::Array4< const amrex::Real > &z_nd, amrex::Real mfx, amrex::Real mfy, amrex::Real dxinv, amrex::Real dyinv) noexcept
 
amrex::Array< amrex::Real, 4 > erf_terrain_file::FaceBandSlopes (const amrex::MultiFab &z_phys_nd, const amrex::MultiFab &mf_mx, const amrex::MultiFab &mf_my, const amrex::Geometry &geom, int band)
 
std::string erf_terrain_file::OpenFaceSlopeWarning (int lev, int band, const amrex::Array< amrex::Real, 4 > &slopes, const amrex::Array< bool, 4 > &open, const amrex::Array< std::string, 4 > &bc_names)
 

Variables

constexpr amrex::Real erf_terrain_file::open_face_slope_warn = amrex::Real(0.3)
 

Detailed Description

Checks of the height tables read from erf.terrain_file_name, erf.terrain_file_name_USGS and erf.buildings_file_name (ProblemBase::read_custom_terrain), a start-up summary of each table, and the warning for steep terrain next to an inflow or outflow face.

Table layouts:

  • ERF text format (nx, ny >= 1): x has nx values, y has ny values, and height n sits at (x[n / ny], y[n % ny]), i.e. y varies fastest. A single value in a direction makes the surface constant in that direction (a two-dimensional profile).
  • USGS format (nx, ny >= 2): x has one value per point, y one value per row of nx points, and height n sits at (x[n], y[n / nx]), i.e. x varies fastest.

Function Documentation

◆ erf_get_single_value()

template<typename T >
T erf_get_single_value ( std::istream &  is,
int  n,
const std::string &  fname 
)

Read one number from line n of a text file that holds one number per line. Aborts, naming the file and the line, on a line that is missing, is not a number (a whole number for T = int), or has text after the number.

46 {
47  T r = 0;
48  std::string line;
49  if (std::getline(is, line)) {
50  std::stringstream ss(line);
51  ss >> r;
52  if (ss.fail()) {
53  amrex::Abort("Terrain file " + fname + ": line " + std::to_string(n)
54  + " is not a number: '" + line + "'");
55  }
56  std::string extra;
57  if (ss >> extra) {
58  if (std::is_integral_v<T> && (extra[0] == '.' || extra[0] == 'e' || extra[0] == 'E')) {
59  amrex::Abort("Terrain file " + fname + ": line " + std::to_string(n) + " must be a whole"
60  + " number (nx or ny): '" + line + "'");
61  }
62  amrex::Abort("Terrain file " + fname + ": line " + std::to_string(n) + " has text after"
63  + " the value: '" + line + "'; the file has one value per line, with no"
64  + " other text");
65  }
66  } else if (n <= 2) {
67  amrex::Abort("Terrain file " + fname + ": the file ends at line " + std::to_string(n-1)
68  + "; lines 1 and 2 must give nx and ny");
69  } else {
70  amrex::Abort("Terrain file " + fname + ": the file ends at line " + std::to_string(n-1)
71  + ", but nx and ny ask for nx + ny + nx*ny values after them");
72  }
73  return r;
74 }
@ T
Definition: ERF_IndexDefines.H:168