Skip to content

Commit

Permalink
Resolve odd even bug from Exawind#640 (Exawind#646)
Browse files Browse the repository at this point in the history
* WIP: add some unit tests looking for the diff

* more explicit indexing

* Fix odd even indexing issue
  • Loading branch information
psakievich authored Jun 29, 2022
1 parent 983560d commit d7530c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 4 additions & 5 deletions amr-wind/wind_energy/actuator/ActuatorContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,12 @@ void ActuatorContainer::populate_field_buffers()
auto& den_arr = m_data.density;
const int npts = vel_arr.size();
const int ioff = m_proc_offsets[amrex::ParallelDescriptor::MyProc()];
int index = ioff;
for (int i = 0; i < npts; ++i) {
for (int j = 0; j < AMREX_SPACEDIM; ++j, index++) {
vel_arr[i][j] = buff_host[index];
for (int j = 0; j < AMREX_SPACEDIM; ++j) {
vel_arr[i][j] = buff_host[(ioff + i) * NumPStructReal + j];
}
den_arr[i] = buff_host[index];
index++;
den_arr[i] =
buff_host[(ioff + i) * NumPStructReal + AMREX_SPACEDIM];
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions unit_tests/wind_energy/actuator/test_actuator_joukowsky_disk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,16 @@ struct ComputeForceOp<::amr_wind_tests::Joukowsky, ActSrcDisk>
{
void operator()(::amr_wind_tests::Joukowsky::DataType& data)
{
ComputeForceOp<::amr_wind::actuator::Joukowsky, ActSrcDisk> actual_op;
EXPECT_NO_FATAL_FAILURE(actual_op(data));
const auto& meta = data.meta();
const auto& grid = data.grid();
for (int i = 0; i < meta.num_vel_pts; ++i) {
EXPECT_DOUBLE_EQ(10.0, grid.vel[i].x()) << ", " << i;
EXPECT_DOUBLE_EQ(0.0, grid.vel[i].y()) << ", " << i;
EXPECT_DOUBLE_EQ(0.0, grid.vel[i].z()) << ", " << i;
EXPECT_DOUBLE_EQ(1.0, grid.density[i]) << ", " << i;
}
ComputeForceOp<::amr_wind::actuator::Joukowsky, ActSrcDisk> actual_op;
EXPECT_NO_FATAL_FAILURE(actual_op(data));
for (int i = 0; i < meta.num_force_pts; ++i) {
for (int j = 0; j < 3; ++j) {
EXPECT_FALSE(std::isnan(grid.force[i][j]))
Expand Down

0 comments on commit d7530c0

Please sign in to comment.