Skip to content

Commit d53a2bd

Browse files
committed
fix numerous mistakes from previous commit
1 parent 811dc8e commit d53a2bd

File tree

2 files changed

+35
-18
lines changed

2 files changed

+35
-18
lines changed

Src/Base/AMReX_MultiFabUtil.H

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,35 @@ namespace amrex
1818
void average_node_to_cellcenter (MultiFab& cc, int dcomp,
1919
const MultiFab& nd, int scomp,
2020
int ncomp, int ngrow = 0);
21+
void average_node_to_cellcenter (MultiFab& cc, int dcomp,
22+
const MultiFab& nd, int scomp,
23+
int ncomp, IntVect const& ng_vect);
2124

2225
/**
2326
* \brief Average edge-based MultiFab onto cell-centered MultiFab.
2427
*
25-
* This fills in \p ngrow ghost cells in the cell-centered MultiFab. Both cell centered and
26-
* edge centered MultiFabs need to have \p ngrow ghost values.
28+
* This fills in \p ngrow ghost cells in the cell-centered MultiFab. Both cell-centered and
29+
* edge-centered MultiFabs need to have \p ngrow ghost values.
2730
*/
2831
void average_edge_to_cellcenter (MultiFab& cc, int dcomp,
2932
const Vector<const MultiFab*>& edge,
3033
int ngrow = 0);
31-
//! Average face-based MultiFab onto cell-centered MultiFab.
34+
void average_edge_to_cellcenter (MultiFab& cc, int dcomp,
35+
const Vector<const MultiFab*>& edge,
36+
IntVect const& ng_vect);
37+
38+
/**
39+
* \brief Average face-based MultiFab onto cell-centered MultiFab.
40+
*
41+
* This fills in \p ngrow ghost cells in the cell-centered MultiFab. Both cell-centered and
42+
* face-centered MultiFabs need to have \p ngrow ghost values.
43+
*/
3244
void average_face_to_cellcenter (MultiFab& cc, int dcomp,
3345
const Vector<const MultiFab*>& fc,
3446
int ngrow = 0);
35-
//! Average face-based MultiFab onto cell-centered MultiFab.
3647
void average_face_to_cellcenter (MultiFab& cc, int dcomp,
3748
const Vector<const MultiFab*>& fc,
38-
IntVect ngrow = IntVect::TheZeroVector());
49+
IntVect const& ng_vect);
3950

4051
//! Average face-based FabArray onto cell-centered FabArray.
4152
template <typename CMF, typename FMF,
@@ -44,6 +55,12 @@ namespace amrex
4455
const Array<const FMF*,AMREX_SPACEDIM>& fc,
4556
int ngrow = 0);
4657

58+
template <typename CMF, typename FMF,
59+
std::enable_if_t<IsFabArray_v<CMF> && IsFabArray_v<FMF>, int> = 0>
60+
void average_face_to_cellcenter (CMF& cc, int dcomp,
61+
const Array<const FMF*,AMREX_SPACEDIM>& fc,
62+
IntVect const& ngrow);
63+
4764
//! Average face-based MultiFab onto cell-centered MultiFab with geometric weighting.
4865
void average_face_to_cellcenter (MultiFab& cc,
4966
const Vector<const MultiFab*>& fc,
@@ -894,7 +911,7 @@ NormHelper (const MMF& mask,
894911
}
895912

896913
template <typename CMF, typename FMF,
897-
std::enable_if_t<IsFabArray_v<CMF> && IsFabArray_v<FMF>, IntVect> FOO>
914+
std::enable_if_t<IsFabArray_v<CMF> && IsFabArray_v<FMF>, int> FOO>
898915
void average_face_to_cellcenter (CMF& cc, int dcomp,
899916
const Array<const FMF*,AMREX_SPACEDIM>& fc,
900917
int ngrow)
@@ -907,7 +924,7 @@ template <typename CMF, typename FMF,
907924
std::enable_if_t<IsFabArray_v<CMF> && IsFabArray_v<FMF>, int> FOO>
908925
void average_face_to_cellcenter (CMF& cc, int dcomp,
909926
const Array<const FMF*,AMREX_SPACEDIM>& fc,
910-
IntVect ngrow)
927+
IntVect const& ng_vect)
911928
{
912929
AMREX_ASSERT(cc.nComp() >= dcomp + AMREX_SPACEDIM);
913930
AMREX_ASSERT(fc[0]->nComp() == 1);
@@ -918,7 +935,7 @@ void average_face_to_cellcenter (CMF& cc, int dcomp,
918935
AMREX_D_TERM(auto const& fxma = fc[0]->const_arrays();,
919936
auto const& fyma = fc[1]->const_arrays();,
920937
auto const& fzma = fc[2]->const_arrays(););
921-
ParallelFor(cc, ngrow,
938+
ParallelFor(cc, ng_vect,
922939
[=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k) noexcept
923940
{
924941
#if (AMREX_SPACEDIM == 1)
@@ -945,7 +962,7 @@ void average_face_to_cellcenter (CMF& cc, int dcomp,
945962
#endif
946963
for (MFIter mfi(cc,TilingIfNotGPU()); mfi.isValid(); ++mfi)
947964
{
948-
const Box bx = mfi.growntilebox(ngrow);
965+
const Box bx = mfi.growntilebox(ng_vect);
949966
auto const& ccarr = cc.array(mfi);
950967
AMREX_D_TERM(auto const& fxarr = fc[0]->const_array(mfi);,
951968
auto const& fyarr = fc[1]->const_array(mfi);,

Src/Base/AMReX_MultiFabUtil.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ namespace amrex
6767
}
6868

6969
void average_node_to_cellcenter (MultiFab& cc, int dcomp,
70-
const MultiFab& nd, int scomp, int ncomp, IntVect& ngrow)
70+
const MultiFab& nd, int scomp, int ncomp, IntVect const& ng_vect)
7171
{
7272
#ifdef AMREX_USE_GPU
7373
if (Gpu::inLaunchRegion() && cc.isFusingCandidate()) {
7474
auto const& ccma = cc.arrays();
7575
auto const& ndma = nd.const_arrays();
76-
ParallelFor(cc, ngrow, ncomp,
76+
ParallelFor(cc, ng_vect, ncomp,
7777
[=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k, int n) noexcept
7878
{
7979
amrex_avg_nd_to_cc(i, j, k, n, ccma[box_no], ndma[box_no], dcomp, scomp);
@@ -89,7 +89,7 @@ namespace amrex
8989
#endif
9090
for (MFIter mfi(cc,TilingIfNotGPU()); mfi.isValid(); ++mfi)
9191
{
92-
const Box bx = mfi.growntilebox(ngrow);
92+
const Box bx = mfi.growntilebox(ng_vect);
9393
Array4<Real> const& ccarr = cc.array(mfi);
9494
Array4<Real const> const& ndarr = nd.const_array(mfi);
9595

@@ -104,12 +104,12 @@ namespace amrex
104104
void average_edge_to_cellcenter (MultiFab& cc, int dcomp,
105105
const Vector<const MultiFab*>& edge, int ngrow)
106106
{
107-
IntVect ng_vect(ng);
107+
IntVect ng_vect(ngrow);
108108
average_edge_to_cellcenter (cc, dcomp, edge, ng_vect);
109109
}
110110

111111
void average_edge_to_cellcenter (MultiFab& cc, int dcomp,
112-
const Vector<const MultiFab*>& edge, IntVect& ngrow)
112+
const Vector<const MultiFab*>& edge, IntVect const& ng_vect)
113113
{
114114
AMREX_ASSERT(cc.nComp() >= dcomp + AMREX_SPACEDIM);
115115
AMREX_ASSERT(edge.size() == AMREX_SPACEDIM);
@@ -120,7 +120,7 @@ namespace amrex
120120
AMREX_D_TERM(auto const& exma = edge[0]->const_arrays();,
121121
auto const& eyma = edge[1]->const_arrays();,
122122
auto const& ezma = edge[2]->const_arrays(););
123-
ParallelFor(cc, ngrow,
123+
ParallelFor(cc, ng_vect,
124124
[=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k) noexcept
125125
{
126126
amrex_avg_eg_to_cc(i, j, k, ccma[box_no],
@@ -138,7 +138,7 @@ namespace amrex
138138
#endif
139139
for (MFIter mfi(cc,TilingIfNotGPU()); mfi.isValid(); ++mfi)
140140
{
141-
const Box bx = mfi.growntilebox(ngrow);
141+
const Box bx = mfi.growntilebox(ng_vect);
142142
Array4<Real> const& ccarr = cc.array(mfi);
143143
AMREX_D_TERM(Array4<Real const> const& exarr = edge[0]->const_array(mfi);,
144144
Array4<Real const> const& eyarr = edge[1]->const_array(mfi);,
@@ -153,11 +153,11 @@ namespace amrex
153153
}
154154

155155
void average_face_to_cellcenter (MultiFab& cc, int dcomp,
156-
const Vector<const MultiFab*>& fc, IntVect& ngrow)
156+
const Vector<const MultiFab*>& fc, IntVect const& ng_vect)
157157
{
158158
average_face_to_cellcenter(cc, dcomp,
159159
Array<MultiFab const*,AMREX_SPACEDIM>{{AMREX_D_DECL(fc[0],fc[1],fc[2])}},
160-
ngrow);
160+
ng_vect);
161161
}
162162

163163
void average_face_to_cellcenter (MultiFab& cc, int dcomp,

0 commit comments

Comments
 (0)