Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vof #111

Open
wants to merge 56 commits into
base: development
Choose a base branch
from
Open

Vof #111

Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
1d8aa88
init commit of vof
Jun 20, 2024
35b3fc2
add missing files
Jun 20, 2024
547d70d
use eb to build tracer (#1)
WeiqunZhang Jun 20, 2024
3e693fb
Tecplot: use nfiles (#2)
WeiqunZhang Jun 20, 2024
087aba0
update VolumeOfFluid.H and .cpp
Jun 21, 2024
3a4f232
Merge branch 'development' into vof
asalmgren Jun 21, 2024
1356ac7
Merge branch 'development' into vof
asalmgren Jun 22, 2024
6ee1d1c
VOF module with required format
Jun 22, 2024
39448dd
Merge branch 'vof' of github.com:IFDL-WSU/incflo into vof
Jun 22, 2024
62578c3
vof advection is done w/o BCs
Jul 10, 2024
6b98a14
Merge branch 'development' into vof
Jul 10, 2024
915eb86
implementation of the height function
Jul 26, 2024
b5cd784
curvature calculation is done
Aug 7, 2024
b1f0da5
Merge branch 'AMReX-Fluids:development' into vof
IFDL-WSU Aug 7, 2024
fdc0d62
light modification
Aug 17, 2024
aa39f08
Merge branch 'vof' of github.com:IFDL-WSU/incflo-vof into vof
Aug 17, 2024
f8911d1
light modification
Aug 17, 2024
eabae52
Merge branch 'AMReX-Fluids:development' into vof
IFDL-WSU Aug 17, 2024
4f81fb1
Merge branch 'AMReX-Fluids:development' into vof
IFDL-WSU Aug 19, 2024
303c098
implement surface-tension force
Aug 26, 2024
c8328ef
Merge remote-tracking branch 'hua/vof' into vof
Aug 26, 2024
6c9cba0
update implementation of surface tension force
Sep 6, 2024
16811b2
Merge branch 'AMReX-Fluids:development' into vof
IFDL-WSU Sep 6, 2024
2eb52b8
Merge branch 'AMReX-Fluids:development' into vof
IFDL-WSU Sep 14, 2024
1fc9cde
test
Sep 14, 2024
b403956
Merge branch 'vof' of github.com:IFDL-WSU/incflo-vof into vof
Sep 14, 2024
1789530
implement 2D
Sep 19, 2024
b9df26d
implement 2D
Sep 19, 2024
3274baa
Merge branch 'AMReX-Fluids:development' into vof
IFDL-WSU Sep 19, 2024
5c37b09
update 2D implementation
Sep 20, 2024
3c1db7c
update 2D implementation
Sep 20, 2024
0a57edd
update 2D implementation
Sep 24, 2024
1cbede4
Merge branch 'AMReX-Fluids:development' into vof
IFDL-WSU Sep 25, 2024
c8e1cd3
use cc project and face-centered SF
Oct 1, 2024
3971e64
Merge branch 'AMReX-Fluids:development' into vof
IFDL-WSU Oct 2, 2024
d257a29
did cleaning for tests
Oct 2, 2024
7109fd1
correct lid_drven_cavity input
Oct 2, 2024
cee1737
clean bugs for ccproj based VOF
Oct 4, 2024
1868861
clean bugs for ccproj based VOF
Oct 4, 2024
61e1c73
update for conservative advection scheme
Oct 7, 2024
4fefd68
implement filtering of VOF for high density ratio flows
Oct 12, 2024
b166381
cleaned bugs and complete capillary wave test
Oct 26, 2024
947ffd6
ready for drop flight test
Nov 6, 2024
36353b1
complete merge with incflo development
Nov 7, 2024
4360a93
Merge branch 'AMReX-Fluids-development' into vof
Nov 7, 2024
41cde17
fix the bug of io.cpp caused by VOF implementation
Nov 7, 2024
62d1545
Merge branch 'AMReX-Fluids:development' into vof
IFDL-WSU Dec 4, 2024
3415bfe
update tecplot output
Dec 4, 2024
75a4c63
Implement the initialization of VOF using a parameter incflo.vof_init…
Dec 8, 2024
113cb42
Merge branch 'AMReX-Fluids:development' into vof
IFDL-WSU Dec 8, 2024
8ca85d5
forget to update some files in previous commit
Dec 8, 2024
5bb98cd
update vof.cpp
Dec 8, 2024
f0ea51e
VOF and surface-tension are implemented in AMR
Jan 12, 2025
e524f7f
implement FillPatchNLevels in incflo_fillpatch
Feb 5, 2025
ac925b2
implement VOFCoarseToFine interpolation
Feb 27, 2025
17ee4b4
fix the bugs of CC projection
Mar 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use cc project and face-centered SF
Hua Tan committed Oct 1, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit c8e1cd3b32a8d6173109f3fe0c97e04ffebbd5f8
5 changes: 3 additions & 2 deletions src/convection/incflo_compute_MAC_projected_velocities.cpp
Original file line number Diff line number Diff line change
@@ -178,8 +178,9 @@ incflo::compute_MAC_projected_velocities (
allow_inflow_on_outflow, BC_MF.get());

//add surface tension
//if(m_vof_advect_tracer)
// get_volume_of_fluid ()->velocity_face_source(lev,l_dt, AMREX_D_DECL(*u_mac[lev], *v_mac[lev], *w_mac[lev]));
if(m_vof_advect_tracer && m_use_cc_proj)
get_volume_of_fluid ()->velocity_face_source(lev,0.5*l_dt, AMREX_D_DECL(*u_mac[lev], *v_mac[lev], *w_mac[lev]),
AMREX_D_DECL(nullptr, nullptr, nullptr));


if(0){
11 changes: 7 additions & 4 deletions src/incflo.H
Original file line number Diff line number Diff line change
@@ -103,14 +103,16 @@ public:
amrex::Vector<amrex::MultiFab const*> const& density,
amrex::Vector<amrex::MultiFab const*> const& tracer_old,
amrex::Vector<amrex::MultiFab const*> const& tracer_new,
bool include_pressure_gradient = true);
bool include_pressure_gradient = true,
bool include_SF = false);
void compute_vel_forces_on_level ( int lev,
amrex::MultiFab& vel_forces,
const amrex::MultiFab& velocity,
const amrex::MultiFab& density,
const amrex::MultiFab& tracer_old,
const amrex::MultiFab& tracer_new,
bool include_pressure_gradient = true);
bool include_pressure_gradient = true,
bool include_SF = false);


///////////////////////////////////////////////////////////////////////////
@@ -225,8 +227,8 @@ public:
AMREX_D_DECL(amrex::Vector<amrex::MultiFab const*> const& u_mac,
amrex::Vector<amrex::MultiFab const*> const& v_mac,
amrex::Vector<amrex::MultiFab const*> const& w_mac));
void update_vof_density (amrex::Vector<amrex::MultiFab*> const& density,
amrex::Vector<amrex::MultiFab*> const& tracer);
void update_vof_density (int lev, amrex::Vector<amrex::MultiFab*> const& density,
amrex::Vector<amrex::MultiFab*> const& tracer);


[[nodiscard]] amrex::Array<amrex::MultiFab,AMREX_SPACEDIM>
@@ -662,6 +664,7 @@ private:

// cell-centered pressure gradient
amrex::MultiFab gp;
amrex::MultiFab gp_mac;

amrex::MultiFab conv_velocity;
amrex::MultiFab conv_velocity_o;
3 changes: 2 additions & 1 deletion src/incflo.cpp
Original file line number Diff line number Diff line change
@@ -82,7 +82,8 @@ void incflo::InitData ()
}

InitialIterations();

//get_volume_of_fluid()->WriteTecPlotFile (m_cur_time,m_nstep);
//amrex::Abort("finish initial projection");
// Set m_nstep to 0 before entering time loop
m_nstep = 0;

3 changes: 2 additions & 1 deletion src/incflo_apply_predictor.cpp
Original file line number Diff line number Diff line change
@@ -128,7 +128,8 @@ void incflo::ApplyPredictor (bool incremental_projection)
//when VOF method is used to advect the tracer, density and viscosity of each cell will
// depend the VOF field value of the cell.
if (m_vof_advect_tracer)
update_vof_density (get_density_old(),get_tracer_old());
for (int lev = 0; lev <= finest_level; ++lev)
update_vof_density (lev, get_density_old(),get_tracer_old());

// *************************************************************************************
// Compute explicit viscous term
14 changes: 8 additions & 6 deletions src/incflo_compute_forces.cpp
Original file line number Diff line number Diff line change
@@ -40,11 +40,12 @@ void incflo::compute_vel_forces (Vector<MultiFab*> const& vel_forces,
Vector<MultiFab const*> const& density,
Vector<MultiFab const*> const& tracer_old,
Vector<MultiFab const*> const& tracer_new,
bool include_pressure_gradient)
bool include_pressure_gradient,
bool include_SF)
{
for (int lev = 0; lev <= finest_level; ++lev)
compute_vel_forces_on_level (lev, *vel_forces[lev], *velocity[lev], *density[lev],
*tracer_old[lev], *tracer_new[lev], include_pressure_gradient);
*tracer_old[lev], *tracer_new[lev], include_pressure_gradient, include_SF);
}

void incflo::compute_vel_forces_on_level (int lev,
@@ -53,7 +54,8 @@ void incflo::compute_vel_forces_on_level (int lev,
const MultiFab& density,
const MultiFab& tracer_old,
const MultiFab& tracer_new,
bool include_pressure_gradient)
bool include_pressure_gradient,
bool include_SF)
{
GpuArray<Real,3> l_gravity{m_gravity[0],m_gravity[1],m_gravity[2]};
GpuArray<Real,3> l_gp0{m_gp0[0], m_gp0[1], m_gp0[2]};
@@ -157,7 +159,7 @@ void incflo::compute_vel_forces_on_level (int lev,
// rho: density

//fixme: we just consider the surface tension for first tracer
if (m_vof_advect_tracer && m_sigma[0]!=0.){
if (m_vof_advect_tracer && m_sigma[0]!=0.&&!m_use_cc_proj&&include_SF){

VolumeOfFluid* vof_p = get_volume_of_fluid ();

@@ -528,8 +530,8 @@ static int oct[3][2] = { { 1, 2 }, { 0, 2 }, { 0, 1 } };

}
}
else if(choice==4) {
//cell-centered surface tension force
else if (choice ==4) {
//cell-centered surface tension force
#ifdef _OPENMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
#endif
7 changes: 7 additions & 0 deletions src/prob/prob_init_fluid.cpp
Original file line number Diff line number Diff line change
@@ -207,6 +207,13 @@ void incflo::prob_init_fluid (int lev)
if (1109 == m_probtype) {
get_volume_of_fluid ()->tracer_vof_init_fraction(lev, ld.tracer);
MultiFab::Copy(ld.tracer_o, ld.tracer, 0, 0, 1, ld.tracer.nGrow());
ld.tracer_o.FillBoundary(geom[lev].periodicity());
if (m_vof_advect_tracer){
update_vof_density (lev, get_density_new(),get_tracer_new());
MultiFab::Copy(ld.density_o, ld.density, 0, 0, 1, ld.density.nGrow());
fillpatch_density(lev, m_t_new[lev], ld.density_o, 3);
}

}
}

66 changes: 55 additions & 11 deletions src/projection/incflo_apply_cc_projection.cpp
Original file line number Diff line number Diff line change
@@ -297,7 +297,7 @@ void incflo::ApplyCCProjection (Vector<MultiFab const*> density,
LPInfo lp_info;
lp_info.setMaxCoarseningLevel(m_mac_mg_max_coarsening_level);
#ifndef AMREX_USE_EB
if (m_constant_density) {
if (m_constant_density&&!m_vof_advect_tracer) {
Vector<BoxArray> ba;
Vector<DistributionMapping> dm;
for (auto const& ir : inv_rho) {
@@ -340,13 +340,14 @@ void incflo::ApplyCCProjection (Vector<MultiFab const*> density,
mac_vec[lev][2] = w_mac[lev];);
}

Vector<MultiFab> sfu_mac(finest_level+1), sfv_mac(finest_level+1), sfw_mac(finest_level+1);
// Compute velocity on faces
for (int lev = 0; lev <= finest_level; ++lev)
{
// Predict normal velocity to faces -- note that the {u_mac, v_mac, w_mac}
// returned from this call are on face CENTROIDS
vel[lev]->FillBoundary(geom[lev].periodicity());
#if 1
#if 0
MOL::ExtrapVelToFaces(*vel[lev],
AMREX_D_DECL(*u_mac[lev], *v_mac[lev], *w_mac[lev]),
geom[lev],
@@ -355,10 +356,27 @@ void incflo::ApplyCCProjection (Vector<MultiFab const*> density,
#else
average_ccvel_to_mac( mac_vec[lev], *vel[lev]);
#endif


//add surface tension
AMREX_D_TERM(sfu_mac[lev].define(u_mac[lev]->boxArray(), dmap[lev], 1, u_mac[lev]->nGrow(), MFInfo(), Factory(lev));,
sfv_mac[lev].define(v_mac[lev]->boxArray(), dmap[lev], 1, v_mac[lev]->nGrow(), MFInfo(), Factory(lev));,
sfw_mac[lev].define(w_mac[lev]->boxArray(), dmap[lev], 1, w_mac[lev]->nGrow(), MFInfo(), Factory(lev)););

AMREX_D_TERM(sfu_mac[lev].setVal(0.0);,
sfv_mac[lev].setVal(0.0);,
sfw_mac[lev].setVal(0.0););


if(m_vof_advect_tracer)
get_volume_of_fluid ()->velocity_face_source(lev, scaling_factor, AMREX_D_DECL(*u_mac[lev], *v_mac[lev], *w_mac[lev]),
AMREX_D_DECL(&sfu_mac[lev], &sfv_mac[lev], &sfw_mac[lev]));

}

macproj->setUMAC(mac_vec);


if (m_verbose > 2) amrex::Print() << "CC Projection:\n";
//
// Perform MAC projection: - del dot (dt/rho) grad phi = div(U)
@@ -391,12 +409,22 @@ void incflo::ApplyCCProjection (Vector<MultiFab const*> density,

for (int lev=0; lev <= finest_level; ++lev)
{
#ifdef AMREX_USE_EB
amrex::Abort("Haven't written mac_to_ccvel for EB");
#else
//#ifdef AMREX_USE_EB
// amrex::Abort("Haven't written mac_to_ccvel for EB");
//#else
average_mac_to_ccvel(GetArrOfPtrs(m_fluxes[lev]),*cc_gphi[lev]);
#endif
//#endif
}
// computer the cell-centered surface tension term (see note in VolumeOfFluid:: velocity_face_source)
VolumeOfFluid* vof_p = get_volume_of_fluid ();
if(m_vof_advect_tracer)
for (int lev=0; lev <= finest_level; ++lev)
{
AMREX_D_TERM(Copy(m_fluxes[lev][0],sfu_mac[lev], 0, 0, 1, 0);,
Copy(m_fluxes[lev][1],sfv_mac[lev], 0, 0, 1, 0);,
Copy(m_fluxes[lev][2],sfw_mac[lev], 0, 0, 1, 0););
average_mac_to_ccvel(GetArrOfPtrs(m_fluxes[lev]),vof_p->force[lev]);
}

for(int lev = 0; lev <= finest_level; lev++)
{
@@ -413,55 +441,71 @@ void incflo::ApplyCCProjection (Vector<MultiFab const*> density,

Array4<Real> const& u = ld.velocity.array(mfi);
Array4<Real const> const& rho = density[lev]->const_array(mfi);
Array4<Real const> const& gsf = vof_p->force[lev].const_array(mfi);

Real r0 = m_ro_0;

amrex::ParallelFor(tbx, [u,gphi,p_cc,phi,incremental] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
amrex::ParallelFor(tbx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
AMREX_D_TERM(u(i,j,k,0) += gphi(i,j,k,0);,
u(i,j,k,1) += gphi(i,j,k,1);,
u(i,j,k,2) += gphi(i,j,k,2););
//we need to add the surface-tension effect to the cell-centered velocity
if(m_vof_advect_tracer){
AMREX_D_TERM(u(i,j,k,0) -= gsf(i,j,k,0)*scaling_factor;,
u(i,j,k,1) -= gsf(i,j,k,1)*scaling_factor;,
u(i,j,k,2) -= gsf(i,j,k,2)*scaling_factor;);
}
if (incremental)
p_cc (i,j,k) += phi(i,j,k);
else
p_cc (i,j,k) = phi(i,j,k);
});

if (incremental && m_constant_density) {
if (incremental && m_constant_density&&!m_vof_advect_tracer) {
amrex::ParallelFor(tbx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
AMREX_D_TERM(gp_cc(i,j,k,0) -= gphi(i,j,k,0) * r0 / scaling_factor;,
gp_cc(i,j,k,1) -= gphi(i,j,k,1) * r0 / scaling_factor;,
gp_cc(i,j,k,2) -= gphi(i,j,k,2) * r0 / scaling_factor;);

});
} else if (incremental && !m_constant_density) {
} else if (incremental && (!m_constant_density||m_vof_advect_tracer)) {
amrex::ParallelFor(tbx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
AMREX_D_TERM(gp_cc(i,j,k,0) -= gphi(i,j,k,0) * rho(i,j,k) / scaling_factor;,
gp_cc(i,j,k,1) -= gphi(i,j,k,1) * rho(i,j,k) / scaling_factor;,
gp_cc(i,j,k,2) -= gphi(i,j,k,2) * rho(i,j,k) / scaling_factor;);
});
} else if (!incremental && m_constant_density) {
} else if (!incremental && m_constant_density&&!m_vof_advect_tracer) {
amrex::ParallelFor(tbx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
AMREX_D_TERM(gp_cc(i,j,k,0) = -gphi(i,j,k,0) * r0 / scaling_factor;,
gp_cc(i,j,k,1) = -gphi(i,j,k,1) * r0 / scaling_factor;,
gp_cc(i,j,k,2) = -gphi(i,j,k,2) * r0 / scaling_factor;);
});
} else if (!incremental && !m_constant_density) {
} else if (!incremental && (!m_constant_density||m_vof_advect_tracer)) {
amrex::ParallelFor(tbx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
AMREX_D_TERM(gp_cc(i,j,k,0) = -gphi(i,j,k,0) * rho(i,j,k) / scaling_factor;,
gp_cc(i,j,k,1) = -gphi(i,j,k,1) * rho(i,j,k) / scaling_factor;,
gp_cc(i,j,k,2) = -gphi(i,j,k,2) * rho(i,j,k) / scaling_factor;);
if(m_vof_advect_tracer){
AMREX_D_TERM(gp_cc(i,j,k,0) += gsf(i,j,k,0) * rho(i,j,k);,
gp_cc(i,j,k,1) += gsf(i,j,k,1) * rho(i,j,k);,
gp_cc(i,j,k,2) += gsf(i,j,k,2) * rho(i,j,k););
}

});
}
}
ld.gp.FillBoundary(geom[lev].periodicity());
ld.p_cc.FillBoundary(geom[lev].periodicity());
}

//get_volume_of_fluid()->WriteTecPlotFile (m_cur_time,m_nstep);
//amrex::Abort("finish initial projection");

// ***************************************************************************************
// END OF MAC STUFF
// ***************************************************************************************
5 changes: 4 additions & 1 deletion src/vof/VolumeOfFluid.H
Original file line number Diff line number Diff line change
@@ -20,9 +20,12 @@ public:
void write_tecplot_surface(amrex::Real time, int nstep);
void WriteTecPlotFile (amrex::Real time, int nstep);
void output_droplet (amrex::Real time, int nstep);
int domain_tag_droplets (int finest_level, amrex::Vector<amrex::BoxArray > const &grids, amrex::Vector<amrex::Geometry > const& geom,
amrex::Vector<amrex::MultiFab*> const& vof,amrex::Vector<amrex::MultiFab*> const& tag);
void apply_velocity_field(amrex::Real time, int nstep);
void velocity_face_source(int lev,amrex::Real dt, AMREX_D_DECL(amrex::MultiFab& u_mac, amrex::MultiFab& v_mac,
amrex::MultiFab& w_mac));
amrex::MultiFab& w_mac),
AMREX_D_DECL(amrex::MultiFab* sfu_mac, amrex::MultiFab* sfv_mac, amrex::MultiFab* sfw_mac));

// normal vector of interface
amrex::Vector<amrex::MultiFab> normal;
Loading