Skip to content

Commit

Permalink
tryign to average down after reflux
Browse files Browse the repository at this point in the history
  • Loading branch information
jbbel committed May 23, 2024
1 parent 0382c06 commit bc70d38
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
8 changes: 4 additions & 4 deletions exec/dean_kow/multilevel/inputs_bug1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# whichever comes first
# *****************************************************************
max_step = 2500
max_step = 5
max_step = 50

seed = 1024

Expand Down Expand Up @@ -36,11 +36,11 @@ amr.v = 1 # verbosity in Amr
# Resolution and refinement
# *****************************************************************

amr.n_cell = 256 256
amr.n_cell = 32 32
amr.n_cell = 256 256
amr.max_grid_size_x = 256 256
amr.max_grid_size_y = 256 256
amr.max_grid_size_x = 64 64
amr.max_grid_size_x = 64 64
amr.max_grid_size_y = 64 64

amr.max_level = 1
Expand All @@ -62,7 +62,7 @@ amr.blocking_factor_x = 8
amr.blocking_factor_y = 8
amr.blocking_factor_z = 8

amr.regrid_int = 2 # how often to regrid
amr.regrid_int = 10 # how often to regrid

# *****************************************************************
# Time step control
Expand Down
13 changes: 11 additions & 2 deletions src_deankow/multilevel/AmrCoreAdv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ AmrCoreAdv::Evolve ()
Real sum_phi_new = phi_new[0].sum();

amrex::Print() << "Coarse STEP " << step+1 << " ends." << " TIME = " << cur_time
<< " DT = " << dt[0] << " Sum(Phi) = " << sum_phi_old << " " << sum_phi_new << std::endl;
<< " DT = " << dt[0] << " Sum(Phi) = " << std::setw(24) << std::setprecision(16)
<< std::scientific << sum_phi_old << " " << std::setw(2l) << std::setprecision(16)
<< std::scientific << sum_phi_new << std::endl;

// sync up time
for (lev = 0; lev <= finest_level; ++lev) {
Expand Down Expand Up @@ -292,7 +294,7 @@ AmrCoreAdv::RemakeLevel (int lev, Real time, const BoxArray& ba,

#ifdef AMREX_PARTICLES
if (lev == 1) {
particleData.regrid_particles(grown_fba, old_fine_ba, phi_new[1]);
particleData.regrid_particles(grown_fba, ba, old_fine_ba, phi_new[1]);
}
#endif
}
Expand Down Expand Up @@ -629,6 +631,13 @@ AmrCoreAdv::timeStepNoSubcycling (Real time, int iteration)
if (istep[0] % regrid_int == 0)
{
regrid(0, time);

AverageDown();

Real sum_phi_reg = phi_new[0].sum();
amrex::Print() << " Sum(Phi) new after regrid = " << std::setw(24) << std::setprecision(16) << std::scientific << sum_phi_reg << std::endl;
sum_phi_reg = phi_old[0].sum();
amrex::Print() << " Sum(Phi) old after regrid = " << std::setw(24) << std::setprecision(16) << std::scientific << sum_phi_reg << std::endl;
}
}

Expand Down
16 changes: 14 additions & 2 deletions src_deankow/multilevel/ParticleData.H
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,26 @@ struct ParticleData {
}
}

void regrid_particles(const amrex::BoxArray& new_fine_ba, const amrex::BoxArray& old_fine_ba, amrex::MultiFab& phi_fine)
void regrid_particles(const amrex::BoxArray& new_fine_ba, const amrex::BoxArray& new_ungrown_ba, const amrex::BoxArray& old_fine_ba, amrex::MultiFab& phi_fine)
{
amrex::DistributionMapping new_dm { new_fine_ba, amrex::ParallelDescriptor::NProcs() };
stochastic_particles->SetParticleDistributionMap(1, new_dm);
stochastic_particles->SetParticleBoxArray(1, new_fine_ba);
stochastic_particles->SetParticleBoxArray(1, new_ungrown_ba);
stochastic_particles->Redistribute();
stochastic_particles->RemoveParticlesAtLevel(0);
stochastic_particles->AddParticles(phi_fine, old_fine_ba);
phi_fine.setVal(0.0);
const int lev = 1;
const auto dx = stochastic_particles->Geom(lev).CellSizeArray();

#if (AMREX_SPACEDIM == 2)
const amrex::Real cell_vol = dx[0]*dx[1];
#else
const amrex::Real cell_vol = dx[0]*dx[1]*dx[2];
#endif
stochastic_particles->Increment(phi_fine, lev);
phi_fine.mult(1./cell_vol);
stochastic_particles->SetParticleBoxArray(1, new_fine_ba);
}

void Checkpoint (const std::string& filename) const
Expand Down
1 change: 1 addition & 0 deletions src_deankow/multilevel/mykernel.H
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void init_phi (int i, int j, int k,
Real x = prob_lo[0] + (i+Real(0.5)) * dx[0] - xcent;
Real y = prob_lo[1] + (j+Real(0.5)) * dx[1] - ycent;
Real r2 = (x*x + y*y);
r2 = 4.*(x-y)*(x-y)+ .25*(x+y)*(x+y);
#if (AMREX_SPACEDIM == 3)
Real zcent = Real(0.75);
Real z = prob_lo[2] + (k+Real(0.5)) * dx[2] - zcent;
Expand Down

0 comments on commit bc70d38

Please sign in to comment.