|
1 | 1 | #include <AMReX_FPhysBC.H> |
2 | 2 | #include <AMReX_FillPatchUtil.H> |
| 3 | +#include <AMReX_FillPatcher.H> |
3 | 4 |
|
4 | 5 | using namespace amrex; |
5 | 6 |
|
@@ -83,6 +84,117 @@ namespace { |
83 | 84 |
|
84 | 85 | extern "C" |
85 | 86 | { |
| 87 | + void amrex_fi_new_fillpatcher (FillPatcher<MultiFab>*& fillpatcher, |
| 88 | + const BoxArray* fba, const DistributionMapping* fdm, |
| 89 | + const Geometry* fgeom, |
| 90 | + const BoxArray* cba, const DistributionMapping* cdm, |
| 91 | + const Geometry* cgeom, |
| 92 | + int nghost, int ncomp, int interp_id) |
| 93 | + { |
| 94 | + fillpatcher = new FillPatcher<MultiFab> |
| 95 | + (*fba, *fdm, *fgeom, *cba, *cdm, *cgeom, |
| 96 | + IntVect(nghost), ncomp, interp[interp_id]); |
| 97 | + } |
| 98 | + |
| 99 | + void amrex_fi_delete_fillpatcher (FillPatcher<MultiFab>* fillpatcher) |
| 100 | + { |
| 101 | + delete fillpatcher; |
| 102 | + } |
| 103 | + |
| 104 | + void amrex_fi_fillpatcher_fill (FillPatcher<MultiFab>* fillpatcher, |
| 105 | + MultiFab* mf, int nghost, Real time, |
| 106 | + MultiFab* cmf[], Real ct[], int nc, |
| 107 | + MultiFab* fmf[], Real ft[], int nf, |
| 108 | + int scomp, int dcomp, int ncomp, |
| 109 | + const Geometry* cgeom, const Geometry* fgeom, |
| 110 | + FPhysBC::fill_physbc_funptr_t cfill, |
| 111 | + FPhysBC::fill_physbc_funptr_t ffill, |
| 112 | + int* lo_bc[], int* hi_bc[], |
| 113 | + INTERP_HOOK pre_interp, INTERP_HOOK post_interp) |
| 114 | + { |
| 115 | + Vector<BCRec> bcs; |
| 116 | + for (int i = 0; i < ncomp; ++i) { |
| 117 | + bcs.emplace_back(lo_bc[i+scomp], hi_bc[i+scomp]); |
| 118 | + } |
| 119 | + |
| 120 | + FPhysBC cbc(cfill, cgeom); |
| 121 | + FPhysBC fbc(ffill, fgeom); |
| 122 | + fillpatcher->fill(*mf, IntVect{AMREX_D_DECL(nghost,nghost,nghost)}, time, |
| 123 | + Vector<MultiFab*>{cmf, cmf+nc}, Vector<Real>{ct, ct+nc}, |
| 124 | + Vector<MultiFab*>{fmf, fmf+nf}, Vector<Real>{ft, ft+nf}, |
| 125 | + scomp, dcomp, ncomp, |
| 126 | + cbc, 0, fbc, 0, bcs, 0, |
| 127 | + FIInterpHook(pre_interp), |
| 128 | + FIInterpHook(post_interp)); |
| 129 | + } |
| 130 | + |
| 131 | + void amrex_fi_fillpatcher_fillcf (FillPatcher<MultiFab>* fillpatcher, |
| 132 | + MultiFab* mf, int nghost, Real time, |
| 133 | + MultiFab* cmf[], Real ct[], int nc, |
| 134 | + int scomp, int dcomp, int ncomp, |
| 135 | + const Geometry* cgeom, |
| 136 | + FPhysBC::fill_physbc_funptr_t cfill, |
| 137 | + int* lo_bc[], int* hi_bc[], |
| 138 | + INTERP_HOOK pre_interp, INTERP_HOOK post_interp) |
| 139 | + { |
| 140 | + Vector<BCRec> bcs; |
| 141 | + for (int i = 0; i < ncomp; ++i) { |
| 142 | + bcs.emplace_back(lo_bc[i+scomp], hi_bc[i+scomp]); |
| 143 | + } |
| 144 | + |
| 145 | + FPhysBC cbc(cfill, cgeom); |
| 146 | + fillpatcher->fillCoarseFineBoundary(*mf, IntVect{AMREX_D_DECL(nghost,nghost,nghost)}, time, |
| 147 | + Vector<MultiFab*>{cmf, cmf+nc}, |
| 148 | + Vector<Real>{ct, ct+nc}, |
| 149 | + scomp, dcomp, ncomp, |
| 150 | + cbc, 0, bcs, 0, |
| 151 | + FIInterpHook(pre_interp), |
| 152 | + FIInterpHook(post_interp)); |
| 153 | + } |
| 154 | + |
| 155 | + void amrex_fi_fillpatcher_store_rk3 (FillPatcher<MultiFab>* fillpatcher, |
| 156 | + Real time, Real dt, |
| 157 | + const MultiFab* s_old, MultiFab* rk[]) |
| 158 | + { |
| 159 | + Array<MultiFab,3> rkk{{ |
| 160 | + MultiFab(*rk[0], amrex::make_alias, 0, rk[0]->nComp()), |
| 161 | + MultiFab(*rk[1], amrex::make_alias, 0, rk[1]->nComp()), |
| 162 | + MultiFab(*rk[2], amrex::make_alias, 0, rk[2]->nComp()) |
| 163 | + }}; |
| 164 | + fillpatcher->storeRKCoarseData(time, dt, *s_old, rkk); |
| 165 | + } |
| 166 | + |
| 167 | + void amrex_fi_fillpatcher_store_rk4 (FillPatcher<MultiFab>* fillpatcher, |
| 168 | + Real time, Real dt, |
| 169 | + const MultiFab* s_old, MultiFab* rk[]) |
| 170 | + { |
| 171 | + Array<MultiFab,4> rkk{{ |
| 172 | + MultiFab(*rk[0], amrex::make_alias, 0, rk[0]->nComp()), |
| 173 | + MultiFab(*rk[1], amrex::make_alias, 0, rk[1]->nComp()), |
| 174 | + MultiFab(*rk[2], amrex::make_alias, 0, rk[2]->nComp()), |
| 175 | + MultiFab(*rk[3], amrex::make_alias, 0, rk[3]->nComp()) |
| 176 | + }}; |
| 177 | + fillpatcher->storeRKCoarseData(time, dt, *s_old, rkk); |
| 178 | + } |
| 179 | + |
| 180 | + void amrex_fi_fillpatcher_fill_rk (FillPatcher<MultiFab>* fillpatcher, |
| 181 | + int stage, int iteration, int ncycle, |
| 182 | + MultiFab* mf, Real time, |
| 183 | + const Geometry* cgeom, const Geometry* fgeom, |
| 184 | + FPhysBC::fill_physbc_funptr_t cfill, |
| 185 | + FPhysBC::fill_physbc_funptr_t ffill, |
| 186 | + int* lo_bc[], int* hi_bc[], int ncomp) |
| 187 | + { |
| 188 | + Vector<BCRec> bcs; |
| 189 | + for (int i = 0; i < ncomp; ++i) { |
| 190 | + bcs.emplace_back(lo_bc[i], hi_bc[i]); |
| 191 | + } |
| 192 | + |
| 193 | + FPhysBC cbc(cfill, cgeom); |
| 194 | + FPhysBC fbc(ffill, fgeom); |
| 195 | + fillpatcher->fillRK(stage, iteration, ncycle, *mf, time, cbc, fbc, bcs); |
| 196 | + } |
| 197 | + |
86 | 198 | void amrex_fi_fillpatch_single (MultiFab* mf, Real time, MultiFab* smf[], Real stime[], int ns, |
87 | 199 | int scomp, int dcomp, int ncomp, const Geometry* geom, |
88 | 200 | FPhysBC::fill_physbc_funptr_t fill) |
|
0 commit comments