Skip to content

Commit

Permalink
refactor: demand that yac is given max and min longitude and latitude…
Browse files Browse the repository at this point in the history
… in config params
  • Loading branch information
yoctoyotta1024 committed Aug 17, 2024
1 parent 67ca555 commit 3e67b02
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 33 deletions.
12 changes: 9 additions & 3 deletions examples/bubble3d/bubble3d_inputfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,17 @@ def main(
isfigures = [True, True]
savefigpath = path2build + "/bin/" # directory for saving figures

### --- settings for 2-D gridbox boundaries --- ###
### --- settings for 3-D gridbox boundaries --- ###
num_vertical_levels = 24 # TODO(CB): move to config file (?)
zgrid = get_zgrid(icon_grid_file, num_vertical_levels) # [m]
xgrid = [0, 5000, 100] # evenly spaced xhalf coords [m]
ygrid = np.array([0, 1000, 2000]) # array of yhalf coords [m]
xgrid = [
0,
5000,
100,
] # evenly spaced xhalf coords [m] # distance must match longitude in config file
ygrid = np.array(
[0, 1500, 3000]
) # array of yhalf coords [m] # distance must match latitudes in config file

### --- settings for initial superdroplets --- ###
# settings for initial superdroplet coordinates
Expand Down
6 changes: 4 additions & 2 deletions examples/bubble3d/src/config/bubble3d_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@ outputdata:

coupled_dynamics:
type: yac
lower_latitude: -0.157079632
upper_latitude: 0.157079632
lower_longitude: -0.02255
upper_longitude: 0.02255
lower_latitude: -0.01347
upper_latitude: 0.01347
20 changes: 4 additions & 16 deletions libs/coupldyn_yac/yac_cartesian_dynamics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,10 @@ std::array<size_t, 3> kijfromindex(const std::array<size_t, 3> &ndims, const siz
void create_vertex_coordinates(const Config &config, const std::array<size_t, 3> ndims,
std::vector<double> &vertex_longitudes,
std::vector<double> &vertex_latitudes) {
double lower_longitude = 0;
double upper_longitude = ndims[EASTWARD] * (2 * std::numbers::pi / (ndims[EASTWARD] + 1));
double lower_latitude = (-0.5 * std::numbers::pi * ndims[NORTHWARD]) / (ndims[NORTHWARD] + 2);
double upper_latitude = (0.5 * std::numbers::pi * ndims[NORTHWARD]) / (ndims[NORTHWARD] + 2);

if (!std::isnan(config.get_yac_dynamics().lower_longitude))
lower_longitude = config.get_yac_dynamics().lower_longitude;

if (!std::isnan(config.get_yac_dynamics().upper_longitude))
upper_longitude = config.get_yac_dynamics().upper_longitude;

if (!std::isnan(config.get_yac_dynamics().lower_latitude))
lower_latitude = config.get_yac_dynamics().lower_latitude;

if (!std::isnan(config.get_yac_dynamics().upper_latitude))
upper_latitude = config.get_yac_dynamics().upper_latitude;
lower_longitude = config.get_yac_dynamics().lower_longitude;
upper_longitude = config.get_yac_dynamics().upper_longitude;
lower_latitude = config.get_yac_dynamics().lower_latitude;
upper_latitude = config.get_yac_dynamics().upper_latitude;

// Defines the vertex longitude and latitude values in radians for grid creation
// The values are later permuted by YAC to generate all vertex coordinates
Expand Down
17 changes: 5 additions & 12 deletions libs/initialise/optional_config_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Author: Clara Bayley (CB)
* Additional Contributors:
* -----
* Last Modified: Friday 21st June 2024
* Last Modified: Saturday 17th August 2024
* Modified By: CB
* -----
* License: BSD 3-Clause "New" or "Revised" License
Expand Down Expand Up @@ -208,17 +208,10 @@ void OptionalConfigParams::YacDynamicsParams::set_params(const YAML::Node &confi

assert((node["type"].as<std::string>() == "yac"));

if (node["lower_longitude"])
lower_longitude = node["lower_longitude"].as<double>();

if (node["upper_longitude"])
upper_longitude = node["upper_longitude"].as<double>();

if (node["lower_latitude"])
lower_latitude = node["lower_latitude"].as<double>();

if (node["upper_latitude"])
upper_latitude = node["upper_latitude"].as<double>();
lower_longitude = node["lower_longitude"].as<double>();
upper_longitude = node["upper_longitude"].as<double>();
lower_latitude = node["lower_latitude"].as<double>();
upper_latitude = node["upper_latitude"].as<double>();
}

void OptionalConfigParams::YacDynamicsParams::print_params() const {
Expand Down

0 comments on commit 3e67b02

Please sign in to comment.