\brief Takes an array of 3 MultiFab `vector_field` * (representing the x, y, z components of a vector), * averages it to the cell center, and stores the * resulting MultiFab in mf_avg (in the components dcomp to dcomp+2) * Should only be used for BTD now. */
| 154 | * Should only be used for BTD now. |
| 155 | */ |
| 156 | void |
| 157 | AverageAndPackVectorField( MultiFab& mf_avg, |
| 158 | const std::array< std::unique_ptr<MultiFab>, 3 >& vector_field, |
| 159 | const DistributionMapping& dm, |
| 160 | const int dcomp, const IntVect ngrow ) |
| 161 | { |
| 162 | #ifndef WARPX_DIM_RZ |
| 163 | (void)dm; |
| 164 | #endif |
| 165 | |
| 166 | #ifdef WARPX_DIM_RZ |
| 167 | // Note that vector_total is declared in the same way as |
| 168 | // vector_field so that it can be handled the same way. |
| 169 | std::array<std::unique_ptr<MultiFab>,3> vector_total; |
| 170 | if (vector_field[0]->nComp() > 1) { |
| 171 | // With the RZ solver, if there are more than one component, the total |
| 172 | // fields needs to be constructed in temporary MultiFabs. |
| 173 | vector_total[0] = std::make_unique<MultiFab>(vector_field[0]->boxArray(), dm, 1, vector_field[0]->nGrowVect()); |
| 174 | vector_total[1] = std::make_unique<MultiFab>(vector_field[1]->boxArray(), dm, 1, vector_field[1]->nGrowVect()); |
| 175 | vector_total[2] = std::make_unique<MultiFab>(vector_field[2]->boxArray(), dm, 1, vector_field[2]->nGrowVect()); |
| 176 | ConstructTotalRZVectorField(vector_total, vector_field); |
| 177 | } else { |
| 178 | // Create aliases of the MultiFabs |
| 179 | vector_total[0] = std::make_unique<MultiFab>(*vector_field[0], amrex::make_alias, 0, 1); |
| 180 | vector_total[1] = std::make_unique<MultiFab>(*vector_field[1], amrex::make_alias, 0, 1); |
| 181 | vector_total[2] = std::make_unique<MultiFab>(*vector_field[2], amrex::make_alias, 0, 1); |
| 182 | } |
| 183 | #else |
| 184 | const std::array<std::unique_ptr<MultiFab>,3> &vector_total = vector_field; |
| 185 | #endif |
| 186 | |
| 187 | ablastr::coarsen::sample::Coarsen(mf_avg, *(vector_total[0]), dcomp , 0, 1, ngrow ); |
| 188 | ablastr::coarsen::sample::Coarsen(mf_avg, *(vector_total[1]), dcomp + 1, 0, 1, ngrow ); |
| 189 | ablastr::coarsen::sample::Coarsen(mf_avg, *(vector_total[2]), dcomp + 2, 0, 1, ngrow ); |
| 190 | } |
| 191 | |
| 192 | /** \brief Take a MultiFab `scalar_field` |
| 193 | * averages it to the cell center, and stores the |
nothing calls this directly
no test coverage detected