ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_FireEngineRegistry.cpp File Reference
#include <ERF_FireEngineRegistry.H>
#include <AMReX.H>
#include <algorithm>
#include <map>
Include dependency graph for ERF_FireEngineRegistry.cpp:

Functions

bool register_fire_engine (const std::string &name, FireEngineCreator creator)
 Add an engine to the registry; aborts on a name registered twice. More...
 
std::vector< std::string > fire_engine_names ()
 Names erf.fire.engine accepts, sorted; empty when no engine is compiled in. More...
 
std::unique_ptr< FireEngine > make_fire_engine (const std::string &name, const FireCouplingParams &params)
 The engine erf.fire.engine names, or nullptr when no engine has that name. More...
 

Function Documentation

◆ fire_engine_names()

std::vector<std::string> fire_engine_names ( )

Names erf.fire.engine accepts, sorted; empty when no engine is compiled in.

35 {
36  std::vector<std::string> names;
37  for (const auto& kv : fire_engine_registry()) { names.push_back(kv.first); }
38  return names; // std::map keeps them sorted
39 }

Referenced by FireCouplingParams::read().

Here is the caller graph for this function:

◆ make_fire_engine()

std::unique_ptr<FireEngine> make_fire_engine ( const std::string &  name,
const FireCouplingParams &  params 
)

The engine erf.fire.engine names, or nullptr when no engine has that name.

43 {
44  const auto& registry = fire_engine_registry();
45  const auto it = registry.find(name);
46  if (it == registry.end()) { return nullptr; }
47  return it->second(params);
48 }
std::string name
Definition: ERF_Plotfile2DCatalog.cpp:116

Referenced by ERF::initializeFire().

Here is the caller graph for this function:

◆ register_fire_engine()

bool register_fire_engine ( const std::string &  name,
FireEngineCreator  creator 
)

Add an engine to the registry; aborts on a name registered twice.

Called by ERF_REGISTER_FIRE_ENGINE; returns true so the macro can hold the result in a static variable.

20 {
21  auto& registry = fire_engine_registry();
22  if (name.empty()) {
23  amrex::Abort("[FIRE] ERF_REGISTER_FIRE_ENGINE: an engine registered an empty name");
24  }
25  if (registry.count(name) > 0) {
26  amrex::Abort("[FIRE] ERF_REGISTER_FIRE_ENGINE: two engines registered the name \"" + name
27  + "\"; each engine directory in the build must use its own name");
28  }
29  registry.emplace(name, std::move(creator));
30  return true;
31 }