forked from erf-model/ERF
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multiple moist models (erf-model#1303)
* Does not compile with templated Microphysics.H but does compile with the case select version (commented out). * Remove buffer files. * Use inheritance through NullMoist class to reset ptr in Microphysics.
- Loading branch information
1 parent
00c1513
commit accb442
Showing
19 changed files
with
316 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,2 @@ | ||
CEXE_sources += Cloud.cpp | ||
CEXE_sources += Init.cpp | ||
CEXE_sources += Diagnose.cpp | ||
CEXE_sources += Update.cpp | ||
CEXE_sources += IceFall.cpp | ||
CEXE_sources += Precip.cpp | ||
CEXE_sources += PrecipFall.cpp | ||
CEXE_headers += Microphysics.H | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,163 +1,55 @@ | ||
/* | ||
* Implementation 1-moment microphysics model | ||
* NOTE: this model is based on the SAM code, and the Klemp's paper | ||
* 1): Joseph, Klemp, the simulation of three-dimensional convective storm dynamics, | ||
* Journal of the atmospheric sciences, vol35, p1070 | ||
* 2): Marat Khairoutdinov and David Randall, cloud resolving modeling of the ARM summer 1997 IOP: | ||
* model formulation, results, unvertainties, and sensitivities, Journal of the atmospheric sciences, vol60, p607 | ||
*/ | ||
#ifndef MICROPHYSICS_H | ||
#define MICROPHYSICS_H | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <memory> | ||
#include <NullMoist.H> | ||
#include <SAM.H> | ||
|
||
#include <AMReX_FArrayBox.H> | ||
#include <AMReX_Geometry.H> | ||
#include <AMReX_TableData.H> | ||
#include <AMReX_MultiFabUtil.H> | ||
|
||
#include "ERF_Constants.H" | ||
#include "Microphysics_Utils.H" | ||
#include "IndexDefines.H" | ||
#include "DataStruct.H" | ||
|
||
namespace MicVar { | ||
enum { | ||
// independent variables | ||
qt = 0, | ||
qp, | ||
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 | ||
// temporary variable | ||
omega, | ||
NumVars | ||
}; | ||
} | ||
|
||
// | ||
// use MultiFab for 3D data, but table for 1D data | ||
// | ||
class Microphysics { | ||
|
||
using FabPtr = std::shared_ptr<amrex::MultiFab>; | ||
|
||
public: | ||
// constructor | ||
Microphysics () {} | ||
|
||
// Set up for first time | ||
void define (SolverChoice& sc) | ||
{ | ||
docloud = sc.do_cloud; | ||
doprecip = sc.do_precip; | ||
m_fac_cond = lcond / sc.c_p; | ||
m_fac_fus = lfus / sc.c_p; | ||
m_fac_sub = lsub / sc.c_p; | ||
m_gOcp = CONST_GRAV / sc.c_p; | ||
m_axis = sc.ave_plane; | ||
} | ||
|
||
// destructor | ||
~Microphysics () = default; | ||
|
||
// cloud physics | ||
void Cloud (); | ||
|
||
// ice physics | ||
void IceFall (); | ||
|
||
// precip | ||
void Precip (); | ||
|
||
// precip fall | ||
void PrecipFall (int hydro_type); | ||
|
||
// micro interface for precip fall | ||
void MicroPrecipFall (); | ||
|
||
// init | ||
void Init (const amrex::MultiFab& cons_in, | ||
amrex::MultiFab& qmoist, | ||
const amrex::BoxArray& grids, | ||
const amrex::Geometry& geom, | ||
const amrex::Real& dt_advance); | ||
|
||
// update ERF variables | ||
void Update (amrex::MultiFab& cons_in, | ||
amrex::MultiFab& qmoist); | ||
|
||
// diagnose | ||
void Diagnose (); | ||
|
||
// process microphysics | ||
void Proc (); | ||
|
||
private: | ||
// geometry | ||
amrex::Geometry m_geom; | ||
// valid boxes on which to evolve the solution | ||
amrex::BoxArray m_gtoe; | ||
|
||
// timestep | ||
amrex::Real dt; | ||
|
||
// number of vertical levels | ||
int nlev, zlo, zhi; | ||
|
||
// plane average axis | ||
int m_axis; | ||
|
||
// model options | ||
bool docloud, doprecip; | ||
|
||
// constants | ||
amrex::Real m_fac_cond; | ||
amrex::Real m_fac_fus; | ||
amrex::Real m_fac_sub; | ||
amrex::Real m_gOcp; | ||
|
||
// microphysics parameters/coefficients | ||
amrex::TableData<amrex::Real, 1> accrrc; | ||
amrex::TableData<amrex::Real, 1> accrsi; | ||
amrex::TableData<amrex::Real, 1> accrsc; | ||
amrex::TableData<amrex::Real, 1> coefice; | ||
amrex::TableData<amrex::Real, 1> evaps1; | ||
amrex::TableData<amrex::Real, 1> evaps2; | ||
amrex::TableData<amrex::Real, 1> accrgi; | ||
amrex::TableData<amrex::Real, 1> accrgc; | ||
amrex::TableData<amrex::Real, 1> evapg1; | ||
amrex::TableData<amrex::Real, 1> evapg2; | ||
amrex::TableData<amrex::Real, 1> evapr1; | ||
amrex::TableData<amrex::Real, 1> evapr2; | ||
|
||
// vertical plane average data | ||
amrex::TableData<amrex::Real, 1> rho1d; | ||
amrex::TableData<amrex::Real, 1> pres1d; | ||
amrex::TableData<amrex::Real, 1> tabs1d; | ||
amrex::TableData<amrex::Real, 1> qt1d; | ||
amrex::TableData<amrex::Real, 1> qv1d; | ||
amrex::TableData<amrex::Real, 1> qn1d; | ||
|
||
// independent variables | ||
amrex::Array<FabPtr, MicVar::NumVars> mic_fab_vars; | ||
|
||
amrex::TableData<amrex::Real, 1> gamaz; | ||
amrex::TableData<amrex::Real, 1> zmid; // mid value of vertical coordinate in physical domain | ||
|
||
// data (output) | ||
amrex::TableData<amrex::Real, 1> qifall; | ||
amrex::TableData<amrex::Real, 1> tlatqi; | ||
public: | ||
|
||
Microphysics () { } | ||
|
||
~Microphysics () = default; | ||
|
||
template<class NewMoistModel> | ||
void | ||
SetModel () | ||
{ | ||
m_moist_model = std::make_unique<NewMoistModel>(); | ||
} | ||
|
||
void | ||
define (SolverChoice& sc) | ||
{ | ||
m_moist_model->define(sc); | ||
} | ||
|
||
void | ||
Init (const amrex::MultiFab& cons_in, | ||
amrex::MultiFab& qmoist, | ||
const amrex::BoxArray& grids, | ||
const amrex::Geometry& geom, | ||
const amrex::Real& dt_advance) | ||
{ | ||
m_moist_model->Init(cons_in, qmoist, grids, geom, dt_advance); | ||
} | ||
|
||
void | ||
Advance ( ) | ||
{ | ||
m_moist_model->Advance(); | ||
} | ||
|
||
void | ||
Update (amrex::MultiFab& cons_in, | ||
amrex::MultiFab& qmoist) | ||
{ | ||
m_moist_model->Update(cons_in, qmoist); | ||
} | ||
|
||
|
||
private: | ||
std::unique_ptr<NullMoist> m_moist_model; | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CEXE_headers += NullMoist.H | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#ifndef NULLMOIST_H | ||
#define NULLMOIST_H | ||
|
||
#include <AMReX_MultiFabUtil.H> | ||
#include <AMReX_Geometry.H> | ||
#include <DataStruct.H> | ||
|
||
class NullMoist { | ||
|
||
public: | ||
NullMoist () {} | ||
|
||
virtual ~NullMoist () = default; | ||
|
||
virtual void | ||
define (SolverChoice& /*sc*/) { }; | ||
|
||
virtual | ||
void Init (const amrex::MultiFab& /*cons_in*/, | ||
amrex::MultiFab& /*qmoist*/, | ||
const amrex::BoxArray& /*grids*/, | ||
const amrex::Geometry& /*geom*/, | ||
const amrex::Real& /*dt_advance*/) { }; | ||
|
||
virtual void | ||
Advance ( ) { }; | ||
|
||
virtual void | ||
Update (amrex::MultiFab& /*cons_in*/, | ||
amrex::MultiFab& /*qmoist*/) { }; | ||
|
||
private: | ||
|
||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.