Block-Structured AMR Software Framework
AMReX_MultiFabUtilI.H
Go to the documentation of this file.
1 
2 // Used by EB_LSCore only. Might be removed in the future. So don't use.
3 
4 namespace amrex::MFUtil {
5 
7 
11  template<typename T>
12  struct SymmetricGhost {
13  static void copy (T & target, const T & source, int nc, int ng) {
14  target.ParallelCopy(source, 0, 0, nc, ng, ng);
15  }
16  };
17 
18 
22  template<typename T> // T can be either MultiFab or iMultiFab
23  struct AsymmetricGhost {
24  static void copy (T & target, const T & source, int nc, int ng) {
25  target.ParallelCopy(source, 0, 0, nc, 0, ng);
26  }
27  };
28 
29 
35  template<typename T, template<typename> class Cpy>
36  T duplicate(const BoxArray & ba, const DistributionMapping & dm, const T & mf_in) {
37 
38  int ng = mf_in.nGrow();
39  int nc = mf_in.nComp();
40 
41  T mf_out(ba, dm, nc, ng);
42 
43  Cpy<T>::copy(mf_out, mf_in, nc, ng);
44 
45  return mf_out;
46  }
47 
48 
55  template<typename T, template<typename> class Cpy>
56  T duplicate(const BoxArray & ba, const DistributionMapping & dm, const T & mf_in,
57  const Periodicity & periodicity) {
58 
59  T mf_out = duplicate<T, Cpy>(ba, dm, mf_in);
60  mf_out.FillBoundary(periodicity);
61 
62  return mf_out;
63  }
64 
65 
70  template<typename T>
71  T regrid(const BoxArray & ba, const DistributionMapping & dm,
72  const T & mf_in, bool regrid_ghost = false ) {
73 
74  if (regrid_ghost) {
75  T mf_out = duplicate<T, SymmetricGhost>(ba, dm, mf_in);
76  return mf_out;
77  } else {
78  T mf_out = duplicate<T, AsymmetricGhost>(ba, dm, mf_in);
79  return mf_out;
80  }
81  }
82 
83 
89  template<typename T>
90  void regrid( T & mf_out, const BoxArray & ba, const DistributionMapping & dm,
91  const T & mf_in, bool regrid_ghost = false ) {
92 
93  int ng = mf_in.nGrow();
94  int nc = mf_in.nComp();
95 
96  mf_out.define(ba, dm, nc, ng);
97  if (regrid_ghost) { SymmetricGhost<T>::copy(mf_out, mf_in, nc, ng); }
98  else { AsymmetricGhost<T>::copy(mf_out, mf_in, nc, ng); }
99  }
100 
101 
106  template<typename T>
107  void regrid( T & mf_out, const BoxArray & ba, const DistributionMapping & dm,
108  const FabFactory<FArrayBox> & eb_factory,
109  const T & mf_in, bool regrid_ghost = false ) {
110 
111  int ng = mf_in.nGrow();
112  int nc = mf_in.nComp();
113 
114  mf_out.define(ba, dm, nc, ng, MFInfo(), eb_factory);
115  if (regrid_ghost) { SymmetricGhost<T>::copy(mf_out, mf_in, nc, ng); }
116  else { AsymmetricGhost<T>::copy(mf_out, mf_in, nc, ng); }
117  }
118 
119 }
A collection of Boxes stored in an Array.
Definition: AMReX_BoxArray.H:549
Calculates the distribution of FABs to MPI processes.
Definition: AMReX_DistributionMapping.H:41
This provides length of period for periodic domains. 0 means it is not periodic in that direction....
Definition: AMReX_Periodicity.H:17
void copy(HostToDevice, InIter begin, InIter end, OutIter result) noexcept
A host-to-device copy routine. Note this is just a wrapper around memcpy, so it assumes contiguous st...
Definition: AMReX_GpuContainers.H:121
Definition: AMReX_MultiFabUtilI.H:4
T duplicate(const BoxArray &ba, const DistributionMapping &dm, const T &mf_in)
Definition: AMReX_MultiFabUtilI.H:36
T regrid(const BoxArray &ba, const DistributionMapping &dm, const T &mf_in, bool regrid_ghost=false)
Definition: AMReX_MultiFabUtilI.H:71
FabArray memory allocation information.
Definition: AMReX_FabArray.H:66
Definition: AMReX_MultiFabUtilI.H:23
static void copy(T &target, const T &source, int nc, int ng)
Definition: AMReX_MultiFabUtilI.H:24
General collection of MultiFab utilities.
Definition: AMReX_MultiFabUtilI.H:12
static void copy(T &target, const T &source, int nc, int ng)
Definition: AMReX_MultiFabUtilI.H:13