AMReX-Hydro
AMReX-based hydro routines for low Mach number flows
hydro_utils.H
Go to the documentation of this file.
1 /** \addtogroup Utilities
2  * @{
3  */
4 
5 #ifndef HYDRO_UTILS_H
6 #define HYDRO_UTILS_H
7 
8 #include <AMReX_MultiFabUtil.H>
9 #include <AMReX_BCRec.H>
10 #include <hydro_godunov_ppm.H>
11 
12 #ifdef AMREX_USE_EB
13 #include <AMReX_EBFabFactory.H>
14 #include <AMReX_EBMultiFabUtil.H>
15 #endif
16 
17 /**
18  * Collection of hydro utility functions
19  *
20  */
21 
22 namespace HydroUtils {
23 
24 /**
25  * \brief Enforces solvablity by scaling outflow to match with inflow.
26  *
27  */
30  amrex::BCRec const* bc_type,
32  bool include_bndry_corners = false);
33 
34 /**
35  * \brief Compute edge state and flux. Most general version for use with multilevel synchronization.
36  * All other versions ultimately call this one.
37  * Allows time-depdendent inflow and inflow through EB.
38  */
39 void
44  amrex::Array4<amrex::Real> const& flux_y,
45  amrex::Array4<amrex::Real> const& flux_z),
47  amrex::Array4<amrex::Real> const& face_y,
48  amrex::Array4<amrex::Real> const& face_z),
49  bool knownFaceState,
55  amrex::Array4<amrex::Real const> const& w_flux),
58  amrex::Geometry geom,
59  amrex::Real l_dt,
60  amrex::Vector<amrex::BCRec> const& h_bcrec,
61  const amrex::BCRec* d_bcrec,
62  int const* iconserv,
63 #ifdef AMREX_USE_EB
64  const amrex::EBFArrayBoxFactory& ebfact,
65  amrex::Array4<amrex::Real const> const& values_on_eb_inflow,
66 #endif
67  bool godunov_use_ppm, bool godunov_use_forces_in_trans,
68  bool is_velocity, bool fluxes_are_area_weighted,
69  std::string const& advection_type,
70  int limiter_type = PPM::default_limiter,
71  bool allow_inflow_on_outflow = false,
72  amrex::Array4<int const> const& bc_arr = {});
73 
74 void
78  amrex::Array4<amrex::Real> const& flux_y,
79  amrex::Array4<amrex::Real> const& flux_z),
81  amrex::Array4<amrex::Real> const& face_y,
82  amrex::Array4<amrex::Real> const& face_z),
83  bool knownFaceState,
89  amrex::Array4<amrex::Real const> const& w_flux),
92  amrex::Geometry geom,
93  amrex::Real l_dt,
94  amrex::Vector<amrex::BCRec> const& h_bcrec,
95  const amrex::BCRec* d_bcrec,
96  int const* iconserv,
97 #ifdef AMREX_USE_EB
98  const amrex::EBFArrayBoxFactory& ebfact,
99  amrex::Array4<amrex::Real const> const& values_on_eb_inflow,
100 #endif
101  bool godunov_use_ppm, bool godunov_use_forces_in_trans,
102  bool is_velocity, bool fluxes_are_area_weighted,
103  std::string const& advection_type,
104  int limiter_type = PPM::default_limiter,
105  bool allow_inflow_on_outflow = false,
106  amrex::Array4<int const> const& bc_arr = {});
107 /**
108  * \brief Compute edge state and flux. Allows inflow on EB but NOT time-dependent inflow.
109  *
110  */
111 void
115  amrex::Array4<amrex::Real> const& flux_y,
116  amrex::Array4<amrex::Real> const& flux_z),
118  amrex::Array4<amrex::Real> const& face_y,
119  amrex::Array4<amrex::Real> const& face_z),
120  bool knownFaceState,
123  amrex::Array4<amrex::Real const> const& w_mac),
126  amrex::Geometry geom,
127  amrex::Real l_dt,
128  amrex::Vector<amrex::BCRec> const& h_bcrec,
129  const amrex::BCRec* d_bcrec,
130  int const* iconserv,
131 #ifdef AMREX_USE_EB
132  const amrex::EBFArrayBoxFactory& ebfact,
133  amrex::Array4<amrex::Real const> const& values_on_eb_inflow,
134 #endif
135  bool godunov_use_ppm, bool godunov_use_forces_in_trans,
136  bool is_velocity, bool fluxes_are_area_weighted,
137  std::string const& advection_type,
138  int limiter_type = PPM::default_limiter,
139  bool allow_inflow_on_outflow = false,
140  amrex::Array4<int const> const& bc_arr = {});
141 
142 #ifdef AMREX_USE_EB
143 /**
144  * \brief Compute edge state and flux. Allows time-depdendent inflow but no inflow through EB.
145  *
146  */
147 void
148 ComputeFluxesOnBoxFromState (amrex::Box const& bx, int ncomp, amrex::MFIter& mfi,
152  amrex::Array4<amrex::Real> const& flux_y,
153  amrex::Array4<amrex::Real> const& flux_z),
155  amrex::Array4<amrex::Real> const& face_y,
156  amrex::Array4<amrex::Real> const& face_z),
157  bool knownFaceState,
160  amrex::Array4<amrex::Real const> const& w_mac),
163  amrex::Geometry geom,
164  amrex::Real l_dt,
165  amrex::Vector<amrex::BCRec> const& h_bcrec,
166  const amrex::BCRec* d_bcrec,
167  int const* iconserv,
168  const amrex::EBFArrayBoxFactory& ebfact,
169  /*amrex::Array4<amrex::Real const> const& values_on_eb_inflow,*/
170  bool godunov_use_ppm, bool godunov_use_forces_in_trans,
171  bool is_velocity, bool fluxes_are_area_weighted,
172  std::string const& advection_type,
173  int limiter_type = PPM::default_limiter,
174  bool allow_inflow_on_outflow = false,
175  amrex::Array4<int const> const& bc_arr = {});
176 #endif
177 
178 /**
179  * \brief Compute edge state and flux. Does NOT allow time-depdendent inflow or inflow through EB.
180  *
181  */
182 #ifdef AMREX_USE_EB
183 void
184 ComputeFluxesOnBoxFromState ( amrex::Box const& bx, int ncomp, amrex::MFIter& mfi,
187  amrex::Array4<amrex::Real> const& flux_y,
188  amrex::Array4<amrex::Real> const& flux_z),
190  amrex::Array4<amrex::Real> const& face_y,
191  amrex::Array4<amrex::Real> const& face_z),
192  bool knownFaceState,
195  amrex::Array4<amrex::Real const> const& w_mac),
198  amrex::Geometry geom,
199  amrex::Real l_dt,
200  amrex::Vector<amrex::BCRec> const& h_bcrec,
201  const amrex::BCRec* d_bcrec,
202  int const* iconserv,
203  const amrex::EBFArrayBoxFactory& ebfact,
204  /*amrex::Array4<amrex::Real const> const& values_on_eb_inflow,*/
205  bool godunov_use_ppm, bool godunov_use_forces_in_trans,
206  bool is_velocity, bool fluxes_are_area_weighted,
207  std::string const& advection_type,
208  int limiter_type = PPM::default_limiter,
209  bool allow_inflow_on_outflow = false,
210  amrex::Array4<int const> const& bc_arr = {});
211 #endif
212 
213 /**
214  * \brief Compute edge state and flux. Allows time-depdendent inflow and inflow through EB.
215  *
216  */
217 void
222  amrex::Array4<amrex::Real> const& flux_y,
223  amrex::Array4<amrex::Real> const& flux_z),
225  amrex::Array4<amrex::Real> const& face_y,
226  amrex::Array4<amrex::Real> const& face_z),
227  bool knownFaceState,
230  amrex::Array4<amrex::Real const> const& w_mac),
233  amrex::Geometry geom,
234  amrex::Real l_dt,
235  amrex::Vector<amrex::BCRec> const& h_bcrec,
236  const amrex::BCRec* d_bcrec,
237  int const* iconserv,
238 #ifdef AMREX_USE_EB
239  const amrex::EBFArrayBoxFactory& ebfact,
240  amrex::Array4<amrex::Real const> const& values_on_eb_inflow,
241 #endif
242  bool godunov_use_ppm, bool godunov_use_forces_in_trans,
243  bool is_velocity, bool fluxes_are_area_weighted,
244  std::string const& advection_type,
245  int limiter_type = PPM::default_limiter,
246  bool allow_inflow_on_outflow = false,
247  amrex::Array4<int const> const& bc_arr = {});
248 
249 #ifdef AMREX_USE_EB
250 void
251 ExtrapVelToFaces ( amrex::MultiFab const& vel,
252  amrex::MultiFab const& vel_forces,
254  amrex::MultiFab& v_mac,
255  amrex::MultiFab& w_mac),
256  amrex::Vector<amrex::BCRec> const& h_bcrec,
257  amrex::BCRec const* d_bcrec,
258  const amrex::Geometry& geom,
259  amrex::Real dt,
260  const amrex::EBFArrayBoxFactory& ebfact,
261  bool godunov_ppm, bool godunov_use_forces_in_trans,
262  std::string const& advection_type,
263  int limiter_type = PPM::default_limiter,
264  bool allow_inflow_on_outflow = false);
265 #endif
266 
267 void
268 ExtrapVelToFaces ( amrex::MultiFab const& vel,
269  amrex::MultiFab const& vel_forces,
271  amrex::MultiFab& v_mac,
272  amrex::MultiFab& w_mac),
273  amrex::Vector<amrex::BCRec> const& h_bcrec,
274  amrex::BCRec const* d_bcrec,
275  const amrex::Geometry& geom,
276  amrex::Real dt,
277 #ifdef AMREX_USE_EB
278  const amrex::EBFArrayBoxFactory& ebfact,
279  amrex::MultiFab const* velocity_on_eb_inflow,
280 #endif
281  bool godunov_ppm, bool godunov_use_forces_in_trans,
282  std::string const& advection_type,
283  int limiter_type = PPM::default_limiter,
284  bool allow_inflow_on_outflow = false,
285  amrex::iMultiFab* BC_MF = nullptr);
286 
287 /**
288  * \brief If convective, compute convTerm = u dot grad q = div (u q) - q div(u).
289  *
290  */
291 void
292 ComputeConvectiveTerm ( amrex::Box const& bx, int num_comp, amrex::MFIter& mfi,
295  amrex::Array4<amrex::Real const> const& q_on_face_y,
296  amrex::Array4<amrex::Real const> const& q_on_face_z),
298  amrex::Array4<amrex::Real> const& convTerm,
299  int const* iconserv,
300 #ifdef AMREX_USE_EB
301  const amrex::EBFArrayBoxFactory& ebfact,
302 #endif
303  std::string const& advection_type);
304 
305 /**
306  * \brief Compute Fluxes.
307  *
308  */
309 void ComputeFluxes ( amrex::Box const& bx,
311  amrex::Array4<amrex::Real> const& fy,
312  amrex::Array4<amrex::Real> const& fz),
319  amrex::Geometry const& geom, int ncomp,
320  bool fluxes_are_area_weighted,
321  int const* iconserv);
322 
323 /**
324  * \brief Compute divergence.
325  *
326  */
327 
328 void ComputeDivergence ( amrex::Box const& bx,
329  amrex::Array4<amrex::Real> const& div,
333  int ncomp, amrex::Geometry const& geom,
334  amrex::Real mult,
335  bool fluxes_are_area_weighted);
336 
337 #ifdef AMREX_USE_EB
338 
339 void EB_ComputeFluxes ( amrex::Box const& bx,
341  amrex::Array4<amrex::Real> const& fy,
342  amrex::Array4<amrex::Real> const& fz),
348  amrex::Array4<amrex::Real const> const& zedge),
352  amrex::Geometry const& geom, int ncomp,
354  bool fluxes_are_area_weighted,
355  int const* iconserv);
356 
357 
358 void EB_ComputeDivergence ( amrex::Box const& bx,
359  amrex::Array4<amrex::Real> const& div,
364  int ncomp, amrex::Geometry const& geom,
365  amrex::Real mult,
366  bool fluxes_are_area_weighted);
367 
368 
369 void EB_ComputeDivergence ( amrex::Box const& bx,
370  amrex::Array4<amrex::Real> const& div,
375  int ncomp, amrex::Geometry const& geom,
376  amrex::Real mult,
377  bool fluxes_are_area_weighted,
378  amrex::Array4<amrex::Real const> const& eb_velocity,
379  amrex::Array4<amrex::Real const> const& values_on_eb_inflow,
382  amrex::Array4<amrex::Real const> const& bnorm);
383 #endif
384 }
385 
386 #endif
387 /** @}*/
#define AMREX_D_DECL(a, b, c)
void enforceInOutSolvability(const Vector< Array< MultiFab *, AMREX_SPACEDIM >> &vels_vec, const BCRec *bc_type, const Vector< Geometry > &geom, bool include_bndry_corners)
Definition: hydro_enforce_inout_solvability.cpp:264
void ExtrapVelToFaces(amrex::MultiFab const &vel, amrex::MultiFab const &vel_forces, AMREX_D_DECL(amrex::MultiFab &u_mac, amrex::MultiFab &v_mac, amrex::MultiFab &w_mac), amrex::Vector< amrex::BCRec > const &h_bcrec, amrex::BCRec const *d_bcrec, const amrex::Geometry &geom, amrex::Real dt, bool godunov_ppm, bool godunov_use_forces_in_trans, std::string const &advection_type, int limiter_type=PPM::default_limiter, bool allow_inflow_on_outflow=false, amrex::iMultiFab *BC_MF=nullptr)
Definition: hydro_extrap_vel_to_faces.cpp:42
Definition: hydro_enforce_inout_solvability.cpp:9
void ComputeConvectiveTerm(amrex::Box const &bx, int num_comp, amrex::MFIter &mfi, amrex::Array4< amrex::Real const > const &q, AMREX_D_DECL(amrex::Array4< amrex::Real const > const &q_on_face_x, amrex::Array4< amrex::Real const > const &q_on_face_y, amrex::Array4< amrex::Real const > const &q_on_face_z), amrex::Array4< amrex::Real const > const &divu, amrex::Array4< amrex::Real > const &convTerm, int const *iconserv, std::string const &advection_type)
If convective, compute convTerm = u dot grad q = div (u q) - q div(u).
void ComputeDivergence(amrex::Box const &bx, amrex::Array4< amrex::Real > const &div, AMREX_D_DECL(amrex::Array4< amrex::Real const > const &fx, amrex::Array4< amrex::Real const > const &fy, amrex::Array4< amrex::Real const > const &fz), int ncomp, amrex::Geometry const &geom, amrex::Real mult, bool fluxes_are_area_weighted)
Compute divergence.
void ComputeFluxesOnBoxFromState(amrex::Box const &bx, int ncomp, amrex::MFIter &mfi, amrex::Array4< amrex::Real const > const &q, amrex::Array4< amrex::Real const > const &qnph, AMREX_D_DECL(amrex::Array4< amrex::Real > const &flux_x, amrex::Array4< amrex::Real > const &flux_y, amrex::Array4< amrex::Real > const &flux_z), AMREX_D_DECL(amrex::Array4< amrex::Real > const &face_x, amrex::Array4< amrex::Real > const &face_y, amrex::Array4< amrex::Real > const &face_z), bool knownFaceState, AMREX_D_DECL(amrex::Array4< amrex::Real const > const &u_mac, amrex::Array4< amrex::Real const > const &v_mac, amrex::Array4< amrex::Real const > const &w_mac), AMREX_D_DECL(amrex::Array4< amrex::Real const > const &u_flux, amrex::Array4< amrex::Real const > const &v_flux, amrex::Array4< amrex::Real const > const &w_flux), amrex::Array4< amrex::Real const > const &divu, amrex::Array4< amrex::Real const > const &fq, amrex::Geometry geom, amrex::Real l_dt, amrex::Vector< amrex::BCRec > const &h_bcrec, const amrex::BCRec *d_bcrec, int const *iconserv, bool godunov_use_ppm, bool godunov_use_forces_in_trans, bool is_velocity, bool fluxes_are_area_weighted, std::string const &advection_type, int limiter_type=PPM::default_limiter, bool allow_inflow_on_outflow=false, amrex::Array4< int const > const &bc_arr={})
Compute edge state and flux. Most general version for use with multilevel synchronization....
void ComputeFluxes(amrex::Box const &bx, AMREX_D_DECL(amrex::Array4< amrex::Real > const &fx, amrex::Array4< amrex::Real > const &fy, amrex::Array4< amrex::Real > const &fz), AMREX_D_DECL(amrex::Array4< amrex::Real const > const &umac, amrex::Array4< amrex::Real const > const &vmac, amrex::Array4< amrex::Real const > const &wmac), AMREX_D_DECL(amrex::Array4< amrex::Real const > const &xed, amrex::Array4< amrex::Real const > const &yed, amrex::Array4< amrex::Real const > const &zed), amrex::Geometry const &geom, int ncomp, bool fluxes_are_area_weighted, int const *iconserv)
Compute Fluxes.
static constexpr int default_limiter
Definition: hydro_godunov_ppm.H:86
std::array< T, N > Array