Skip to content

Commit

Permalink
refactor: alternative attempt to fix calculation of source index for …
Browse files Browse the repository at this point in the history
…winds using yac edges fields
  • Loading branch information
yoctoyotta1024 committed Nov 7, 2024
1 parent 49b8f01 commit db3f114
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 9 additions & 5 deletions libs/coupldyn_yac/yac_cartesian_dynamics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Author: Wilton Loch (WL)
* Additional Contributors: Clara Bayley (CB)
* -----
* Last Modified: Monday 9th September 2024
* Last Modified: Friday 20th September 2024
* Modified By: CB
* -----
* License: BSD 3-Clause "New" or "Revised" License
Expand Down Expand Up @@ -170,8 +170,8 @@ void CartesianDynamics::receive_yac_field(const unsigned int grid_points,
for (size_t i = 0; i < ndims_east; i++) {
for (size_t k = 0; k < vertical_levels; k++) {
auto vertical_idx = k;
auto edges_ndims_east = ndims_east * 2 - 1;
auto source_idx = edges_ndims_east * j + ndims_east - 1 + i;
auto source_idx = (ndims_east - 1) * j + ndims_east * j;
source_idx += std::min(2 * i + 1, 2 * ndims_east - 2);
auto ii = (ndims_east * j + i) * vertical_levels + k;
target_array[ii] = yac_raw_data[vertical_idx][source_idx] / conversion_factor;
}
Expand All @@ -187,8 +187,12 @@ void CartesianDynamics::receive_yac_field(const unsigned int grid_points,
for (size_t i = 0; i < ndims_east; i++) {
for (size_t k = 0; k < vertical_levels; k++) {
auto vertical_idx = k;
auto edges_ndims_east = ndims_east * 2 + 1;
auto source_idx = edges_ndims_east * j + i;
auto source_idx = ndims_east * j + (ndims_east + 1) * j;
if (j < ndims_north - 1) {
source_idx += 2 * i;
} else {
source_idx += i;
}
auto ii = (ndims_east * j + i) * vertical_levels + k;
target_array[ii] = yac_raw_data[vertical_idx][source_idx] / conversion_factor;
}
Expand Down
3 changes: 2 additions & 1 deletion libs/coupldyn_yac/yac_cartesian_dynamics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Author: Clara Bayley (CB)
* Additional Contributors:
* -----
* Last Modified: Wednesday 4th September 2024
* Last Modified: Friday 20th September 2024
* Modified By: CB
* -----
* License: BSD 3-Clause "New" or "Revised" License
Expand All @@ -23,6 +23,7 @@
#ifndef LIBS_COUPLDYN_YAC_YAC_CARTESIAN_DYNAMICS_HPP_
#define LIBS_COUPLDYN_YAC_YAC_CARTESIAN_DYNAMICS_HPP_

#include <algorithm>
#include <array>
#include <fstream>
#include <functional>
Expand Down

0 comments on commit db3f114

Please sign in to comment.