8 #include <athena/athena.hpp>
9 #include <athena/mesh/mesh.hpp>
10 #include <athena/parameter_input.hpp>
11 #include <athena/reconstruct/interpolation.hpp>
12 #include <athena/scalars/scalars.hpp>
15 #include <application/application.hpp>
16 #include <application/exceptions.hpp>
20 #include <configure.hpp>
31 if (NCLOUD == 0)
return;
33 Application::Logger app(
"microphysics");
34 app->Log(
"Initialize Microphysics");
36 w.InitWithShallowSlice(pmb->pscalars->r, 4, 0, NCLOUD);
37 u.InitWithShallowSlice(pmb->pscalars->s, 4, 0, NCLOUD);
39 int ncells1 = pmb->ncells1;
40 int ncells2 = pmb->ncells2;
41 int ncells3 = pmb->ncells3;
44 vsedf[0].NewAthenaArray(NCLOUD, ncells3, ncells2, ncells1 + 1);
45 vsedf[1].NewAthenaArray(NCLOUD, ncells3, ncells2 + 1, ncells1);
46 vsedf[2].NewAthenaArray(NCLOUD, ncells3 + 1, ncells2, ncells1);
49 mass_flux[0].NewAthenaArray(NCLOUD, ncells3, ncells2, ncells1 + 1);
50 mass_flux[1].NewAthenaArray(NCLOUD, ncells3, ncells2 + 1, ncells1);
51 mass_flux[2].NewAthenaArray(NCLOUD, ncells3 + 1, ncells2, ncells1);
54 vsed_[0].NewAthenaArray(NCLOUD, ncells3, ncells2, ncells1);
56 vsed_[1].NewAthenaArray(NCLOUD, ncells3, ncells2, ncells1);
58 vsed_[2].NewAthenaArray(NCLOUD, ncells3, ncells2, ncells1);
68 if (NCLOUD == 0)
return;
70 Application::Logger app(
"microphysics");
71 app->Log(
"Destroy Microphysics");
79 for (
auto &air : ac) {
80 system->AssembleReactionMatrix(air,
time);
81 system->EvolveOneStep(&air,
time, dt);
88 int ks = pmb->ks, js = pmb->js, is = pmb->is;
89 int ke = pmb->ke, je = pmb->je, ie = pmb->ie;
92 system->SetVsedFromConserved(
vsed_, phydro, ks, ke, js, je, is, ie);
96 for (
int n = 0; n < NCLOUD; ++n)
97 for (
int k = ks; k <= ke + 1; ++k)
98 for (
int j = js;
j <= je + 1; ++
j)
99 for (
int i = is; i <= ie + 1; ++i) {
100 vsedf[X1DIR](n, k,
j, i) = interp_cp4(
101 vsed_[X1DIR](n, k,
j, i - 2),
vsed_[X1DIR](n, k,
j, i - 1),
102 vsed_[X1DIR](n, k,
j, i),
vsed_[X1DIR](n, k,
j, i + 1));
104 vsedf[X2DIR](n, k,
j, i) = interp_cp4(
105 vsed_[X2DIR](n, k,
j - 2, i),
vsed_[X2DIR](n, k,
j - 1, i),
106 vsed_[X2DIR](n, k,
j, i),
vsed_[X2DIR](n, k,
j + 1, i));
108 vsedf[X3DIR](n, k,
j, i) = interp_cp4(
109 vsed_[X3DIR](n, k - 2,
j, i),
vsed_[X3DIR](n, k - 1,
j, i),
110 vsed_[X3DIR](n, k,
j, i),
vsed_[X3DIR](n, k + 1,
j, i));
114 for (
int n = 0; n < NCLOUD; ++n)
115 for (
int k = ks; k <= ke; ++k)
116 for (
int j = js;
j <= je; ++
j) {
118 vsedf[X1DIR](n, k,
j, is) = 0.;
119 vsedf[X1DIR](n, k,
j, ie + 1) = 0.;
135 auto scheduler = pmb->pimpl->scheduler;
136 if (!scheduler->CheckDone({hydro_implicit_correction}))
return false;
141 auto scheduler = pmb->pimpl->scheduler;
142 if (!scheduler->CheckDone({hydro_calculate_flux}))
return false;
149 auto scheduler = pmb->pimpl->scheduler;
150 if (!scheduler->CheckDone({hydro_implicit_correction}))
return false;
155 auto scheduler = pmb->pimpl->scheduler;
156 if (!scheduler->CheckDone({microphysics_set_mass_flux}))
return false;
std::vector< AirParcel > AirColumn
static AllMicrophysicalSchemes Create(MeshBlock *pmb, ParameterInput *pin)
AthenaArray< Real > w
primitive variables: mass fraction [kg/kg]
void SetVsedFromConserved(Hydro const *phydro)
inbound functions
Microphysics(MeshBlock *pmb, ParameterInput *pin)
constructor and destructor
std::vector< std::shared_ptr< MicrophysicalSchemeBase > > systems_
pointers of microphysical systems
AthenaArray< Real > u
conserved variables: mass concentration [kg/m^3]
static const std::string input_key
microphysics input key in the input file [microphysics_config]
MeshBlock const * pmy_block_
meshblock pointer
AthenaArray< Real > vsed_[3]
sedimentation velocity at cell center [m/s]
void EvolveSystems(AirColumn &ac, Real time, Real dt)
Evolve all microphysical systems.
AthenaArray< Real > mass_flux[3]
mass flux of the dry fluid [kg/m^2/s]
AthenaArray< Real > vsedf[3]
sedimentation velocity at cell interface [m/s]
bool microphysics_set_mass_flux(MeshBlock *pmb, IntegrationStage stage)
bool hydro_calculate_flux(MeshBlock *pmb, IntegrationStage stage)
bool microphysics_evolve_system(MeshBlock *pmb, IntegrationStage stage)
bool hydro_implicit_correction(MeshBlock *pmb, IntegrationStage stage)
bool microphysics_set_sedimentaton_velocity(MeshBlock *pmb, IntegrationStage stage)
bool scalar_claculate_flux(MeshBlock *pmb, IntegrationStage stage)
std::pair< int, int > IntegrationStage