Skip to content

Commit

Permalink
J(), K() always return 0 for inactive directions
Browse files Browse the repository at this point in the history
Call this VERSION 0.0.8.
Disable test in src/Milhoja_GridAmrex.cpp that fails unnecessarily.
  • Loading branch information
kweide committed Aug 23, 2024
1 parent 6cba671 commit 79900fe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions includes/Milhoja_IntVect.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class RealVect;
* is turned off). Alternatively, if MILHOJA_MDIM-like behavior is needed, three
* functions `IntVect::I()`, `IntVect::J()`, and `IntVect::K()` are provided.
* They return the first, second, or third element of the vector, respectively,
* or a default value of 0 if trying to get an element above MILHOJA_NDIM. These
* or a default value of 1 if trying to get an element above MILHOJA_NDIM. These
* functions should especially be used when writing triple-nested loops that
* are dimension-agnostic.
*
Expand Down Expand Up @@ -95,13 +95,13 @@ class IntVect
return i_;
}

//! Return second element of vector, or 0 if MILHOJA_NDIM<2
//! Return second element of vector, or 1 if MILHOJA_NDIM<2
#ifdef ACC_ROUTINE_FOR_METH
#pragma acc routine seq
#endif
int J() const {
#if (MILHOJA_NDIM == 1)
return 0;
return 1;
#elif (MILHOJA_NDIM == 2) || (MILHOJA_NDIM == 3)
return j_;
#else
Expand All @@ -123,13 +123,13 @@ class IntVect
#endif
}

//! Return third element of vector, or 0 if MILHOJA_NDIM<3
//! Return third element of vector, or 1 if MILHOJA_NDIM<3
#ifdef ACC_ROUTINE_FOR_METH
#pragma acc routine seq
#endif
int K() const {
#if (MILHOJA_NDIM == 1) || (MILHOJA_NDIM == 2)
return 0;
return 1;
#elif (MILHOJA_NDIM == 3)
return k_;
#else
Expand Down
4 changes: 3 additions & 1 deletion src/Milhoja_GridAmrex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,15 @@ GridAmrex::GridAmrex(void)
throw std::logic_error("amrex::Real does not match milhoja::Real");
}

#if MILHOJA_NDIM == 3
// Check IntVect::{I,J,K} behavior matches amrex::Dim3
IntVect iv{LIST_NDIM(17,19,21)};
amrex::Dim3 d3 = amrex::IntVect(iv).dim3();
if( iv.I()!=d3.x || iv.J()!=d3.y || iv.K()!=d3.z ) {
throw std::logic_error("amrex::Dim3 and milhoja::IntVect do not "
"have matching default values.");
"have matching values.");
}
#endif

//----- LOG GRID CONFIGURATION INFORMATION
int size = -1;
Expand Down
2 changes: 1 addition & 1 deletion tools/milhoja_pypkg/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.7
0.0.8

0 comments on commit 79900fe

Please sign in to comment.