Skip to content

Commit

Permalink
Fix todo with plotfile.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Lattanzi committed Dec 13, 2023
1 parent 0ea42fd commit 56dbb2d
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions Source/IO/Plotfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,24 +599,25 @@ ERF::WritePlotFile (int which, Vector<std::string> plot_var_names)
mf_comp ++;
}

// TODO: Protect against accessing non-existent data
int q_size = micro.Get_Qmoist_Size();
MultiFab qv_mf(*(qmoist[lev]), make_alias, 0, 1);
MultiFab qc_mf(*(qmoist[lev]), make_alias, 1, 1);
MultiFab qi_mf(*(qmoist[lev]), make_alias, 2, 1);
MultiFab qr_mf(*(qmoist[lev]), make_alias, 3, 1);
MultiFab qs_mf(*(qmoist[lev]), make_alias, 4, 1);
MultiFab qg_mf(*(qmoist[lev]), make_alias, 5, 1);

if (containerHasElement(plot_var_names, "qt"))
// NOTE: Protect against accessing non-existent data
int q_size = qmoist[lev]->nComp();
MultiFab qv_mf, qc_mf, qi_mf, qr_mf, qs_mf, qg_mf;
qv_mf(*(qmoist[lev]), make_alias, 0, 1);
if (q_size>1) qc_mf(*(qmoist[lev]), make_alias, 1, 1);
if (q_size>2) qi_mf(*(qmoist[lev]), make_alias, 2, 1);
if (q_size>3) qr_mf(*(qmoist[lev]), make_alias, 3, 1);
if (q_size>4) qs_mf(*(qmoist[lev]), make_alias, 4, 1);
if (q_size>5) qg_mf(*(qmoist[lev]), make_alias, 5, 1);

if (containerHasElement(plot_var_names, "qt") && (q_size >= 3))
{
MultiFab::Copy(mf[lev],qv_mf,0,mf_comp,1,0);
MultiFab::Add (mf[lev],qc_mf,0,mf_comp,1,0);
MultiFab::Add (mf[lev],qi_mf,0,mf_comp,1,0);
mf_comp += 1;
}

if (containerHasElement(plot_var_names, "qp"))
if (containerHasElement(plot_var_names, "qp") && (q_size >= 6))
{
MultiFab::Copy(mf[lev],qr_mf,0,mf_comp,1,0);
MultiFab::Add (mf[lev],qs_mf,0,mf_comp,1,0);
Expand All @@ -630,31 +631,31 @@ ERF::WritePlotFile (int which, Vector<std::string> plot_var_names)
mf_comp += 1;
}

if (containerHasElement(plot_var_names, "qc"))
if (containerHasElement(plot_var_names, "qc") && (q_size >= 2))
{
MultiFab::Copy(mf[lev],qc_mf,0,mf_comp,1,0);
if (q_size>1) MultiFab::Copy(mf[lev],qc_mf,0,mf_comp,1,0);
mf_comp += 1;
}

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

if (containerHasElement(plot_var_names, "qrain"))
if (containerHasElement(plot_var_names, "qrain") && (q_size >= 4))
{
MultiFab::Copy(mf[lev],qr_mf,0,mf_comp,1,0);
mf_comp += 1;
}

if (containerHasElement(plot_var_names, "qsnow"))
if (containerHasElement(plot_var_names, "qsnow") && (q_size >= 5))
{
MultiFab::Copy(mf[lev],qs_mf,0,mf_comp,1,0);
mf_comp += 1;
}

if (containerHasElement(plot_var_names, "qgraup"))
if (containerHasElement(plot_var_names, "qgraup") && (q_size >= 6))
{
MultiFab::Copy(mf[lev],qg_mf,0,mf_comp,1,0);
mf_comp += 1;
Expand Down

0 comments on commit 56dbb2d

Please sign in to comment.