/home/runner/work/amr-wind/amr-wind/amr-wind/equation_systems/AdvOp_MOL.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/equation_systems/AdvOp_MOL.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
AdvOp_MOL.H
Go to the documentation of this file.
1#ifndef ADVOP_MOL_H
2#define ADVOP_MOL_H
3
4#include <type_traits>
5
10
11#include "AMReX_Gpu.H"
12#include "AMReX_ParmParse.H"
13
14namespace amr_wind::pde {
15
19template <typename PDE>
21 PDE,
22 fvm::MOL,
23 typename std::enable_if_t<std::is_base_of_v<ScalarTransport, PDE>>>
24{
25 // cppcheck-suppress uninitMemberVar
27 CFDSim& /* sim */,
28 PDEFields& fields_in,
29 bool /* has_overset */,
30 bool /* variable density */,
31 bool /* mesh mapping */,
32 bool /* is_anelastic */)
33 : fields(fields_in)
34 , density(fields_in.repo.get_field("density"))
35 , u_mac(fields_in.repo.get_field("u_mac"))
36 , v_mac(fields_in.repo.get_field("v_mac"))
37 , w_mac(fields_in.repo.get_field("w_mac"))
38 {}
39
41 const FieldState /*unused*/,
42 const amrex::Real /*unused*/,
43 const amrex::Real /*unused*/)
44 {}
45
46 void operator()(const FieldState fstate, const amrex::Real /*unused*/)
47 {
48 static_assert(
49 PDE::ndim == 1, "Invalid number of components for scalar");
50
51 const auto& repo = fields.repo;
52 const auto& geom = repo.mesh().Geom();
53
54 // cppcheck-suppress constVariableReference
55 auto& conv_term = fields.conv_term.state(fstate);
56 const auto& dof_field = fields.field.state(fstate);
57 const auto& den = density.state(fstate);
58
59 for (int lev = 0; lev < repo.num_active_levels(); ++lev) {
60 amrex::MFItInfo mfi_info;
61 // if (amrex::Gpu::notInLaunchRegion())
62 // mfi_info.EnableTiling(amrex::IntVect(1024,16,16)).SetDynamic(true);
63 if (amrex::Gpu::notInLaunchRegion()) {
64 mfi_info.EnableTiling(amrex::IntVect(1024, 1024, 1024))
65 .SetDynamic(true);
66 }
67#ifdef AMREX_USE_OMP
68#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
69#endif
70 for (amrex::MFIter mfi(density(lev), mfi_info); mfi.isValid();
71 ++mfi) {
72
73 amrex::Box const& bx = mfi.tilebox();
74 auto rho_arr = den(lev).const_array(mfi);
75 auto tra_arr = dof_field(lev).const_array(mfi);
76 amrex::FArrayBox rhotracfab;
77 amrex::Array4<amrex::Real> rhotrac;
78
79 if (PDE::multiply_rho) {
80
81 amrex::Box rhotrac_box =
82 amrex::grow(bx, fvm::MOL::nghost_state);
83 rhotracfab.resize(
84 rhotrac_box, PDE::ndim, amrex::The_Async_Arena());
85 rhotrac = rhotracfab.array();
86
87 amrex::ParallelFor(
88 rhotrac_box, PDE::ndim,
89 [=] AMREX_GPU_DEVICE(
90 int i, int j, int k, int n) noexcept {
91 rhotrac(i, j, k, n) =
92 rho_arr(i, j, k) * tra_arr(i, j, k, n);
93 });
94 }
95
96 {
97 const int nmaxcomp = PDE::ndim;
98
99 amrex::Box tmpbox = amrex::surroundingNodes(bx);
100 const int tmpcomp = nmaxcomp * AMREX_SPACEDIM;
101
102 amrex::FArrayBox tmpfab(
103 tmpbox, tmpcomp, amrex::The_Async_Arena());
104
105 amrex::Array4<amrex::Real> fx = tmpfab.array(0);
106 amrex::Array4<amrex::Real> fy = tmpfab.array(nmaxcomp);
107 amrex::Array4<amrex::Real> fz = tmpfab.array(nmaxcomp * 2);
108
110 lev, bx, PDE::ndim, fx, fy, fz,
111 (PDE::multiply_rho ? rhotrac : tra_arr),
112 u_mac(lev).const_array(mfi),
113 v_mac(lev).const_array(mfi),
114 w_mac(lev).const_array(mfi), dof_field.bcrec().data(),
115 dof_field.bcrec_device().data(), geom);
116
118 bx, PDE::ndim, conv_term(lev).array(mfi), fx, fy, fz,
119 geom[lev].InvCellSizeArray());
120 }
121 }
122 }
123 }
124
130};
131
132} // namespace amr_wind::pde
133
134#endif /* ADVOP_MOL_H */
Definition CFDSim.H:47
Definition Field.H:116
FieldState
Definition FieldDescTypes.H:14
Definition AdvOp_Godunov.H:16
void compute_convective_rate(amrex::Box const &bx, int ncomp, amrex::Array4< amrex::Real > const &dUdt, amrex::Array4< amrex::Real const > const &fx, amrex::Array4< amrex::Real const > const &fy, amrex::Array4< amrex::Real const > const &fz, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > dxi)
Definition incflo_mol_fluxes.cpp:6
void compute_convective_fluxes(int lev, amrex::Box const &bx, int ncomp, amrex::Array4< amrex::Real > const &fx, amrex::Array4< amrex::Real > const &fy, amrex::Array4< amrex::Real > const &fz, amrex::Array4< amrex::Real const > const &q, amrex::Array4< amrex::Real const > const &umac, amrex::Array4< amrex::Real const > const &vmac, amrex::Array4< amrex::Real const > const &wmac, amrex::BCRec const *h_bcrec, amrex::BCRec const *d_bcrec, amrex::Vector< amrex::Geometry > geom)
Definition incflo_mol_fluxes.cpp:26
static constexpr int nghost_state
Number of ghost cells in the state variable.
Definition SchemeTraits.H:41
AdvectionOp(CFDSim &, PDEFields &fields_in, bool, bool, bool, bool)
Definition AdvOp_MOL.H:26
void preadvect(const FieldState, const amrex::Real, const amrex::Real)
Definition AdvOp_MOL.H:40
Definition PDEOps.H:168
Definition PDEFields.H:27