Skip to content

Commit

Permalink
Add non-conservative tracer to corrector
Browse files Browse the repository at this point in the history
  • Loading branch information
cgilet committed Apr 1, 2024
1 parent 9871881 commit 1084e66
Showing 1 changed file with 38 additions and 22 deletions.
60 changes: 38 additions & 22 deletions src/incflo_apply_corrector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ void incflo::ApplyCorrector()
Array4<Real const> const& dtdt = ld.conv_tracer.const_array(mfi);
Array4<Real const> const& tra_f = (l_ntrac > 0) ? tra_forces[lev].const_array(mfi)
: Array4<Real const>{};
auto iconserv = get_tracer_iconserv_device_ptr();

if (m_diff_type == DiffusionType::Explicit)
{
Expand All @@ -255,13 +256,19 @@ void incflo::ApplyCorrector()
{
for (int n = 0; n < l_ntrac; ++n)
{
Real tra_new = rho_o(i,j,k)*tra_o(i,j,k,n) + l_dt * (
m_half*( dtdt(i,j,k,n) + dtdt_o(i,j,k,n))
+m_half*(laps_o(i,j,k,n) + laps(i,j,k,n))
+ tra_f(i,j,k,n) );

tra_new /= rho(i,j,k);
tra(i,j,k,n) = tra_new;
if ( iconserv[n] ) {
Real tra_new = rho_o(i,j,k)*tra_o(i,j,k,n) + l_dt * (
m_half*( dtdt(i,j,k,n) + dtdt_o(i,j,k,n))
+m_half*(laps_o(i,j,k,n) + laps(i,j,k,n))
+ tra_f(i,j,k,n) );

tra(i,j,k,n) = tra_new / rho(i,j,k);
} else {
tra(i,j,k,n) = tra_o(i,j,k,n) + l_dt * (
m_half*( dtdt(i,j,k,n) + dtdt_o(i,j,k,n))
+m_half*(laps_o(i,j,k,n) + laps(i,j,k,n))
+ tra_f(i,j,k,n) );
}
}
});
}
Expand All @@ -273,14 +280,19 @@ void incflo::ApplyCorrector()
{
for (int n = 0; n < l_ntrac; ++n)
{
Real tra_new = rho_o(i,j,k)*tra_o(i,j,k,n) + l_dt * (
m_half*( dtdt(i,j,k,n) + dtdt_o(i,j,k,n))
+m_half*(laps_o(i,j,k,n) )
+ tra_f(i,j,k,n) );

tra_new /= rho(i,j,k);
tra(i,j,k,n) = tra_new;
}
if ( iconserv[n] ) {
Real tra_new = rho_o(i,j,k)*tra_o(i,j,k,n) + l_dt * (
m_half*( dtdt(i,j,k,n) + dtdt_o(i,j,k,n))
+m_half*(laps_o(i,j,k,n) )
+ tra_f(i,j,k,n) );

tra(i,j,k,n) = tra_new / rho(i,j,k);
} else {
tra(i,j,k,n) = tra_o(i,j,k,n) + l_dt * (
m_half*( dtdt(i,j,k,n) + dtdt_o(i,j,k,n))
+m_half*(laps_o(i,j,k,n) )
+ tra_f(i,j,k,n) );
}
});
}
else if (m_diff_type == DiffusionType::Implicit)
Expand All @@ -289,13 +301,17 @@ void incflo::ApplyCorrector()
{
for (int n = 0; n < l_ntrac; ++n)
{
Real tra_new = rho_o(i,j,k)*tra_o(i,j,k,n) + l_dt * (
m_half*( dtdt(i,j,k,n)+dtdt_o(i,j,k,n))
+ tra_f(i,j,k,n) );

tra_new /= rho(i,j,k);
tra(i,j,k,n) = tra_new;
}
if ( iconserv[n] ) {
Real tra_new = rho_o(i,j,k)*tra_o(i,j,k,n) + l_dt * (
m_half*( dtdt(i,j,k,n)+dtdt_o(i,j,k,n))
+ tra_f(i,j,k,n) );

tra(i,j,k,n) = tra_new / rho(i,j,k);
} else {
tra(i,j,k,n) = tra_o(i,j,k,n) + l_dt * (
m_half*( dtdt(i,j,k,n)+dtdt_o(i,j,k,n))
+ tra_f(i,j,k,n) );
}
});
}
} // mfi
Expand Down

0 comments on commit 1084e66

Please sign in to comment.