Loading [MathJax]/extensions/tex2jax.js
PISM, A Parallel Ice Sheet Model 2.2.2-d6b3a29ca committed by Constantine Khrulev on 2025-03-28
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Context.hh
Go to the documentation of this file.
1/* Copyright (C) 2014, 2015, 2016, 2019, 2020, 2021, 2023, 2024 PISM Authors
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
20#ifndef PISM_CONTEXT_H
21#define PISM_CONTEXT_H
22
23#include <memory>
24#include <string>
25
26#include <mpi.h>
27
28namespace pism {
29
30namespace units {
31class System;
32}
33
34class Config;
35class EnthalpyConverter;
36class Time;
37class Profiling;
38class Logger;
39
40class Context {
41public:
42 Context(MPI_Comm c, std::shared_ptr<units::System> sys, std::shared_ptr<Config> conf,
43 std::shared_ptr<EnthalpyConverter> EC, std::shared_ptr<Time> t,
44 std::shared_ptr<Logger> log, const std::string &p);
45 ~Context();
46
47 MPI_Comm com() const;
48 int size() const;
49 int rank() const;
50 std::shared_ptr<units::System> unit_system() const;
51 std::shared_ptr<const Config> config() const;
52 std::shared_ptr<EnthalpyConverter> enthalpy_converter() const;
53 std::shared_ptr<const Time> time() const;
54 const std::string& prefix() const;
55 const Profiling& profiling() const;
56
57 std::shared_ptr<const Logger> log() const;
58 std::shared_ptr<Logger> log();
59
60 std::shared_ptr<Config> config();
61 std::shared_ptr<Time> time();
62
63private:
64 class Impl;
66 // disable copying and assignments
67 Context(const Context& other);
69};
70
71//! Create a default context using options.
72std::shared_ptr<Context> context_from_options(MPI_Comm com,
73 const std::string &prefix,
74 bool print = false);
75
76} // end of namespace pism
77
78#endif /* PISM_CONTEXT_H */
Context & operator=(const Context &)
MPI_Comm com() const
Definition Context.cc:65
Context(const Context &other)
Impl * m_impl
Definition Context.hh:65
std::shared_ptr< const Config > config() const
Definition Context.cc:89
const std::string & prefix() const
Definition Context.cc:105
int size() const
Definition Context.cc:69
const Profiling & profiling() const
Definition Context.cc:109
std::shared_ptr< const Logger > log() const
Definition Context.cc:113
std::shared_ptr< units::System > unit_system() const
Definition Context.cc:81
int rank() const
Definition Context.cc:75
std::shared_ptr< const Time > time() const
Definition Context.cc:101
std::shared_ptr< EnthalpyConverter > enthalpy_converter() const
Definition Context.cc:93
std::shared_ptr< Context > context_from_options(MPI_Comm com, const std::string &prefix, bool print)
Create a default context using options.
Definition Context.cc:121