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

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/equation_systems/vof/vof_advection.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
vof_advection.H
Go to the documentation of this file.
1
2#ifndef VOF_ADVECTION_H
3#define VOF_ADVECTION_H
4
8
9namespace amr_wind::pde {
10
14template <>
15struct AdvectionOp<VOF, fvm::Godunov>
16{
18 CFDSim& /* sim */,
19 PDEFields& fields_in,
20 bool /*unused*/,
21 bool /*unused*/,
22 bool /*unused*/,
23 bool /*unused*/)
24 : fields(fields_in)
25 , u_mac(fields_in.repo.get_field("u_mac"))
26 , v_mac(fields_in.repo.get_field("v_mac"))
27 , w_mac(fields_in.repo.get_field("w_mac"))
28 {
29 amrex::ParmParse pp_multiphase("VOF");
30 pp_multiphase.query("remove_debris", m_rm_debris);
31 pp_multiphase.query("replace_masked", m_replace_mask);
32
33 // Setup density factor arrays for multiplying velocity flux
35 {"advalpha_x", "advalpha_y", "advalpha_z"}, 1,
37 }
38
40 const FieldState /*unused*/,
41 const amrex::Real /*unused*/,
42 const amrex::Real /*unused*/)
43 {}
44
45 void operator()(const FieldState /*unused*/, const amrex::Real dt)
46 {
47 static_assert(
48 VOF::ndim == 1, "Invalid number of components for scalar");
49
50 auto& repo = fields.repo;
51 const auto& geom = repo.mesh().Geom();
52 const int nlevels = repo.num_active_levels();
53
54 auto& aa_x = repo.get_field("advalpha_x");
55 auto& aa_y = repo.get_field("advalpha_y");
56 auto& aa_z = repo.get_field("advalpha_z");
57
58 // Old and new states
59 auto& dof_old = fields.field.state(amr_wind::FieldState::Old);
60 auto& dof_new = fields.field;
61 // Working state of vof is nph, to keep others untouched during step
62 auto& dof_field = fields.field.state(amr_wind::FieldState::NPH);
63
64 // Initialize as old state values
65 for (int lev = 0; lev < repo.num_active_levels(); ++lev) {
66 amrex::MultiFab::Copy(
67 dof_field(lev), dof_old(lev), 0, 0, dof_field.num_comp(),
68 dof_field.num_grow());
69 }
70
71 //
72 // Advect volume using Implicit Eulerian Sweeping method with PLIC
73 // reconstruction
74 //
75
76 auto flux_x =
77 repo.create_scratch_field(1, 0, amr_wind::FieldLoc::XFACE);
78 auto flux_y =
79 repo.create_scratch_field(1, 0, amr_wind::FieldLoc::YFACE);
80 auto flux_z =
81 repo.create_scratch_field(1, 0, amr_wind::FieldLoc::ZFACE);
82
83 // Scratch field for fluxC
84 auto fluxC = repo.create_scratch_field(1, 0, amr_wind::FieldLoc::CELL);
85
86 // Define the sweep time
87 isweep += 1;
88 if (isweep > 3) {
89 isweep = 1;
90 }
91
92 amrex::Vector<amrex::Array<amrex::MultiFab*, AMREX_SPACEDIM>> fluxes(
93 nlevels);
94 amrex::Vector<amrex::Array<amrex::MultiFab*, AMREX_SPACEDIM>> advas(
95 nlevels);
96 for (int lev = 0; lev < nlevels; ++lev) {
97 fluxes[lev][0] = &(*flux_x)(lev);
98 fluxes[lev][1] = &(*flux_y)(lev);
99 fluxes[lev][2] = &(*flux_z)(lev);
100 advas[lev][0] = &aa_x(lev);
101 advas[lev][1] = &aa_y(lev);
102 advas[lev][2] = &aa_z(lev);
103 }
104
105 // Split advection step 1, with cmask calculation
107 isweep, 0, nlevels, dof_field, fluxes, (*fluxC), advas, u_mac,
108 v_mac, w_mac, dof_field.bc_type(), geom, dt, m_rm_debris);
109 // Split advection step 2
111 isweep, 1, nlevels, dof_field, fluxes, (*fluxC), advas, u_mac,
112 v_mac, w_mac, dof_field.bc_type(), geom, dt, m_rm_debris);
113 // Split advection step 3
115 isweep, 2, nlevels, dof_field, fluxes, (*fluxC), advas, u_mac,
116 v_mac, w_mac, dof_field.bc_type(), geom, dt, m_rm_debris);
117
118 // Replace masked cells using overset
119 if (repo.int_field_exists("iblank_cell") && m_replace_mask) {
120 auto& f_iblank = repo.get_int_field("iblank_cell");
122 nlevels, f_iblank, dof_field, dof_new);
123 }
124
125 // Copy working version of vof to new state
126 for (int lev = 0; lev < repo.num_active_levels(); ++lev) {
127 amrex::MultiFab::Copy(
128 dof_new(lev), dof_field(lev), 0, 0, dof_field.num_comp(),
129 dof_field.num_grow());
130 }
131 }
132
137 int isweep = 0;
138 bool m_rm_debris{true};
139 bool m_replace_mask{true};
140 // Lagrangian transport is deprecated, only Eulerian is supported
141};
142
143} // namespace amr_wind::pde
144#endif
Definition CFDSim.H:51
Definition Field.H:116
amrex::Vector< Field * > declare_face_normal_field(const amrex::Vector< std::string > &names, const int ncomp=1, const int ngrow=0, const int nstates=1)
Definition FieldRepo.H:225
FieldState
Definition FieldDescTypes.H:14
@ ZFACE
Face-centered in z-direction.
@ XFACE
Face-centered in x-direction (e.g., face normal velocity)
@ CELL
Cell-centered (default)
@ YFACE
Face-centered in y-direction.
@ NPH
State at (n + 1/2) (intermediate) timestep.
@ Old
Same as FieldState::N.
void split_advection_step(int isweep, int iorder, int nlevels, Field &dof_field, amrex::Vector< amrex::Array< amrex::MultiFab *, AMREX_SPACEDIM > > const &fluxes, ScratchField &fluxC, amrex::Vector< amrex::Array< amrex::MultiFab *, AMREX_SPACEDIM > > const &advas, Field const &u_mac, Field const &v_mac, Field const &w_mac, amrex::GpuArray< BC, AMREX_SPACEDIM *2 > BCs, amrex::Vector< amrex::Geometry > geom, amrex::Real dt, bool rm_debris)
Definition SplitAdvection.cpp:11
static void replace_masked_vof(const int nlevels, amr_wind::IntField &f_iblank, amr_wind::Field &f_vof, amr_wind::Field &f_vof_new)
Definition vof_hybridsolver_ops.H:10
Definition AdvOp_Godunov.H:16
static constexpr int nghost_mac
Number of ghost cells in the MAC face variables.
Definition SchemeTraits.H:23
Field & u_mac
Definition vof_advection.H:134
AdvectionOp(CFDSim &, PDEFields &fields_in, bool, bool, bool, bool)
Definition vof_advection.H:17
PDEFields & fields
Definition vof_advection.H:133
Field & w_mac
Definition vof_advection.H:136
Field & v_mac
Definition vof_advection.H:135
void preadvect(const FieldState, const amrex::Real, const amrex::Real)
Definition vof_advection.H:39
void operator()(const FieldState, const amrex::Real dt)
Definition vof_advection.H:45
Definition PDEOps.H:168
Definition PDEFields.H:27
FieldRepo & repo
Reference to the field repository instance.
Definition PDEFields.H:31
Definition vof.H:17
static constexpr int ndim
Definition vof.H:24