SNOWPACK  SNOWPACK-3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MainPage.h
Go to the documentation of this file.
1 /***********************************************************************************/
2 /* Copyright 2009-2010 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
3 /***********************************************************************************/
4 /* This file is part of SNOWPACK.
5  SNOWPACK is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  SNOWPACK is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with SNOWPACK. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef MAINPAGE_H
19 #define MAINPAGE_H
20 
21 //groups);
536  * @endcode
537  *
538  * @section function_pointer Function pointer typedef
539  * All these methods sharing the same prototype, a generic function pointer type can be defined in the Stability class:
540  * @code
541  * typedef double (*StabMemFn)(const ElementData&, const double&);
542  * @endcode
543  *
544  * @section model_map Model map
545  * 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
546  * is defined in the "Stability.h" header %file:
547  * @code
548  * static std::map<std::string, StabMemFn> mapHandHardness;
549  * @endcode
550  * and statically filled in the initStaticData() method as following:
551  * @code
552  * const bool Stability::__init = Stability::initStaticData();
553  * bool Stability::initStaticData() {
554  * mapHandHardness["MONTI"] = &StabilityAlgorithms::setHandHardnessMONTI;
555  * mapHandHardness["BELLAIRE"] = &StabilityAlgorithms::setHandHardnessBELLAIRE;
556  * mapHandHardness["ASARC"] = &StabilityAlgorithms::setHandHardnessASARC;
557  * return true;
558  * }
559  * @endcode
560  * This way of fillinf the map ensures that it will be initialized only once and for all, making it consistent and efficient.
561  *
562  * @section model_user_choice User model configuration
563  * 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
564  * configuration file. We need to read this key and activate the proper implementation, knowing that the proper key <-> implementation matching is done
565  * through the map:
566  * @code
567  * cfg.getValue("HARDNESS_PARAMETERIZATION", "SnowpackAdvanced", hardness_parameterization);
568  * map<string, StabMemFn>::const_iterator it1 = mapHandHardness.find(hardness_parameterization);
569  * if (it1 == mapHandHardness.end()) throw InvalidArgumentException("Unknown hardness parameterization: "+hardness_parameterization, AT);
570  * @endcode
571  * 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
572  * above (ie. either "DEFAULT" or "MONTI" or "ASARC").
573  *
574  * @section calling_model Model call
575  * Finally, the process model has to be called where needed, so each time the hand hardness has to be computed, the call becomes:
576  * @code
577  * hardness = (mapHandHardness[hardness_parameterization]))(EMS[e], hoar_density_buried);
578  * @endcode
579  *
580  */
581 
582 #endif
583 
584 
585 
586 
587 
588 
589 
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:251
This class contains the stability routines for the snowpack model. Stability is found for each LAYER ...
Definition: Stability.h:49