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

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/equation_systems/density/density_ops.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
density_ops.H
Go to the documentation of this file.
1#ifndef DENSITY_OPS_H
2#define DENSITY_OPS_H
3
5
6namespace amr_wind::pde {
7
8template <typename Scheme>
9struct ComputeRHSOp<Density, Scheme>
10{
11 explicit ComputeRHSOp(PDEFields& fields_in) : fields(fields_in) {}
12
14 const DiffusionType /*unused*/,
15 const amrex::Real dt,
16 bool /*mesh_mapping*/)
17 {
18 // Field states for diffusion and advection terms. In Godunov scheme
19 // these terms only have one state.
20 auto fstate = std::is_same<Scheme, fvm::Godunov>::value
23
24 const int nlevels = fields.repo.num_active_levels();
25 auto& field = fields.field;
26 const auto& field_old = field.state(FieldState::Old);
27 const auto& conv_term = fields.conv_term.state(fstate);
28
29 for (int lev = 0; lev < nlevels; ++lev) {
30#ifdef AMREX_USE_OMP
31#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
32#endif
33 for (amrex::MFIter mfi(field(lev)); mfi.isValid(); ++mfi) {
34 const auto& bx = mfi.tilebox();
35 auto rho = field(lev).array(mfi);
36 const auto rho_o = field_old(lev).const_array(mfi);
37 const auto ddt_o = conv_term(lev).const_array(mfi);
38
39 amrex::ParallelFor(
40 bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
41 rho(i, j, k) = rho_o(i, j, k) + dt * ddt_o(i, j, k);
42 // Defer n+1/2 update to the time-stepping algorithm
43 // rho_nph(i, j, k) = 0.5 * (rho(i, j, k) + rho_o(i, j,
44 // k));
45 });
46 }
47 }
48 }
49
51 const DiffusionType /*unused*/,
52 const amrex::Real dt,
53 bool /*mesh_mapping*/)
54 {
55 const int nlevels = fields.repo.num_active_levels();
56 auto& field = fields.field;
57 const auto& field_old = field.state(FieldState::Old);
58 const auto& conv_term = fields.conv_term;
59 const auto& conv_term_old = fields.conv_term.state(FieldState::Old);
60
61 for (int lev = 0; lev < nlevels; ++lev) {
62#ifdef AMREX_USE_OMP
63#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
64#endif
65 for (amrex::MFIter mfi(field(lev)); mfi.isValid(); ++mfi) {
66 const auto& bx = mfi.tilebox();
67 auto rho = field(lev).array(mfi);
68 const auto rho_o = field_old(lev).const_array(mfi);
69 const auto ddt = conv_term(lev).const_array(mfi);
70 const auto ddt_o = conv_term_old(lev).const_array(mfi);
71
72 amrex::ParallelFor(
73 bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
74 rho(i, j, k) =
75 rho_o(i, j, k) +
76 dt * 0.5 * (ddt_o(i, j, k) + ddt(i, j, k));
77 // Defer n+1/2 update to time-stepping algorithm
78 // rho_nph(i, j, k) =
79 // 0.5 * (rho(i, j, k) + rho_o(i, j, k));
80 });
81 }
82 }
83 }
84
85 // data members
87};
88} // namespace amr_wind::pde
89
90#endif /* DENSITY_OPS_H */
Field & state(const FieldState fstate)
Return field at a different time state.
Definition Field.cpp:114
int num_active_levels() const noexcept
Total number of levels currently active in the AMR mesh.
Definition FieldRepo.H:361
@ New
Same as FieldState::NP1.
@ Old
Same as FieldState::N.
DiffusionType
Definition incflo_enums.H:4
Definition AdvOp_Godunov.H:16
void predictor_rhs(const DiffusionType, const amrex::Real dt, bool)
Definition density_ops.H:13
PDEFields & fields
Definition density_ops.H:86
void corrector_rhs(const DiffusionType, const amrex::Real dt, bool)
Definition density_ops.H:50
ComputeRHSOp(PDEFields &fields_in)
Definition density_ops.H:11
Definition CompRHSOps.H:18
PDEFields & fields
Definition CompRHSOps.H:270
Definition density.H:13
Definition PDEFields.H:27
Field & conv_term
Convective term for this PDE.
Definition PDEFields.H:43
FieldRepo & repo
Reference to the field repository instance.
Definition PDEFields.H:31
Field & field
Solution variable (e.g., velocity, temperature)
Definition PDEFields.H:34