/home/runner/work/kynema-sgf/kynema-sgf/src/equation_systems/vof/vof_advection.H Source File

Kynema-SGF API: /home/runner/work/kynema-sgf/kynema-sgf/src/equation_systems/vof/vof_advection.H Source File
Kynema-SGF 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
5#include "src/core/SimTime.H"
9
10namespace kynema_sgf::pde {
11
15template <>
16struct AdvectionOp<VOF, fvm::Godunov>
17{
19 CFDSim& sim,
20 PDEFields& fields_in,
21 bool /*unused*/,
22 bool /*unused*/,
23 bool /*unused*/,
24 bool /*unused*/)
25 : m_time(sim.time())
26 , fields(fields_in)
27 , u_mac(fields_in.repo.get_field("u_mac"))
28 , v_mac(fields_in.repo.get_field("v_mac"))
29 , w_mac(fields_in.repo.get_field("w_mac"))
30 , m_flux_x(fields_in.repo.create_scratch_field(
31 1, 0, kynema_sgf::FieldLoc::XFACE))
32 , m_flux_y(fields_in.repo.create_scratch_field(
33 1, 0, kynema_sgf::FieldLoc::YFACE))
34 , m_flux_z(fields_in.repo.create_scratch_field(
35 1, 0, kynema_sgf::FieldLoc::ZFACE))
36 , m_fluxC(fields_in.repo.create_scratch_field(
37 1, 0, kynema_sgf::FieldLoc::CELL))
38 {
39 amrex::ParmParse pp_multiphase("VOF");
40 pp_multiphase.query("remove_debris", m_rm_debris);
41 pp_multiphase.query("replace_masked", m_replace_mask);
42
43 // Setup density factor arrays for multiplying velocity flux
45 {"advalpha_x", "advalpha_y", "advalpha_z"}, 1,
47 }
48
50 const FieldState /*unused*/,
51 const amrex::Real /*unused*/,
52 const amrex::Real /*unused*/)
53 {}
54
55 void operator()(const FieldState /*unused*/, const amrex::Real dt)
56 {
57 static_assert(
58 VOF::ndim == 1, "Invalid number of components for scalar");
59
60 auto& repo = fields.repo;
61 const auto& geom = repo.mesh().Geom();
62 const int nlevels = repo.num_active_levels();
63
64 auto& aa_x = repo.get_field("advalpha_x");
65 auto& aa_y = repo.get_field("advalpha_y");
66 auto& aa_z = repo.get_field("advalpha_z");
67
68 // Old and new states
69 auto& dof_old = fields.field.state(kynema_sgf::FieldState::Old);
70 auto& dof_new = fields.field;
71 // Working state of vof is nph, to keep others untouched during step
72 auto& dof_field = fields.field.state(kynema_sgf::FieldState::NPH);
73
74 // Initialize as old state values
75 for (int lev = 0; lev < repo.num_active_levels(); ++lev) {
76 amrex::MultiFab::Copy(
77 dof_field(lev), dof_old(lev), 0, 0, dof_field.num_comp(),
78 dof_field.num_grow());
79 }
80
81 //
82 // Advect volume using Implicit Eulerian Sweeping method with PLIC
83 // reconstruction
84 //
85
86 auto& flux_x = *m_flux_x;
87 auto& flux_y = *m_flux_y;
88 auto& flux_z = *m_flux_z;
89 auto& fluxC = *m_fluxC;
90
91 // Define the sweep time
92 isweep += 1;
93 if (isweep > 3) {
94 isweep = 1;
95 }
96
97 amrex::Vector<amrex::Array<amrex::MultiFab*, AMREX_SPACEDIM>> fluxes(
98 nlevels);
99 amrex::Vector<amrex::Array<amrex::MultiFab*, AMREX_SPACEDIM>> advas(
100 nlevels);
101 for (int lev = 0; lev < nlevels; ++lev) {
102 fluxes[lev][0] = &flux_x(lev);
103 fluxes[lev][1] = &flux_y(lev);
104 fluxes[lev][2] = &flux_z(lev);
105 advas[lev][0] = &aa_x(lev);
106 advas[lev][1] = &aa_y(lev);
107 advas[lev][2] = &aa_z(lev);
108 }
109
110 // Split advection step 1, with cmask calculation
112 isweep, 0, nlevels, dof_field, fluxes, fluxC, advas, u_mac, v_mac,
113 w_mac, dof_field.bc_type(), geom, m_time.new_time(), dt,
115 // (copy old boundaries to working state)
116 // Split advection step 2
118 isweep, 1, nlevels, dof_field, fluxes, fluxC, advas, u_mac, v_mac,
119 w_mac, dof_field.bc_type(), geom, m_time.new_time(), dt,
121 // (copy old boundaries to working state)
122 // Split advection step 3
124 isweep, 2, nlevels, dof_field, fluxes, fluxC, advas, u_mac, v_mac,
125 w_mac, dof_field.bc_type(), geom, m_time.new_time(), dt,
127
128 // Replace masked cells using overset
129 if (repo.int_field_exists("iblank_cell") && m_replace_mask) {
130 auto& f_iblank = repo.get_int_field("iblank_cell");
132 nlevels, f_iblank, dof_field, dof_new);
133 }
134
135 // Copy working version of vof to new state
136 for (int lev = 0; lev < repo.num_active_levels(); ++lev) {
137 amrex::MultiFab::Copy(
138 dof_new(lev), dof_field(lev), 0, 0, dof_field.num_comp(),
139 dof_field.num_grow());
140 }
141 }
142
148
149 std::unique_ptr<ScratchField> m_flux_x;
150 std::unique_ptr<ScratchField> m_flux_y;
151 std::unique_ptr<ScratchField> m_flux_z;
152 std::unique_ptr<ScratchField> m_fluxC;
153
154 int isweep = 0;
155 bool m_rm_debris{true};
156 bool m_replace_mask{true};
157 // Lagrangian transport is deprecated, only Eulerian is supported
158};
159
160} // namespace kynema_sgf::pde
161#endif
Definition CFDSim.H:55
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
FieldLoc
Definition FieldDescTypes.H:29
FieldState
Definition FieldDescTypes.H:16
@ 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
@ NPH
State at (n + 1/2) (intermediate) timestep.
Definition FieldDescTypes.H:20
@ Old
Same as FieldState::N.
Definition FieldDescTypes.H:23
Definition SchemeTraits.H:6
static void replace_masked_vof(const int nlevels, kynema_sgf::IntField &f_iblank, kynema_sgf::Field &f_vof, kynema_sgf::Field &f_vof_new)
Definition vof_hybridsolver_ops.H:10
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
Definition AdvOp_Godunov.H:22
This test case is intended as an evaluation of the momentum advection scheme.
Definition BCInterface.cpp:10
static constexpr int nghost_mac
Number of ghost cells in the MAC face variables.
Definition SchemeTraits.H:23
void operator()(const FieldState, const amrex::Real dt)
Definition vof_advection.H:55
Field & v_mac
Definition vof_advection.H:146
int isweep
Definition vof_advection.H:154
bool m_replace_mask
Definition vof_advection.H:156
Field & w_mac
Definition vof_advection.H:147
std::unique_ptr< ScratchField > m_flux_x
Definition vof_advection.H:149
AdvectionOp(CFDSim &sim, PDEFields &fields_in, bool, bool, bool, bool)
Definition vof_advection.H:18
Field & u_mac
Definition vof_advection.H:145
std::unique_ptr< ScratchField > m_fluxC
Definition vof_advection.H:152
std::unique_ptr< ScratchField > m_flux_y
Definition vof_advection.H:150
PDEFields & fields
Definition vof_advection.H:144
void preadvect(const FieldState, const amrex::Real, const amrex::Real)
Definition vof_advection.H:49
const SimTime & m_time
Definition vof_advection.H:143
std::unique_ptr< ScratchField > m_flux_z
Definition vof_advection.H:151
bool m_rm_debris
Definition vof_advection.H:155
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