/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#ifndef VOF_ADVECTION_H
2#define VOF_ADVECTION_H
3
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 : m_time(sim.time())
25 , fields(fields_in)
26 , u_mac(fields_in.repo.get_field("u_mac"))
27 , v_mac(fields_in.repo.get_field("v_mac"))
28 , w_mac(fields_in.repo.get_field("w_mac"))
29 {
30 amrex::ParmParse pp_multiphase("VOF");
31 pp_multiphase.query("remove_debris", m_rm_debris);
32 pp_multiphase.query("replace_masked", m_replace_mask);
33
34 // Setup density factor arrays for multiplying velocity flux
36 {"advalpha_x", "advalpha_y", "advalpha_z"}, 1,
38 }
39
41 const FieldState /*unused*/,
42 const amrex::Real /*unused*/,
43 const amrex::Real /*unused*/)
44 {}
45
46 void operator()(const FieldState /*unused*/, const amrex::Real dt)
47 {
48 static_assert(
49 VOF::ndim == 1, "Invalid number of components for scalar");
50
51 auto& repo = fields.repo;
52 const auto& geom = repo.mesh().Geom();
53 const int nlevels = repo.num_active_levels();
54
55 auto& aa_x = repo.get_field("advalpha_x");
56 auto& aa_y = repo.get_field("advalpha_y");
57 auto& aa_z = repo.get_field("advalpha_z");
58
59 // Old and new states
60 auto& dof_old = fields.field.state(amr_wind::FieldState::Old);
61 auto& dof_new = fields.field;
62 // Working state of vof is nph, to keep others untouched during step
63 auto& dof_field = fields.field.state(amr_wind::FieldState::NPH);
64
65 // Initialize as old state values
66 for (int lev = 0; lev < repo.num_active_levels(); ++lev) {
67 amrex::MultiFab::Copy(
68 dof_field(lev), dof_old(lev), 0, 0, dof_field.num_comp(),
69 dof_field.num_grow());
70 }
71
72 //
73 // Advect volume using Implicit Eulerian Sweeping method with PLIC
74 // reconstruction
75 //
76
77 auto flux_x =
78 repo.create_scratch_field(1, 0, amr_wind::FieldLoc::XFACE);
79 auto flux_y =
80 repo.create_scratch_field(1, 0, amr_wind::FieldLoc::YFACE);
81 auto flux_z =
82 repo.create_scratch_field(1, 0, amr_wind::FieldLoc::ZFACE);
83
84 // Scratch field for fluxC
85 auto fluxC = repo.create_scratch_field(1, 0, amr_wind::FieldLoc::CELL);
86
87 // Define the sweep time
88 isweep += 1;
89 if (isweep > 3) {
90 isweep = 1;
91 }
92
93 amrex::Vector<amrex::Array<amrex::MultiFab*, AMREX_SPACEDIM>> fluxes(
94 nlevels);
95 amrex::Vector<amrex::Array<amrex::MultiFab*, AMREX_SPACEDIM>> advas(
96 nlevels);
97 for (int lev = 0; lev < nlevels; ++lev) {
98 fluxes[lev][0] = &(*flux_x)(lev);
99 fluxes[lev][1] = &(*flux_y)(lev);
100 fluxes[lev][2] = &(*flux_z)(lev);
101 advas[lev][0] = &aa_x(lev);
102 advas[lev][1] = &aa_y(lev);
103 advas[lev][2] = &aa_z(lev);
104 }
105
106 // Split advection step 1, with cmask calculation
108 isweep, 0, nlevels, dof_field, fluxes, (*fluxC), advas, u_mac,
109 v_mac, w_mac, dof_field.bc_type(), geom, m_time.new_time(), dt,
111 // (copy old boundaries to working state)
112 // Split advection step 2
114 isweep, 1, nlevels, dof_field, fluxes, (*fluxC), advas, u_mac,
115 v_mac, w_mac, dof_field.bc_type(), geom, m_time.new_time(), dt,
117 // (copy old boundaries to working state)
118 // Split advection step 3
120 isweep, 2, nlevels, dof_field, fluxes, (*fluxC), advas, u_mac,
121 v_mac, w_mac, dof_field.bc_type(), geom, m_time.new_time(), dt,
123
124 // Replace masked cells using overset
125 if (repo.int_field_exists("iblank_cell") && m_replace_mask) {
126 auto& f_iblank = repo.get_int_field("iblank_cell");
128 nlevels, f_iblank, dof_field, dof_new);
129 }
130
131 // Copy working version of vof to new state
132 for (int lev = 0; lev < repo.num_active_levels(); ++lev) {
133 amrex::MultiFab::Copy(
134 dof_new(lev), dof_field(lev), 0, 0, dof_field.num_comp(),
135 dof_field.num_grow());
136 }
137 }
138
144 int isweep = 0;
145 bool m_rm_debris{true};
146 bool m_replace_mask{true};
147 // Lagrangian transport is deprecated, only Eulerian is supported
148};
149
150} // namespace amr_wind::pde
151#endif
Definition CFDSim.H:54
Definition Field.H:112
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
Definition SimTime.H:33
FieldState
Definition FieldDescTypes.H:16
@ NPH
State at (n + 1/2) (intermediate) timestep.
Definition FieldDescTypes.H:20
@ Old
Same as FieldState::N.
Definition FieldDescTypes.H:23
@ ZFACE
Face-centered in z-direction.
Definition FieldDescTypes.H:34
@ XFACE
Face-centered in x-direction (e.g., face normal velocity)
Definition FieldDescTypes.H:32
@ CELL
Cell-centered (default)
Definition FieldDescTypes.H:30
@ YFACE
Face-centered in y-direction.
Definition FieldDescTypes.H:33
Definition SchemeTraits.H:6
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 time, 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:21
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:141
AdvectionOp(CFDSim &sim, PDEFields &fields_in, bool, bool, bool, bool)
Definition vof_advection.H:17
bool m_rm_debris
Definition vof_advection.H:145
PDEFields & fields
Definition vof_advection.H:140
Field & w_mac
Definition vof_advection.H:143
bool m_replace_mask
Definition vof_advection.H:146
Field & v_mac
Definition vof_advection.H:142
int isweep
Definition vof_advection.H:144
void preadvect(const FieldState, const amrex::Real, const amrex::Real)
Definition vof_advection.H:40
const SimTime & m_time
Definition vof_advection.H:139
void operator()(const FieldState, const amrex::Real dt)
Definition vof_advection.H:46
Definition PDEFields.H:27
FieldRepo & repo
Reference to the field repository instance.
Definition PDEFields.H:31
Definition vof.H:20
static constexpr int ndim
Definition vof.H:27