/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
7#include "src/core/SimTime.H"
8
9namespace kynema_sgf::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(kynema_sgf::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(kynema_sgf::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, kynema_sgf::FieldLoc::XFACE);
79 auto flux_y =
80 repo.create_scratch_field(1, 0, kynema_sgf::FieldLoc::YFACE);
81 auto flux_z =
82 repo.create_scratch_field(1, 0, kynema_sgf::FieldLoc::ZFACE);
83
84 // Scratch field for fluxC
85 auto fluxC =
86 repo.create_scratch_field(1, 0, kynema_sgf::FieldLoc::CELL);
87
88 // Define the sweep time
89 isweep += 1;
90 if (isweep > 3) {
91 isweep = 1;
92 }
93
94 amrex::Vector<amrex::Array<amrex::MultiFab*, AMREX_SPACEDIM>> fluxes(
95 nlevels);
96 amrex::Vector<amrex::Array<amrex::MultiFab*, AMREX_SPACEDIM>> advas(
97 nlevels);
98 for (int lev = 0; lev < nlevels; ++lev) {
99 fluxes[lev][0] = &(*flux_x)(lev);
100 fluxes[lev][1] = &(*flux_y)(lev);
101 fluxes[lev][2] = &(*flux_z)(lev);
102 advas[lev][0] = &aa_x(lev);
103 advas[lev][1] = &aa_y(lev);
104 advas[lev][2] = &aa_z(lev);
105 }
106
107 // Split advection step 1, with cmask calculation
109 isweep, 0, nlevels, dof_field, fluxes, (*fluxC), advas, u_mac,
110 v_mac, w_mac, dof_field.bc_type(), geom, m_time.new_time(), dt,
112 // (copy old boundaries to working state)
113 // Split advection step 2
115 isweep, 1, nlevels, dof_field, fluxes, (*fluxC), advas, u_mac,
116 v_mac, w_mac, dof_field.bc_type(), geom, m_time.new_time(), dt,
118 // (copy old boundaries to working state)
119 // Split advection step 3
121 isweep, 2, nlevels, dof_field, fluxes, (*fluxC), advas, u_mac,
122 v_mac, w_mac, dof_field.bc_type(), geom, m_time.new_time(), dt,
124
125 // Replace masked cells using overset
126 if (repo.int_field_exists("iblank_cell") && m_replace_mask) {
127 auto& f_iblank = repo.get_int_field("iblank_cell");
129 nlevels, f_iblank, dof_field, dof_new);
130 }
131
132 // Copy working version of vof to new state
133 for (int lev = 0; lev < repo.num_active_levels(); ++lev) {
134 amrex::MultiFab::Copy(
135 dof_new(lev), dof_field(lev), 0, 0, dof_field.num_comp(),
136 dof_field.num_grow());
137 }
138 }
139
145 int isweep = 0;
146 bool m_rm_debris{true};
147 bool m_replace_mask{true};
148 // Lagrangian transport is deprecated, only Eulerian is supported
149};
150
151} // namespace kynema_sgf::pde
152#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
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:21
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:46
Field & v_mac
Definition vof_advection.H:143
int isweep
Definition vof_advection.H:145
bool m_replace_mask
Definition vof_advection.H:147
Field & w_mac
Definition vof_advection.H:144
AdvectionOp(CFDSim &sim, PDEFields &fields_in, bool, bool, bool, bool)
Definition vof_advection.H:17
Field & u_mac
Definition vof_advection.H:142
PDEFields & fields
Definition vof_advection.H:141
void preadvect(const FieldState, const amrex::Real, const amrex::Real)
Definition vof_advection.H:40
const SimTime & m_time
Definition vof_advection.H:140
bool m_rm_debris
Definition vof_advection.H:146
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