ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_StructureCoarseSource.H
Go to the documentation of this file.
1 #ifndef ERF_STRUCTURE_COARSE_SOURCE_H_
2 #define ERF_STRUCTURE_COARSE_SOURCE_H_
3 
4 /**
5  * @file ERF_StructureCoarseSource.H
6  * @brief The restriction of a structure model's momentum source onto the coarser levels
7  *
8  * ERF::make_structure_coarse_sources calls it at the start of each step of a level below the
9  * model's level (erf.coupling_type = TwoWay). The restriction keeps the force the source
10  * puts on the air, the integral of the source over the faces' control volumes, on uniform,
11  * stretched and terrain-following meshes.
12  */
13 
14 #include <AMReX_BoxArray.H>
15 #include <AMReX_DistributionMapping.H>
16 #include <AMReX_Geometry.H>
17 #include <AMReX_IntVect.H>
18 #include <AMReX_MultiFab.H>
19 #include <AMReX_Vector.H>
20 
21 #include <array>
22 
23 namespace erf_structure {
24 
25 /**
26  * @brief Restrict face-centered momentum sources from level L down to level lev < L
27  *
28  * src holds the source [N/m^3] on the faces of grids[L] (x, y, z faces; it may have ghost
29  * faces). On return it holds the source on the faces of grids[lev], without ghost faces,
30  * zero away from the region level L covers.
31  *
32  * The force on a face is the source times the face's control volume, J_f dx dy dz, with
33  * J_f the mesh Jacobian on the face (the mean of detJ in the two cells beside it, the one
34  * cell inside the domain on a non-periodic domain face). The restriction goes down one level
35  * at a time: coarse face I takes the forces of the fine faces r I + m, |m| < r, along the
36  * face normal with the weights (r - |m|) / r, and of every fine face across it. Each fine
37  * force is shared out with weights that add up to 1, so the total force is kept exactly,
38  * also when the fine level is split into boxes or crosses a periodic boundary. On a
39  * non-periodic domain face, where the boundary condition sets the momentum, a fine face
40  * inside the domain gives its whole force to the first coarse face inside, so the force
41  * on the faces inside the domain is kept too. The coarse source is the coarse force divided
42  * by the coarse face's control volume.
43  *
44  * detJ[l] is detJ_cc of level l, with one ghost cell filled, on a stretched or
45  * terrain-following mesh, and nullptr on a uniform-dz mesh (J_f = 1 there, and no Jacobian
46  * is applied).
47  */
48 void restrict_face_sources (std::array<amrex::MultiFab,AMREX_SPACEDIM>& src, int L, int lev,
49  const amrex::Vector<amrex::BoxArray>& grids,
50  const amrex::Vector<amrex::DistributionMapping>& dmap,
51  const amrex::Vector<amrex::Geometry>& geom,
52  const amrex::Vector<amrex::IntVect>& ref_ratio,
53  const amrex::Vector<const amrex::MultiFab*>& detJ);
54 
55 /**
56  * @brief Multiply (divide = false) or divide (divide = true) the valid faces normal to dir
57  * by the face Jacobian J_f described above
58  *
59  * mf lives on the faces of detJ's boxes, with detJ's distribution.
60  */
61 void scale_by_face_jacobian (amrex::MultiFab& mf, int dir, const amrex::MultiFab& detJ,
62  const amrex::Geometry& geom, bool divide);
63 
64 /**
65  * @brief The force [N] a face source puts on the air, per direction: the sum over the faces
66  * of the source times J_f dx dy dz, each face counted once
67  *
68  * src[d] holds the source on the faces normal to d of detJ's boxes (no ghost faces needed);
69  * detJ is nullptr on a uniform-dz mesh (J_f = 1). Reduces over the ranks.
70  */
71 std::array<amrex::Real,AMREX_SPACEDIM>
72 face_source_force (const std::array<amrex::MultiFab,AMREX_SPACEDIM>& src,
73  const amrex::Geometry& geom, const amrex::MultiFab* detJ);
74 
75 } // namespace erf_structure
76 
77 #endif
Definition: ERF_StructureCoarseSource.cpp:88
std::array< Real, AMREX_SPACEDIM > face_source_force(const std::array< MultiFab, AMREX_SPACEDIM > &src, const Geometry &geom, const MultiFab *detJ)
Definition: ERF_StructureCoarseSource.cpp:165
void scale_by_face_jacobian(MultiFab &mf, int dir, const MultiFab &detJ, const Geometry &geom, bool divide)
Definition: ERF_StructureCoarseSource.cpp:91
void restrict_face_sources(std::array< MultiFab, AMREX_SPACEDIM > &src, int L, int lev, const Vector< BoxArray > &grids, const Vector< DistributionMapping > &dmap, const Vector< Geometry > &geom, const Vector< IntVect > &ref_ratio, const Vector< const MultiFab * > &detJ)
Definition: ERF_StructureCoarseSource.cpp:122