Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang committed Jul 29, 2023
1 parent 11bf8e4 commit b6ca7a8
Showing 1 changed file with 40 additions and 20 deletions.
60 changes: 40 additions & 20 deletions Src/Particle/AMReX_StructOfArrays.H
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@ struct StructOfArrays {
* @param index component with 0...NReal-1 compile-time and NReal... runtime arguments
*/
[[nodiscard]] RealVector& GetRealData (const int index) {
if (index >= 0 && index < NReal) {
return m_rdata[index];
AMREX_ASSERT(index >= 0 && index < NReal + static_cast<int>(m_runtime_rdata.size()));
if constexpr (NReal == 0) {
AMREX_ASSERT(m_defined);
return m_runtime_rdata[index];
} else {
AMREX_ASSERT((index-NReal) < static_cast<int>(m_runtime_rdata.size())
&& m_defined);
return m_runtime_rdata[index - NReal];
if (index < NReal) {
return m_rdata[index];
} else {
AMREX_ASSERT(m_defined);
return m_runtime_rdata[index - NReal];
}
}
}

Expand All @@ -55,12 +60,17 @@ struct StructOfArrays {
* @param index component with 0...NReal-1 compile-time and NReal... runtime arguments
*/
[[nodiscard]] const RealVector& GetRealData (const int index) const {
if (index >= 0 && index < NReal) {
return m_rdata[index];
AMREX_ASSERT(index >= 0 && index < NReal + static_cast<int>(m_runtime_rdata.size()));
if constexpr (NReal == 0) {
AMREX_ASSERT(m_defined);
return m_runtime_rdata[index];
} else {
AMREX_ASSERT((index-NReal) < static_cast<int>(m_runtime_rdata.size())
&& m_defined);
return m_runtime_rdata[index - NReal];
if (index < NReal) {
return m_rdata[index];
} else {
AMREX_ASSERT(m_defined);
return m_runtime_rdata[index - NReal];
}
}
}

Expand All @@ -69,12 +79,17 @@ struct StructOfArrays {
* @param index component with 0...NInt-1 compile-time and NInt... runtime arguments
*/
[[nodiscard]] IntVector& GetIntData (const int index) {
if (index >= 0 && index < NInt) {
return m_idata[index];
AMREX_ASSERT(index >= 0 && index < NInt + static_cast<int>(m_runtime_idata.size()));
if constexpr (NInt == 0) {
AMREX_ASSERT(m_defined);
return m_runtime_idata[index];
} else {
AMREX_ASSERT((index-NInt) < static_cast<int>(m_runtime_idata.size())
&& m_defined);
return m_runtime_idata[index - NInt];
if (index < NInt) {
return m_idata[index];
} else {
AMREX_ASSERT(m_defined);
return m_runtime_idata[index - NInt];
}
}
}

Expand All @@ -84,12 +99,17 @@ struct StructOfArrays {
* @return
*/
[[nodiscard]] const IntVector& GetIntData (const int index) const {
if (index >= 0 && index < NInt) {
return m_idata[index];
AMREX_ASSERT(index >= 0 && index < NInt + static_cast<int>(m_runtime_idata.size()));
if constexpr (NInt == 0) {
AMREX_ASSERT(m_defined);
return m_runtime_idata[index];
} else {
AMREX_ASSERT((index-NInt) < static_cast<int>(m_runtime_idata.size())
&& m_defined);
return m_runtime_idata[index - NInt];
if (index < NInt) {
return m_idata[index];
} else {
AMREX_ASSERT(m_defined);
return m_runtime_idata[index - NInt];
}
}
}

Expand Down

0 comments on commit b6ca7a8

Please sign in to comment.