Block-Structured AMR Software Framework
AMReX_FillPatchUtil.H
Go to the documentation of this file.
1 #ifndef AMREX_FillPatchUtil_H_
2 #define AMREX_FillPatchUtil_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_MultiFab.H>
6 #include <AMReX_iMultiFab.H>
7 #include <AMReX_Geometry.H>
8 #include <AMReX_PhysBCFunct.H>
9 #include <AMReX_Interpolater.H>
10 #include <AMReX_MFInterpolater.H>
11 #include <AMReX_Array.H>
12 #include <AMReX_Utility.H>
13 
14 #ifdef AMREX_USE_EB
15 #include <AMReX_EB2.H>
16 #include <AMReX_EBFabFactory.H>
17 #include <AMReX_EBInterpolater.H>
18 #include <AMReX_EBMFInterpolater.H>
19 #endif
20 
21 #ifdef AMREX_USE_OMP
22 #include <omp.h>
23 #endif
24 
25 #include <cmath>
26 #include <limits>
27 #include <map>
28 
29 namespace amrex
30 {
31 
32  template <typename MFFAB>
34  {
35  template <class F=MFFAB, std::enable_if_t<IsBaseFab<F>::value,int> = 0>
36  void operator() (MFFAB& /*fab*/, const Box& /*bx*/, int /*icomp*/, int /*ncomp*/) const {}
37 
38  template <class F=MFFAB, std::enable_if_t<IsBaseFab<F>::value,int> = 0>
39  void operator() (Array<MFFAB*, AMREX_SPACEDIM> /*fab*/, const Box& /*bx*/, int /*icomp*/, int /*ncomp*/) const {}
40 
41  template <class F=MFFAB, std::enable_if_t<IsFabArray<F>::value,int> = 0>
42  void operator() (MFFAB& /*mf*/, int /*icomp*/, int /*ncomp*/) const {}
43  };
44 
58  template <typename Interp>
59  bool ProperlyNested (const IntVect& ratio, const IntVect& blocking_factor, int ngrow,
60  const IndexType& boxType, Interp* mapper);
61 
85  template <typename MF, typename BC>
86  std::enable_if_t<IsFabArray<MF>::value>
87  FillPatchSingleLevel (MF& mf, IntVect const& nghost, Real time,
88  const Vector<MF*>& smf, const Vector<Real>& stime,
89  int scomp, int dcomp, int ncomp,
90  const Geometry& geom,
91  BC& physbcf, int bcfcomp);
92 
116  template <typename MF, typename BC>
117  std::enable_if_t<IsFabArray<MF>::value>
118  FillPatchSingleLevel (MF& mf, Real time,
119  const Vector<MF*>& smf, const Vector<Real>& stime,
120  int scomp, int dcomp, int ncomp,
121  const Geometry& geom,
122  BC& physbcf, int bcfcomp);
123 
162  template <typename MF, typename BC, typename Interp,
163  typename PreInterpHook=NullInterpHook<typename MF::FABType::value_type>,
164  typename PostInterpHook=NullInterpHook<typename MF::FABType::value_type> >
165  std::enable_if_t<IsFabArray<MF>::value>
166  FillPatchTwoLevels (MF& mf, IntVect const& nghost, Real time,
167  const Vector<MF*>& cmf, const Vector<Real>& ct,
168  const Vector<MF*>& fmf, const Vector<Real>& ft,
169  int scomp, int dcomp, int ncomp,
170  const Geometry& cgeom, const Geometry& fgeom,
171  BC& cbc, int cbccomp,
172  BC& fbc, int fbccomp,
173  const IntVect& ratio,
174  Interp* mapper,
175  const Vector<BCRec>& bcs, int bcscomp,
176  const PreInterpHook& pre_interp = {},
177  const PostInterpHook& post_interp = {});
178 
216  template <typename MF, typename BC, typename Interp,
217  typename PreInterpHook=NullInterpHook<typename MF::FABType::value_type>,
218  typename PostInterpHook=NullInterpHook<typename MF::FABType::value_type> >
219  std::enable_if_t<IsFabArray<MF>::value>
220  FillPatchTwoLevels (MF& mf, Real time,
221  const Vector<MF*>& cmf, const Vector<Real>& ct,
222  const Vector<MF*>& fmf, const Vector<Real>& ft,
223  int scomp, int dcomp, int ncomp,
224  const Geometry& cgeom, const Geometry& fgeom,
225  BC& cbc, int cbccomp,
226  BC& fbc, int fbccomp,
227  const IntVect& ratio,
228  Interp* mapper,
229  const Vector<BCRec>& bcs, int bcscomp,
230  const PreInterpHook& pre_interp = {},
231  const PostInterpHook& post_interp = {});
232 
274  template <typename MF, typename BC, typename Interp,
275  typename PreInterpHook=NullInterpHook<typename MF::FABType::value_type>,
276  typename PostInterpHook=NullInterpHook<typename MF::FABType::value_type> >
277  std::enable_if_t<IsFabArray<MF>::value>
278  FillPatchTwoLevels (Array<MF*, AMREX_SPACEDIM> const& mf, IntVect const& nghost, Real time,
279  const Vector<Array<MF*, AMREX_SPACEDIM> >& cmf, const Vector<Real>& ct,
280  const Vector<Array<MF*, AMREX_SPACEDIM> >& fmf, const Vector<Real>& ft,
281  int scomp, int dcomp, int ncomp,
282  const Geometry& cgeom, const Geometry& fgeom,
283  Array<BC, AMREX_SPACEDIM>& cbc, const Array<int, AMREX_SPACEDIM>& cbccomp,
284  Array<BC, AMREX_SPACEDIM>& fbc, const Array<int, AMREX_SPACEDIM>& fbccomp,
285  const IntVect& ratio,
286  Interp* mapper,
287  const Array<Vector<BCRec>, AMREX_SPACEDIM>& bcs, const Array<int, AMREX_SPACEDIM>& bcscomp,
288  const PreInterpHook& pre_interp = {},
289  const PostInterpHook& post_interp = {});
290 
332  template <typename MF, typename BC, typename Interp,
333  typename PreInterpHook=NullInterpHook<typename MF::FABType::value_type>,
334  typename PostInterpHook=NullInterpHook<typename MF::FABType::value_type> >
335  std::enable_if_t<IsFabArray<MF>::value>
336  FillPatchTwoLevels (Array<MF*, AMREX_SPACEDIM> const& mf, IntVect const& nghost, Real time,
337  const Vector<Array<MF*, AMREX_SPACEDIM> >& cmf, const Vector<Real>& ct,
338  const Vector<Array<MF*, AMREX_SPACEDIM> >& fmf, const Vector<Real>& ft,
339  int scomp, int dcomp, int ncomp,
340  const Geometry& cgeom, const Geometry& fgeom,
341  Array<BC, AMREX_SPACEDIM>& cbc, int cbccomp,
342  Array<BC, AMREX_SPACEDIM>& fbc, int fbccomp,
343  const IntVect& ratio,
344  Interp* mapper,
345  const Array<Vector<BCRec>, AMREX_SPACEDIM>& bcs, int bcscomp,
346  const PreInterpHook& pre_interp = {},
347  const PostInterpHook& post_interp = {});
348 
389  template <typename MF, typename BC, typename Interp,
390  typename PreInterpHook=NullInterpHook<typename MF::FABType::value_type>,
391  typename PostInterpHook=NullInterpHook<typename MF::FABType::value_type> >
392  std::enable_if_t<IsFabArray<MF>::value>
393  FillPatchTwoLevels (Array<MF*, AMREX_SPACEDIM> const& mf, Real time,
394  const Vector<Array<MF*, AMREX_SPACEDIM> >& cmf, const Vector<Real>& ct,
395  const Vector<Array<MF*, AMREX_SPACEDIM> >& fmf, const Vector<Real>& ft,
396  int scomp, int dcomp, int ncomp,
397  const Geometry& cgeom, const Geometry& fgeom,
398  Array<BC, AMREX_SPACEDIM>& cbc, int cbccomp,
399  Array<BC, AMREX_SPACEDIM>& fbc, int fbccomp,
400  const IntVect& ratio,
401  Interp* mapper,
402  const Array<Vector<BCRec>, AMREX_SPACEDIM>& bcs, int bcscomp,
403  const PreInterpHook& pre_interp = {},
404  const PostInterpHook& post_interp = {});
405 
406 #ifdef AMREX_USE_EB
446  template <typename MF, typename BC, typename Interp, typename PreInterpHook, typename PostInterpHook>
447  std::enable_if_t<IsFabArray<MF>::value>
448  FillPatchTwoLevels (MF& mf, IntVect const& nghost, Real time,
449  const EB2::IndexSpace& index_space,
450  const Vector<MF*>& cmf, const Vector<Real>& ct,
451  const Vector<MF*>& fmf, const Vector<Real>& ft,
452  int scomp, int dcomp, int ncomp,
453  const Geometry& cgeom, const Geometry& fgeom,
454  BC& cbc, int cbccomp,
455  BC& fbc, int fbccomp,
456  const IntVect& ratio,
457  Interp* mapper,
458  const Vector<BCRec>& bcs, int bcscomp,
459  const PreInterpHook& pre_interp,
460  const PostInterpHook& post_interp);
461 
500  template <typename MF, typename BC, typename Interp, typename PreInterpHook, typename PostInterpHook>
501  std::enable_if_t<IsFabArray<MF>::value>
502  FillPatchTwoLevels (MF& mf, Real time,
503  const EB2::IndexSpace& index_space,
504  const Vector<MF*>& cmf, const Vector<Real>& ct,
505  const Vector<MF*>& fmf, const Vector<Real>& ft,
506  int scomp, int dcomp, int ncomp,
507  const Geometry& cgeom, const Geometry& fgeom,
508  BC& cbc, int cbccomp,
509  BC& fbc, int fbccomp,
510  const IntVect& ratio,
511  Interp* mapper,
512  const Vector<BCRec>& bcs, int bcscomp,
513  const PreInterpHook& pre_interp,
514  const PostInterpHook& post_interp);
515 #endif
516 
547  template <typename MF, typename BC, typename Interp,
548  typename PreInterpHook=NullInterpHook<typename MF::FABType::value_type>,
549  typename PostInterpHook=NullInterpHook<typename MF::FABType::value_type> >
550  std::enable_if_t<IsFabArray<MF>::value>
551  InterpFromCoarseLevel (MF& mf, Real time,
552  const MF& cmf, int scomp, int dcomp, int ncomp,
553  const Geometry& cgeom, const Geometry& fgeom,
554  BC& cbc, int cbccomp,
555  BC& fbc, int fbccomp,
556  const IntVect& ratio,
557  Interp* mapper,
558  const Vector<BCRec>& bcs, int bcscomp,
559  const PreInterpHook& pre_interp = {},
560  const PostInterpHook& post_interp = {});
561 
591  template <typename MF, typename BC, typename Interp,
592  typename PreInterpHook=NullInterpHook<typename MF::FABType::value_type>,
593  typename PostInterpHook=NullInterpHook<typename MF::FABType::value_type> >
594  std::enable_if_t<IsFabArray<MF>::value>
595  InterpFromCoarseLevel (MF& mf, IntVect const& nghost, Real time,
596  const MF& cmf, int scomp, int dcomp, int ncomp,
597  const Geometry& cgeom, const Geometry& fgeom,
598  BC& cbc, int cbccomp,
599  BC& fbc, int fbccomp,
600  const IntVect& ratio,
601  Interp* mapper,
602  const Vector<BCRec>& bcs, int bcscomp,
603  const PreInterpHook& pre_interp = {},
604  const PostInterpHook& post_interp = {});
605 
636  template <typename MF, typename BC, typename Interp,
637  typename PreInterpHook=NullInterpHook<typename MF::FABType::value_type>,
638  typename PostInterpHook=NullInterpHook<typename MF::FABType::value_type> >
639  std::enable_if_t<IsFabArray<MF>::value>
640  InterpFromCoarseLevel (Array<MF*, AMREX_SPACEDIM> const& mf, Real time,
641  const Array<MF*, AMREX_SPACEDIM>& cmf, int scomp, int dcomp, int ncomp,
642  const Geometry& cgeom, const Geometry& fgeom,
643  Array<BC, AMREX_SPACEDIM>& cbc, int cbccomp,
644  Array<BC, AMREX_SPACEDIM>& fbc, int fbccomp,
645  const IntVect& ratio,
646  Interp* mapper,
647  const Array<Vector<BCRec>, AMREX_SPACEDIM>& bcs, int bcscomp,
648  const PreInterpHook& pre_interp = {},
649  const PostInterpHook& post_interp = {});
650 
682  template <typename MF, typename BC, typename Interp,
683  typename PreInterpHook=NullInterpHook<typename MF::FABType::value_type>,
684  typename PostInterpHook=NullInterpHook<typename MF::FABType::value_type> >
685  std::enable_if_t<IsFabArray<MF>::value>
686  InterpFromCoarseLevel (Array<MF*, AMREX_SPACEDIM> const& mf, IntVect const& nghost, Real time,
687  const Array<MF*, AMREX_SPACEDIM>& cmf, int scomp, int dcomp, int ncomp,
688  const Geometry& cgeom, const Geometry& fgeom,
689  Array<BC, AMREX_SPACEDIM>& cbc, int cbccomp,
690  Array<BC, AMREX_SPACEDIM>& fbc, int fbccomp,
691  const IntVect& ratio,
692  Interp* mapper,
693  const Array<Vector<BCRec>, AMREX_SPACEDIM>& bcs, int bcscomp,
694  const PreInterpHook& pre_interp = {},
695  const PostInterpHook& post_interp = {});
696 
723  template <typename MF, typename Interp>
724  std::enable_if_t<IsFabArray<MF>::value>
725  InterpFromCoarseLevel (MF& mf, IntVect const& nghost,
726  IntVect const& nghost_outside_domain,
727  const MF& cmf, int scomp, int dcomp, int ncomp,
728  const Geometry& cgeom, const Geometry& fgeom,
729  const IntVect& ratio, Interp* mapper,
730  const Vector<BCRec>& bcs, int bcscomp);
731 
754  template <typename MF>
755  std::enable_if_t<IsFabArray<MF>::value>
756  FillPatchSingleLevel (MF& mf, IntVect const& nghost, Real time,
757  const Vector<MF*>& smf, IntVect const& snghost,
758  const Vector<Real>& stime, int scomp, int dcomp, int ncomp,
759  const Geometry& geom);
760 
791  template <typename MF, typename Interp>
792  std::enable_if_t<IsFabArray<MF>::value>
793  FillPatchTwoLevels (MF& mf, IntVect const& nghost,
794  IntVect const& nghost_outside_domain, Real time,
795  const Vector<MF*>& cmf, const Vector<Real>& ct,
796  const Vector<MF*>& fmf, const Vector<Real>& ft,
797  int scomp, int dcomp, int ncomp,
798  const Geometry& cgeom, const Geometry& fgeom,
799  const IntVect& ratio, Interp* mapper,
800  const Vector<BCRec>& bcs, int bcscomp);
801 
802 #ifndef BL_NO_FORT
804 
805  void InterpCrseFineBndryEMfield (InterpEM_t interp_type,
806  const Array<MultiFab,AMREX_SPACEDIM>& crse,
807  Array<MultiFab,AMREX_SPACEDIM>& fine,
808  const Geometry& cgeom, const Geometry& fgeom,
809  int ref_ratio);
810 
811  void InterpCrseFineBndryEMfield (InterpEM_t interp_type,
812  const Array<MultiFab const*,AMREX_SPACEDIM>& crse,
813  const Array<MultiFab*,AMREX_SPACEDIM>& fine,
814  const Geometry& cgeom, const Geometry& fgeom,
815  int ref_ratio);
816 #endif
817 
856  template <typename MF, typename BC, typename Interp>
857  std::enable_if_t<IsFabArray<MF>::value>
858  FillPatchNLevels (MF& mf, int level, const IntVect& nghost, Real time,
859  const Vector<Vector<MF*>>& smf, const Vector<Vector<Real>>& st,
860  int scomp, int dcomp, int ncomp,
861  const Vector<Geometry>& geom,
862  Vector<BC>& bc, int bccomp,
863  const Vector<IntVect>& ratio,
864  Interp* mapper,
865  const Vector<BCRec>& bcr, int bcrcomp);
866 
867 }
868 
869 #include <AMReX_FillPatchUtil_I.H>
870 
871 #endif
Array4< Real > fine
Definition: AMReX_InterpFaceRegister.cpp:90
Array4< Real const > crse
Definition: AMReX_InterpFaceRegister.cpp:92
Definition: AMReX_Amr.cpp:49
InterpEM_t
Definition: AMReX_FillPatchUtil.H:803
@ InterpB
Definition: AMReX_FillPatchUtil.H:803
@ InterpE
Definition: AMReX_FillPatchUtil.H:803
void InterpCrseFineBndryEMfield(InterpEM_t interp_type, const Array< MultiFab, AMREX_SPACEDIM > &crse, Array< MultiFab, AMREX_SPACEDIM > &fine, const Geometry &cgeom, const Geometry &fgeom, int ref_ratio)
Definition: AMReX_FillPatchUtil.cpp:11
bool ProperlyNested(const IntVect &ratio, const IntVect &blocking_factor, int ngrow, const IndexType &boxType, Interp *mapper)
Test if AMR grids are properly nested.
Definition: AMReX_FillPatchUtil_I.H:33
std::enable_if_t< IsFabArray< MF >::value > FillPatchSingleLevel(MF &mf, IntVect const &nghost, Real time, const Vector< MF * > &smf, const Vector< Real > &stime, int scomp, int dcomp, int ncomp, const Geometry &geom, BC &physbcf, int bcfcomp)
FillPatch with data from the current level.
Definition: AMReX_FillPatchUtil_I.H:73
std::enable_if_t< IsFabArray< MF >::value > FillPatchTwoLevels(MF &mf, IntVect const &nghost, Real time, const Vector< MF * > &cmf, const Vector< Real > &ct, const Vector< MF * > &fmf, const Vector< Real > &ft, int scomp, int dcomp, int ncomp, const Geometry &cgeom, const Geometry &fgeom, BC &cbc, int cbccomp, BC &fbc, int fbccomp, const IntVect &ratio, Interp *mapper, const Vector< BCRec > &bcs, int bcscomp, const PreInterpHook &pre_interp={}, const PostInterpHook &post_interp={})
FillPatch with data from the current level and the level below.
Definition: AMReX_FillPatchUtil_I.H:796
std::enable_if_t< IsFabArray< MF >::value > InterpFromCoarseLevel(MF &mf, Real time, const MF &cmf, int scomp, int dcomp, int ncomp, const Geometry &cgeom, const Geometry &fgeom, BC &cbc, int cbccomp, BC &fbc, int fbccomp, const IntVect &ratio, Interp *mapper, const Vector< BCRec > &bcs, int bcscomp, const PreInterpHook &pre_interp={}, const PostInterpHook &post_interp={})
Fill with interpolation of coarse level data.
Definition: AMReX_FillPatchUtil_I.H:984
IntVectND< AMREX_SPACEDIM > IntVect
Definition: AMReX_BaseFwd.H:30
std::enable_if_t< IsFabArray< MF >::value > FillPatchNLevels(MF &mf, int level, const IntVect &nghost, Real time, const Vector< Vector< MF * >> &smf, const Vector< Vector< Real >> &st, int scomp, int dcomp, int ncomp, const Vector< Geometry > &geom, Vector< BC > &bc, int bccomp, const Vector< IntVect > &ratio, Interp *mapper, const Vector< BCRec > &bcr, int bcrcomp)
FillPatch with data from AMR levels.
Definition: AMReX_FillPatchUtil_I.H:1308
IndexTypeND< AMREX_SPACEDIM > IndexType
Definition: AMReX_BaseFwd.H:33
std::array< T, N > Array
Definition: AMReX_Array.H:24
Definition: AMReX_FillPatchUtil.H:34
void operator()(MFFAB &, const Box &, int, int) const
Definition: AMReX_FillPatchUtil.H:36