Block-Structured AMR Software Framework
 
Loading...
Searching...
No Matches
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
5
6namespace amrex::MFUtil {
7
9
13 template<typename T>
14 struct SymmetricGhost {
15 static void copy (T & target, const T & source, int nc, int ng) {
16 target.ParallelCopy(source, 0, 0, nc, ng, ng);
17 }
18 };
19
20
24 template<typename T> // T can be either MultiFab or iMultiFab
25 struct AsymmetricGhost {
26 static void copy (T & target, const T & source, int nc, int ng) {
27 target.ParallelCopy(source, 0, 0, nc, 0, ng);
28 }
29 };
30
31
37 template<typename T, template<typename> class Cpy>
38 T duplicate(const BoxArray & ba, const DistributionMapping & dm, const T & mf_in) {
39
40 int ng = mf_in.nGrow();
41 int nc = mf_in.nComp();
42
43 T mf_out(ba, dm, nc, ng);
44
45 Cpy<T>::copy(mf_out, mf_in, nc, ng);
46
47 return mf_out;
48 }
49
50
57 template<typename T, template<typename> class Cpy>
58 T duplicate(const BoxArray & ba, const DistributionMapping & dm, const T & mf_in,
59 const Periodicity & periodicity) {
60
61 T mf_out = duplicate<T, Cpy>(ba, dm, mf_in);
62 mf_out.FillBoundary(periodicity);
63
64 return mf_out;
65 }
66
67
72 template<typename T>
73 T regrid(const BoxArray & ba, const DistributionMapping & dm,
74 const T & mf_in, bool regrid_ghost = false ) {
75
76 if (regrid_ghost) {
77 T mf_out = duplicate<T, SymmetricGhost>(ba, dm, mf_in);
78 return mf_out;
79 } else {
80 T mf_out = duplicate<T, AsymmetricGhost>(ba, dm, mf_in);
81 return mf_out;
82 }
83 }
84
85
91 template<typename T>
92 void regrid( T & mf_out, const BoxArray & ba, const DistributionMapping & dm,
93 const T & mf_in, bool regrid_ghost = false ) {
94
95 int ng = mf_in.nGrow();
96 int nc = mf_in.nComp();
97
98 mf_out.define(ba, dm, nc, ng);
99 if (regrid_ghost) { SymmetricGhost<T>::copy(mf_out, mf_in, nc, ng); }
100 else { AsymmetricGhost<T>::copy(mf_out, mf_in, nc, ng); }
101 }
102
103
108 template<typename T>
109 void regrid( T & mf_out, const BoxArray & ba, const DistributionMapping & dm,
110 const FabFactory<FArrayBox> & eb_factory,
111 const T & mf_in, bool regrid_ghost = false ) {
112
113 int ng = mf_in.nGrow();
114 int nc = mf_in.nComp();
115
116 mf_out.define(ba, dm, nc, ng, MFInfo(), eb_factory);
117 if (regrid_ghost) { SymmetricGhost<T>::copy(mf_out, mf_in, nc, ng); }
118 else { AsymmetricGhost<T>::copy(mf_out, mf_in, nc, ng); }
119 }
120
121}
122
124
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:128