679 * @section function_pointer Function pointer
typedef
680 * All these methods sharing the same prototype, a
generic function pointer type can be defined in the
Stability class:
685 * @section model_map Model map
686 * Once an alternative implementation has been written (and properly declared in the
"StabilityAlgorithms.h" header %file), it must be
"registered" in the model map. In our exmaple,
this map
687 * is defined in the
"Stability.h" header %file:
689 *
static std::map<std::string, StabMemFn> mapHandHardness;
691 * and statically filled in the initStaticData() method as following:
695 * mapHandHardness[
"MONTI"] = &StabilityAlgorithms::setHandHardnessMONTI;
696 * mapHandHardness[
"BELLAIRE"] = &StabilityAlgorithms::setHandHardnessBELLAIRE;
697 * mapHandHardness[
"ASARC"] = &StabilityAlgorithms::setHandHardnessASARC;
701 * This way of fillinf the map ensures that it will be initialized only once and
for all, making it consistent and efficient.
703 * @section model_user_choice User model configuration
704 * The user selection of model must be connected with the proper model implementation. The user selects the model he wants through a key in his
705 * configuration file. We need to read
this key and activate the proper implementation, knowing that the proper key <-> implementation matching is done
708 * cfg.getValue(
"HARDNESS_PARAMETERIZATION",
"SnowpackAdvanced", hardness_parameterization);
709 * map<string, StabMemFn>::const_iterator it1 = mapHandHardness.find(hardness_parameterization);
710 *
if (it1 == mapHandHardness.end())
throw InvalidArgumentException(
"Unknown hardness parameterization: "+hardness_parameterization, AT);
712 * This means that in the section
"SnowpackAdvanced" of his ini file, the key
"HARDNESS_PARAMETERIZATION" must contain one of the strings given in the mapHandHardness
713 * above (ie. either
"DEFAULT" or
"MONTI" or
"ASARC").
715 * @section calling_model Model call
716 * Finally, the process model has to be called where needed, so each time the hand hardness has to be computed, the call becomes:
718 * hardness = (mapHandHardness[hardness_parameterization]))(EMS[e], hoar_density_buried);
double(* StabMemFn)(const ElementData &, const double &)
Definition: Stability.h:31
ELEMENT DATA used as a pointer in the SnowStation structure NOTE on M below: this is the mass of an e...
Definition: DataClasses.h:285
This class contains the stability routines for the snowpack model. Stability is found for each LAYER ...
Definition: Stability.h:49