PISM, A Parallel Ice Sheet Model 2.3.0-79cae578d committed by Constantine Khrulev on 2026-03-22
Loading...
Searching...
No Matches
FlowLawFactory.cc
Go to the documentation of this file.
1// Copyright (C) 2009--2018, 2023, 2025 Jed Brown, Ed Bueler and Constantine Khroulev
2//
3// This file is part of PISM.
4//
5// PISM is free software; you can redistribute it and/or modify it under the
6// terms of the GNU General Public License as published by the Free Software
7// Foundation; either version 3 of the License, or (at your option) any later
8// version.
9//
10// PISM is distributed in the hope that it will be useful, but WITHOUT ANY
11// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13// details.
14//
15// You should have received a copy of the GNU General Public License
16// along with PISM; if not, write to the Free Software
17// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19#include <cassert>
20#include <string>
21
22#include "pism/rheology/FlowLawFactory.hh"
23#include "pism/util/Config.hh"
24#include "pism/util/error_handling.hh"
25
26#include "pism/rheology/IsothermalGlen.hh"
27#include "pism/rheology/PatersonBudd.hh"
28#include "pism/rheology/GPBLD.hh"
29#include "pism/rheology/Hooke.hh"
30#include "pism/rheology/PatersonBuddCold.hh"
31#include "pism/rheology/PatersonBuddWarm.hh"
32#include "pism/rheology/GoldsbyKohlstedt.hh"
33
34namespace pism {
35namespace rheology {
36
37using ECPtr = std::shared_ptr<EnthalpyConverter>;
38
39FlowLaw *create_isothermal_glen(double exponent, const Config &config, ECPtr EC) {
40 return new (IsothermalGlen)(exponent, config, EC);
41}
42
43FlowLaw *create_pb(double exponent, const Config &config, ECPtr EC) {
44 return new (PatersonBudd)(exponent, config, EC);
45}
46
47FlowLaw *create_gpbld(double exponent, const Config &config, ECPtr EC) {
48 return new (GPBLD)(exponent, config, EC);
49}
50
51FlowLaw *create_hooke(double exponent, const Config &config, ECPtr EC) {
52 return new (Hooke)(exponent, config, EC);
53}
54
55FlowLaw *create_arr(double exponent, const Config &config, ECPtr EC) {
56 return new (PatersonBuddCold)(exponent, config, EC);
57}
58
59FlowLaw *create_arrwarm(double exponent, const Config &config, ECPtr EC) {
60 return new (PatersonBuddWarm)(exponent, config, EC);
61}
62
63FlowLaw *create_goldsby_kohlstedt(double exponent, const Config &config, ECPtr EC) {
64 return new (GoldsbyKohlstedt)(exponent, config, EC);
65}
66
67FlowLawFactory::FlowLawFactory(std::shared_ptr<const Config> conf,
68 std::shared_ptr<EnthalpyConverter> EC)
69 : m_config(conf), m_EC(EC) {
70
72 { ICE_PB, create_pb },
78}
79
80void FlowLawFactory::add(const std::string &name, FlowLawCreator icreate) {
81 m_flow_laws[name] = icreate;
82}
83
84void FlowLawFactory::remove(const std::string &name) {
85 m_flow_laws.erase(name);
86}
87
88std::shared_ptr<FlowLaw> FlowLawFactory::create(const std::string &type_name, double exponent) {
89 // find the function that can create selected flow law:
90 if (m_flow_laws[type_name] == nullptr) {
92 PISM_ERROR_LOCATION, "Selected ice flow law \"%s\" is not available", type_name.c_str());
93 }
94
95 auto r = m_flow_laws[type_name];
96
97 // create an FlowLaw instance:
98 return std::shared_ptr<FlowLaw>((*r)(exponent, *m_config, m_EC));
99}
100
101} // end of namespace rheology
102} // end of namespace pism
#define ICE_PB
#define ICE_GOLDSBY_KOHLSTEDT
#define ICE_HOOKE
#define ICE_ARR
#define ICE_ARRWARM
#define ICE_GPBLD
#define ICE_ISOTHERMAL_GLEN
A class for storing and accessing PISM configuration flags and parameters.
Definition Config.hh:56
static RuntimeError formatted(const ErrorLocation &location, const char format[],...) __attribute__((format(printf
build a RuntimeError with a formatted message
std::shared_ptr< const Config > m_config
std::map< std::string, FlowLawCreator > m_flow_laws
void remove(const std::string &name)
std::shared_ptr< FlowLaw > create(const std::string &type_name, double exponent)
FlowLawFactory(std::shared_ptr< const Config > conf, std::shared_ptr< EnthalpyConverter > my_EC)
std::shared_ptr< EnthalpyConverter > m_EC
void add(const std::string &name, FlowLawCreator)
Glen (1955) and Paterson-Budd (1982) flow law with additional water fraction factor from Lliboutry & ...
Definition GPBLD.hh:33
A hybrid of Goldsby-Kohlstedt (2001) ice (constitutive form) and Paterson-Budd (1982)-Glen (viscosity...
The Hooke flow law.
Definition Hooke.hh:29
Isothermal Glen ice allowing extra customization.
Cold case of Paterson-Budd.
Warm case of Paterson-Budd.
Derived class of FlowLaw for Paterson-Budd (1982)-Glen ice.
#define PISM_ERROR_LOCATION
FlowLaw * create_hooke(double exponent, const Config &config, ECPtr EC)
std::shared_ptr< EnthalpyConverter > ECPtr
FlowLaw *(* FlowLawCreator)(double, const Config &, std::shared_ptr< EnthalpyConverter >)
FlowLaw * create_isothermal_glen(double exponent, const Config &config, ECPtr EC)
FlowLaw * create_goldsby_kohlstedt(double exponent, const Config &config, ECPtr EC)
FlowLaw * create_arrwarm(double exponent, const Config &config, ECPtr EC)
FlowLaw * create_arr(double exponent, const Config &config, ECPtr EC)
FlowLaw * create_pb(double exponent, const Config &config, ECPtr EC)
FlowLaw * create_gpbld(double exponent, const Config &config, ECPtr EC)