Skip to content

Commit

Permalink
Merge branch 'development' into add_test_probs
Browse files Browse the repository at this point in the history
  • Loading branch information
ewquon authored Feb 15, 2024
2 parents b3044fc + d37803b commit 2f5897f
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 76 deletions.
5 changes: 3 additions & 2 deletions Source/ERF.H
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,9 @@ private:
// eddy diffusivity of heat
"Khv","Khh",
// mynn pbl lengthscale
"Lpbl"
,"qt", "qp", "qv", "qc", "qi", "qrain", "qsnow", "qgraup"
"Lpbl",
// moisture vars
"qt", "qv", "qc", "qi", "qp", "qrain", "qsnow", "qgraup"
#ifdef ERF_COMPUTE_ERROR
,"xvel_err", "yvel_err", "zvel_err", "pp_err"
#endif
Expand Down
20 changes: 17 additions & 3 deletions Source/IO/Plotfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,13 @@ ERF::WritePlotFile (int which, Vector<std::string> plot_var_names)
mf_comp ++;
}

// TODO: The size of the q variables can vary with different
// moisture models. Therefore, certain components may
// reside at different indices. For example, Kessler is
// warm but precipitating. This puts qp at index 3.
// However, SAM is cold and precipitating so qp is index 4.
// Need to built an external enum struct or a better pathway.

// NOTE: Protect against accessing non-existent data
if (use_moisture) {
int q_size = qmoist[lev].size();
Expand All @@ -661,16 +668,23 @@ ERF::WritePlotFile (int which, Vector<std::string> plot_var_names)
mf_comp += 1;
}

if (containerHasElement(plot_var_names, "qi") && (q_size >= 4))
if (containerHasElement(plot_var_names, "qi") && (q_size > 4))
{
MultiFab qi_mf(*(qmoist[lev][3]), make_alias, 0, 1);
MultiFab::Copy(mf[lev],qi_mf,0,mf_comp,1,0);
mf_comp += 1;
}

if (containerHasElement(plot_var_names, "qp") && (q_size >= 5))
if (containerHasElement(plot_var_names, "qp") &&
((q_size >= 5) || (q_size==4)))
{
MultiFab qp_mf(*(qmoist[lev][4]), make_alias, 0, 1);
int q_ind;
if (q_size >= 5) { // Cold moisture physics (has ice)
q_ind = 4;
} else { // Warm moisture physics (no ice)
q_ind = 3;
}
MultiFab qp_mf(*(qmoist[lev][q_ind]), make_alias, 0, 1);
MultiFab::Copy(mf[lev],qp_mf,0,mf_comp,1,0);
mf_comp += 1;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Microphysics/FastEddy/Diagnose_FE.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Microphysics.H"
#include "FastEddy.H"

/**
* Computes diagnostic quantities like cloud ice/liquid and precipitation ice/liquid
Expand Down
13 changes: 7 additions & 6 deletions Source/Microphysics/FastEddy/FastEddy.H
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/*
*/
#ifndef FastEddy_H
#define FastEddy_H

Expand All @@ -16,17 +14,20 @@
#include "Microphysics_Utils.H"
#include "IndexDefines.H"
#include "DataStruct.H"
#include "NullMoist.H"

namespace MicVar_FE {
enum {
// independent variables
qv = 0,
qc,
qt,
rho, // density
rho=0, // density
theta, // liquid/ice water potential temperature
tabs, // temperature
pres, // pressure
// non-precipitating vars
qt, // total cloud
qv, // cloud vapor
qc, // cloud water
// derived vars
NumVars
};
}
Expand Down
6 changes: 1 addition & 5 deletions Source/Microphysics/FastEddy/FastEddy.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/*
* this file is modified from precip_proc from samxx
*/
#include "Microphysics.H"

#include <EOS.H>
#include <TileNoZ.H>
#include "FastEddy.H"

using namespace amrex;

Expand Down
2 changes: 1 addition & 1 deletion Source/Microphysics/FastEddy/Init_FE.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <AMReX_GpuContainers.H>
#include "Microphysics.H"
#include "FastEddy.H"
#include "IndexDefines.H"
#include "PlaneAverage.H"
#include "EOS.H"
Expand Down
3 changes: 1 addition & 2 deletions Source/Microphysics/FastEddy/Update_FE.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

#include "Microphysics.H"
#include "FastEddy.H"
#include "IndexDefines.H"
#include "TileNoZ.H"

Expand Down
8 changes: 4 additions & 4 deletions Source/Microphysics/Kessler/Init_Kessler.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <AMReX_GpuContainers.H>
#include "Microphysics.H"
#include "Kessler.H"
#include "IndexDefines.H"
#include "PlaneAverage.H"
#include "EOS.H"
Expand Down Expand Up @@ -29,8 +29,7 @@ void Kessler::Init (const MultiFab& cons_in,
m_gtoe = grids;

MicVarMap.resize(m_qmoist_size);
MicVarMap = {MicVar_Kess::qt, MicVar_Kess::qv, MicVar_Kess::qcl, MicVar_Kess::qci,
MicVar_Kess::qp, MicVar_Kess::qpl, MicVar_Kess::qpi};
MicVarMap = {MicVar_Kess::qt, MicVar_Kess::qv, MicVar_Kess::qcl, MicVar_Kess::qp};

// initialize microphysics variables
for (auto ivar = 0; ivar < MicVar_Kess::NumVars; ++ivar) {
Expand Down Expand Up @@ -65,10 +64,11 @@ void Kessler::Copy_State_to_Micro (const MultiFab& cons_in)

auto states_array = cons_in.array(mfi);

auto qt_array = mic_fab_vars[MicVar_Kess::qt]->array(mfi);
auto qv_array = mic_fab_vars[MicVar_Kess::qv]->array(mfi);
auto qc_array = mic_fab_vars[MicVar_Kess::qcl]->array(mfi);

auto qp_array = mic_fab_vars[MicVar_Kess::qp]->array(mfi);
auto qt_array = mic_fab_vars[MicVar_Kess::qt]->array(mfi);

auto rho_array = mic_fab_vars[MicVar_Kess::rho]->array(mfi);
auto theta_array = mic_fab_vars[MicVar_Kess::theta]->array(mfi);
Expand Down
27 changes: 11 additions & 16 deletions Source/Microphysics/Kessler/Kessler.H
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,22 @@
#include "Microphysics_Utils.H"
#include "IndexDefines.H"
#include "DataStruct.H"
#include "NullMoist.H"

namespace MicVar_Kess {
enum {
// independent variables
qt = 0,
qp,
rho=0, // density
theta, // liquid/ice water potential temperature
tabs, // temperature
rho, // density
pres, // pressure
// derived variables
qr, // rain water
qv, // water vapor
qn, // cloud condensate (liquid+ice), initial to zero
qci, // cloud ice
qcl, // cloud water
qpl, // precip rain
qpi, // precip ice
qg, // graupel
// temporary variable
omega,
// non-precipitating vars
qt, // total cloud
qv, // cloud vapor
qcl, // cloud water
// precipitating vars
qp, // total precip
// derived vars
NumVars
};
}
Expand Down Expand Up @@ -134,8 +129,8 @@ public:
Qstate_Size () override { return Kessler::m_qstate_size; }

private:
// Number of qmoist variables (qt, qv, qcl, qci, qp, qpl, qpi)
int m_qmoist_size = 7;
// Number of qmoist variables (qt, qv, qcl, qp)
int m_qmoist_size = 4;

// Number of qstate variables
int m_qstate_size = 3;
Expand Down
16 changes: 6 additions & 10 deletions Source/Microphysics/Kessler/Kessler.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/*
* this file is modified from precip_proc from samxx
*/
#include "Microphysics.H"

#include <EOS.H>
#include <TileNoZ.H>
#include "Kessler.H"

using namespace amrex;

Expand All @@ -13,11 +9,11 @@ using namespace amrex;
*/
void Kessler::AdvanceKessler ()
{
auto qv = mic_fab_vars[MicVar_Kess::qv];
auto qc = mic_fab_vars[MicVar_Kess::qcl];
auto qp = mic_fab_vars[MicVar_Kess::qp];
auto tabs = mic_fab_vars[MicVar_Kess::tabs];
auto pres = mic_fab_vars[MicVar_Kess::pres];
auto qv = mic_fab_vars[MicVar_Kess::qv];
auto qc = mic_fab_vars[MicVar_Kess::qcl];
auto qp = mic_fab_vars[MicVar_Kess::qp];
auto tabs = mic_fab_vars[MicVar_Kess::tabs];
auto pres = mic_fab_vars[MicVar_Kess::pres];
auto theta = mic_fab_vars[MicVar_Kess::theta];
auto rho = mic_fab_vars[MicVar_Kess::rho];

Expand Down
3 changes: 1 addition & 2 deletions Source/Microphysics/Kessler/Update_Kessler.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

#include "Microphysics.H"
#include "Kessler.H"
#include "IndexDefines.H"
#include "TileNoZ.H"

Expand Down
4 changes: 2 additions & 2 deletions Source/Microphysics/SAM/Diagnose_SAM.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Microphysics.H"
#include "SAM.H"
#include "EOS.H"

/**
Expand All @@ -15,7 +15,7 @@ void SAM::Diagnose () {
auto qci = mic_fab_vars[MicVar::qci];
auto qpl = mic_fab_vars[MicVar::qpl];
auto qpi = mic_fab_vars[MicVar::qpi];
auto qg = mic_fab_vars[MicVar::qg];
auto qg = mic_fab_vars[MicVar::qg];
auto tabs = mic_fab_vars[MicVar::tabs];

for ( amrex::MFIter mfi(*tabs, amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi) {
Expand Down
3 changes: 1 addition & 2 deletions Source/Microphysics/SAM/IceFall.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

#include <AMReX_ParReduce.H>
#include "Microphysics.H"
#include "SAM.H"
#include "TileNoZ.H"

using namespace amrex;
Expand Down
2 changes: 1 addition & 1 deletion Source/Microphysics/SAM/Init_SAM.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <AMReX_GpuContainers.H>
#include "Microphysics.H"
#include "SAM.H"
#include "IndexDefines.H"
#include "PlaneAverage.H"
#include "EOS.H"
Expand Down
5 changes: 1 addition & 4 deletions Source/Microphysics/SAM/Precip.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/*
* this file is modified from precip_proc from samxx
*/
#include "Microphysics.H"
#include "SAM.H"

using namespace amrex;

Expand Down
2 changes: 1 addition & 1 deletion Source/Microphysics/SAM/PrecipFall.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "ERF_Constants.H"
#include "Microphysics.H"
#include "SAM.H"
#include "TileNoZ.H"

using namespace amrex;
Expand Down
26 changes: 14 additions & 12 deletions Source/Microphysics/SAM/SAM.H
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,27 @@
#include "Microphysics_Utils.H"
#include "IndexDefines.H"
#include "DataStruct.H"
#include "NullMoist.H"

namespace MicVar {
enum {
// independent variables
qt = 0,
qp,
rho=0, // density
theta, // liquid/ice water potential temperature
tabs, // temperature
rho, // density
pres, // pressure
// derived variables
qv, // water vapor
qn, // cloud condensate (liquid+ice), initial to zero
qci, // cloud ice
qcl, // cloud water
qpl, // precip rain
qpi, // precip ice
qg, // graupel
// temporary variable
// non-precipitating vars
qt, // total cloud
qn, // cloud condesnate (liquid + ice)
qv, // cloud vapor
qcl, // cloud water
qci, // cloud ice
// precipitating vars
qp, // total precip
qpl, // precip rain
qpi, // precip ice
qg, // graupel
// derived vars
omega,
NumVars
};
Expand Down
3 changes: 1 addition & 2 deletions Source/Microphysics/SAM/Update_SAM.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

#include "Microphysics.H"
#include "SAM.H"
#include "IndexDefines.H"
#include "TileNoZ.H"

Expand Down

0 comments on commit 2f5897f

Please sign in to comment.