ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
FireCouplingParams Struct Reference

#include <ERF_FireCouplingParams.H>

Collaboration diagram for FireCouplingParams:

Public Member Functions

bool is_passive () const
 
bool is_lagged () const
 
bool is_synchronous () const
 
bool injects_flux () const
 Heat (and vapour) reach the atmosphere: lagged and synchronous coupling. More...
 
bool heat_in_bottom_cell () const
 

Static Public Member Functions

static FireCouplingParams read ()
 

Public Attributes

bool enable = false
 erf.fire.enable: run a fire More...
 
std::string engine
 
int grid_ratio = 5
 erf.fire.grid_ratio: fire cells per atmospheric cell in x and y More...
 
int anchor_level = -1
 erf.fire.anchor_level: the level the fire grid refines, -1 = the finest More...
 
std::string coupling_type = "lagged"
 erf.fire.coupling_type: passive, lagged or synchronous More...
 
amrex::Real heat_flux_alfg = 45.0
 erf.fire.heat_flux_alfg: e-folding height of the injected heat [m] More...
 
amrex::Real fire_atm_feedback = 1.0
 erf.fire.fire_atm_feedback: multiplier on the injected fluxes More...
 
bool inject_latent = true
 erf.fire.inject_latent: inject the engine's latent flux as vapour More...
 
std::string source_mode = "overwrite"
 erf.fire.source_mode: overwrite or add to the theta and vapour sources More...
 
bool source_mode_given = false
 
bool heat_open_fraction = false
 erf.fire.heat_open_fraction: place the heat by the engine's open fraction More...
 
bool heat_tendency_density = false
 erf.fire.heat_tendency_density: density factor of the theta tendency More...
 
bool heat_tendency_exner = true
 erf.fire.heat_tendency_exner: Exner factor of the theta tendency More...
 
std::string heat_profile = "exponential"
 
bool smoke_enable = false
 erf.fire.smoke_enable: inject the smoke tracer More...
 
amrex::Real smoke_emission_factor = 0.02
 erf.fire.smoke_emission_factor: kg smoke per kg fuel burned [-] More...
 
bool fire_debug = false
 erf.fire.fire_debug: debug output of the coupling More...
 

Member Function Documentation

◆ heat_in_bottom_cell()

bool FireCouplingParams::heat_in_bottom_cell ( ) const
inline
62 { return heat_profile == "bottom_cell"; }
std::string heat_profile
Definition: ERF_FireCouplingParams.H:49

Referenced by FireCoupler::add_sources(), and read().

Here is the caller graph for this function:

◆ injects_flux()

bool FireCouplingParams::injects_flux ( ) const
inline

Heat (and vapour) reach the atmosphere: lagged and synchronous coupling.

61 { return is_lagged() || is_synchronous(); }
bool is_lagged() const
Definition: ERF_FireCouplingParams.H:58
bool is_synchronous() const
Definition: ERF_FireCouplingParams.H:59

Referenced by FireCoupler::add_sources(), FireCoupler::initialize(), and FireCoupler::update_flux_buffer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_lagged()

bool FireCouplingParams::is_lagged ( ) const
inline
58 { return coupling_type == "lagged"; }
std::string coupling_type
erf.fire.coupling_type: passive, lagged or synchronous
Definition: ERF_FireCouplingParams.H:29

Referenced by FireCoupler::advance(), and injects_flux().

Here is the caller graph for this function:

◆ is_passive()

bool FireCouplingParams::is_passive ( ) const
inline
57 { return coupling_type == "passive"; }

Referenced by read().

Here is the caller graph for this function:

◆ is_synchronous()

bool FireCouplingParams::is_synchronous ( ) const
inline
59 { return coupling_type == "synchronous"; }

Referenced by FireCoupler::advance(), and injects_flux().

Here is the caller graph for this function:

◆ read()

FireCouplingParams FireCouplingParams::read ( )
static

Parse and check the keys above from erf.fire.*. With erf.fire.enable, erf.fire.engine must name an engine compiled into this executable (fire_engine_names(), ERF_FireEngineRegistry.H).

11 {
13  amrex::ParmParse pp("erf.fire");
14  // Every message names the key and the value
15  auto fail = [](const std::string& msg) { amrex::Abort("[FIRE] " + msg); };
16  auto one_of = [&](const char* key, const std::string& v, const std::vector<std::string>& allowed) {
17  for (const auto& a : allowed) { if (v == a) { return; } }
18  std::string list;
19  for (const auto& a : allowed) { list += (list.empty() ? "" : ", ") + std::string("\"") + a + "\""; }
20  fail(std::string("erf.fire.") + key + " = \"" + v + "\" is not one of " + list);
21  };
22  auto positive = [&](const char* key, amrex::Real v) {
23  if (!(v > 0.0)) { fail(std::string("erf.fire.") + key + " must be > 0, got " + std::to_string(v)); }
24  };
25  auto nonneg = [&](const char* key, amrex::Real v) {
26  if (!(v >= 0.0)) { fail(std::string("erf.fire.") + key + " must be >= 0, got " + std::to_string(v)); }
27  };
28 
29  pp.query("enable", c.enable);
30  pp.query("fire_debug", c.fire_debug);
31  pp.query("grid_ratio", c.grid_ratio);
32  if (c.grid_ratio < 1) {
33  fail("erf.fire.grid_ratio must be >= 1, got " + std::to_string(c.grid_ratio));
34  }
35  pp.query("anchor_level", c.anchor_level);
36  if (c.anchor_level < -1) {
37  fail("erf.fire.anchor_level must be -1 (the finest level) or a level >= 0, got "
38  + std::to_string(c.anchor_level));
39  }
40 
41  // The engine: one compiled into this executable (ERF_REGISTER_FIRE_ENGINE).
42  // With a single engine it is the default; with several the deck names one.
43  const std::vector<std::string> engines = fire_engine_names();
44  if (engines.size() == 1) { c.engine = engines.front(); }
45  const bool engine_given = pp.query("engine", c.engine);
46  if (engine_given || c.enable) {
47  if (engines.empty()) {
48  fail(std::string(c.enable ? "erf.fire.enable = true" : "erf.fire.engine is set")
49  + ", but no fire engine is compiled into this executable: Source/FireCoupling holds "
50  "only the coupling to the atmosphere. Build with an engine directory (GNU make "
51  "FIRE_HOME, CMake ERF_FIRE_ENGINE_DIRS); Source/FireCoupling/ERF_FireEngineTemplate.H "
52  "lists what an engine provides.");
53  }
54  if (!engine_given && engines.size() > 1) {
55  std::string list;
56  for (const auto& a : engines) { list += (list.empty() ? "" : ", ") + std::string("\"") + a + "\""; }
57  fail("several fire engines are compiled in (" + list + "): set erf.fire.engine to one of them");
58  }
59  one_of("engine", c.engine, engines);
60  }
61 
62  pp.query("heat_flux_alfg", c.heat_flux_alfg);
63  pp.query("fire_atm_feedback", c.fire_atm_feedback);
64  pp.query("coupling_type", c.coupling_type);
65  one_of("coupling_type", c.coupling_type, {"passive", "lagged", "synchronous"});
66  positive("heat_flux_alfg", c.heat_flux_alfg);
67  nonneg("fire_atm_feedback", c.fire_atm_feedback); // 0 = one-way, the documented switch
68  pp.query("inject_latent", c.inject_latent);
69  c.source_mode_given = pp.query("source_mode", c.source_mode);
70  one_of("source_mode", c.source_mode, {"overwrite", "add"});
71  pp.query("heat_open_fraction", c.heat_open_fraction);
72  pp.query("heat_tendency_density", c.heat_tendency_density);
73  pp.query("heat_tendency_exner", c.heat_tendency_exner);
74  pp.query("heat_profile", c.heat_profile);
75  one_of("heat_profile", c.heat_profile, {"exponential", "bottom_cell"});
77  fail("erf.fire.heat_open_fraction places the heat along the exponential profile;"
78  " it cannot be combined with erf.fire.heat_profile = bottom_cell");
79  }
80  if (c.heat_in_bottom_cell() && pp.contains("heat_flux_alfg")) {
81  amrex::Print() << "[FIRE] WARNING: erf.fire.heat_flux_alfg is ignored with"
82  << " erf.fire.heat_profile = bottom_cell\n";
83  }
84  // The keys of the heat injection, given with passive coupling, which
85  // injects no heat: warn once per key
86  if (c.is_passive()) {
87  for (const char* k : {"heat_flux_alfg", "fire_atm_feedback", "inject_latent", "source_mode",
88  "heat_open_fraction", "heat_tendency_density", "heat_tendency_exner",
89  "heat_profile"}) {
90  if (pp.contains(k)) {
91  amrex::Print() << "[FIRE] WARNING: erf.fire." << k << " is ignored with erf.fire.coupling_type"
92  << " = passive (no heat is injected)\n";
93  }
94  }
95  }
96  pp.query("smoke_enable", c.smoke_enable);
97  pp.query("smoke_emission_factor", c.smoke_emission_factor);
98  nonneg("smoke_emission_factor", c.smoke_emission_factor);
99  // A smoke key without the smoke switch: a deck that sets the smoke switch,
100  // or the fire switch, to false explicitly is a variant switching smoke off,
101  // so warn; a deck that set neither forgot the smoke switch, so stop
102  if (!c.smoke_enable && pp.contains("smoke_emission_factor")) {
103  if (pp.contains("smoke_enable")) {
104  amrex::Print() << "[FIRE] WARNING: erf.fire.smoke_emission_factor is ignored with"
105  << " erf.fire.smoke_enable = false\n";
106  } else if (pp.contains("enable") && !c.enable) {
107  amrex::Print() << "[FIRE] WARNING: erf.fire.smoke_emission_factor is ignored with"
108  << " erf.fire.enable = false\n";
109  } else {
110  fail("erf.fire.smoke_emission_factor needs erf.fire.smoke_enable = true");
111  }
112  }
113  return c;
114 }
std::vector< std::string > fire_engine_names()
Names erf.fire.engine accepts, sorted; empty when no engine is compiled in.
Definition: ERF_FireEngineRegistry.cpp:34
ParmParse pp("prob")
amrex::Real Real
Definition: ERF_ShocInterface.H:19
Definition: ERF_FireCouplingParams.H:18
bool heat_in_bottom_cell() const
Definition: ERF_FireCouplingParams.H:62
int grid_ratio
erf.fire.grid_ratio: fire cells per atmospheric cell in x and y
Definition: ERF_FireCouplingParams.H:25
bool fire_debug
erf.fire.fire_debug: debug output of the coupling
Definition: ERF_FireCouplingParams.H:55
bool heat_tendency_exner
erf.fire.heat_tendency_exner: Exner factor of the theta tendency
Definition: ERF_FireCouplingParams.H:46
bool inject_latent
erf.fire.inject_latent: inject the engine's latent flux as vapour
Definition: ERF_FireCouplingParams.H:35
std::string engine
Definition: ERF_FireCouplingParams.H:23
int anchor_level
erf.fire.anchor_level: the level the fire grid refines, -1 = the finest
Definition: ERF_FireCouplingParams.H:27
bool heat_tendency_density
erf.fire.heat_tendency_density: density factor of the theta tendency
Definition: ERF_FireCouplingParams.H:44
bool heat_open_fraction
erf.fire.heat_open_fraction: place the heat by the engine's open fraction
Definition: ERF_FireCouplingParams.H:42
bool source_mode_given
Definition: ERF_FireCouplingParams.H:40
bool smoke_enable
erf.fire.smoke_enable: inject the smoke tracer
Definition: ERF_FireCouplingParams.H:51
amrex::Real smoke_emission_factor
erf.fire.smoke_emission_factor: kg smoke per kg fuel burned [-]
Definition: ERF_FireCouplingParams.H:53
std::string source_mode
erf.fire.source_mode: overwrite or add to the theta and vapour sources
Definition: ERF_FireCouplingParams.H:37
bool enable
erf.fire.enable: run a fire
Definition: ERF_FireCouplingParams.H:20
amrex::Real heat_flux_alfg
erf.fire.heat_flux_alfg: e-folding height of the injected heat [m]
Definition: ERF_FireCouplingParams.H:31
amrex::Real fire_atm_feedback
erf.fire.fire_atm_feedback: multiplier on the injected fluxes
Definition: ERF_FireCouplingParams.H:33
bool is_passive() const
Definition: ERF_FireCouplingParams.H:57

Referenced by ERF::initializeFire().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ anchor_level

int FireCouplingParams::anchor_level = -1

erf.fire.anchor_level: the level the fire grid refines, -1 = the finest

Referenced by read().

◆ coupling_type

std::string FireCouplingParams::coupling_type = "lagged"

erf.fire.coupling_type: passive, lagged or synchronous

Referenced by FireCoupler::add_sources(), is_lagged(), is_passive(), is_synchronous(), and read().

◆ enable

bool FireCouplingParams::enable = false

erf.fire.enable: run a fire

Referenced by read().

◆ engine

std::string FireCouplingParams::engine

erf.fire.engine: the fire engine behind the coupling (default: the only engine compiled in; required when there are several)

Referenced by read().

◆ fire_atm_feedback

amrex::Real FireCouplingParams::fire_atm_feedback = 1.0

erf.fire.fire_atm_feedback: multiplier on the injected fluxes

Referenced by FireCoupler::add_sources(), and read().

◆ fire_debug

bool FireCouplingParams::fire_debug = false

erf.fire.fire_debug: debug output of the coupling

Referenced by FireCoupler::add_sources(), FireCoupler::advance(), read(), and FireCoupler::update_flux_buffer().

◆ grid_ratio

int FireCouplingParams::grid_ratio = 5

erf.fire.grid_ratio: fire cells per atmospheric cell in x and y

Referenced by FireCoupler::initialize(), and read().

◆ heat_flux_alfg

amrex::Real FireCouplingParams::heat_flux_alfg = 45.0

erf.fire.heat_flux_alfg: e-folding height of the injected heat [m]

Referenced by FireCoupler::add_sources(), and read().

◆ heat_open_fraction

bool FireCouplingParams::heat_open_fraction = false

erf.fire.heat_open_fraction: place the heat by the engine's open fraction

Referenced by FireCoupler::add_sources(), FireCoupler::initialize(), and read().

◆ heat_profile

std::string FireCouplingParams::heat_profile = "exponential"

erf.fire.heat_profile: exponential (WRF-SFIRE, e-folding heat_flux_alfg) or bottom_cell (all of the flux into the lowest cell)

Referenced by heat_in_bottom_cell(), and read().

◆ heat_tendency_density

bool FireCouplingParams::heat_tendency_density = false

erf.fire.heat_tendency_density: density factor of the theta tendency

Referenced by FireCoupler::add_sources(), and read().

◆ heat_tendency_exner

bool FireCouplingParams::heat_tendency_exner = true

erf.fire.heat_tendency_exner: Exner factor of the theta tendency

Referenced by FireCoupler::add_sources(), and read().

◆ inject_latent

bool FireCouplingParams::inject_latent = true

erf.fire.inject_latent: inject the engine's latent flux as vapour

Referenced by FireCoupler::add_sources(), read(), and FireCoupler::update_flux_buffer().

◆ smoke_emission_factor

amrex::Real FireCouplingParams::smoke_emission_factor = 0.02

erf.fire.smoke_emission_factor: kg smoke per kg fuel burned [-]

Referenced by FireCoupler::add_sources(), and read().

◆ smoke_enable

bool FireCouplingParams::smoke_enable = false

erf.fire.smoke_enable: inject the smoke tracer

Referenced by FireCoupler::add_sources(), read(), and FireCoupler::update_flux_buffer().

◆ source_mode

std::string FireCouplingParams::source_mode = "overwrite"

erf.fire.source_mode: overwrite or add to the theta and vapour sources

Referenced by FireCoupler::add_sources(), and read().

◆ source_mode_given

bool FireCouplingParams::source_mode_given = false

erf.fire.source_mode was given in the deck (the default overwrite must be chosen explicitly when another theta source would be discarded)

Referenced by read().


The documentation for this struct was generated from the following files: