PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
Context.hh
Go to the documentation of this file.
1 /* Copyright (C) 2014, 2015, 2016, 2019, 2020, 2021, 2023 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 
28 namespace pism {
29 
30 namespace units {
31 class System;
32 }
33 
34 class Config;
35 class EnthalpyConverter;
36 class Time;
37 class Profiling;
38 class Logger;
39 
40 class Context {
41 public:
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 
63  int pio_iosys_id() const;
64 private:
65  class Impl;
67  // disable copying and assignments
68  Context(const Context& other);
70 };
71 
72 //! Create a default context using options.
73 std::shared_ptr<Context> context_from_options(MPI_Comm com,
74  const std::string &prefix,
75  bool print = false);
76 
77 } // end of namespace pism
78 
79 #endif /* PISM_CONTEXT_H */
MPI_Comm com() const
Definition: Context.cc:81
Context(const Context &other)
Context(MPI_Comm c, std::shared_ptr< units::System > sys, std::shared_ptr< Config > conf, std::shared_ptr< EnthalpyConverter > EC, std::shared_ptr< Time > t, std::shared_ptr< Logger > log, const std::string &p)
Definition: Context.cc:61
Impl * m_impl
Definition: Context.hh:65
std::shared_ptr< const Config > config() const
Definition: Context.cc:105
int pio_iosys_id() const
Definition: Context.cc:140
const std::string & prefix() const
Definition: Context.cc:121
int size() const
Definition: Context.cc:85
const Profiling & profiling() const
Definition: Context.cc:125
Context & operator=(const Context &)
std::shared_ptr< const Logger > log() const
Definition: Context.cc:129
std::shared_ptr< units::System > unit_system() const
Definition: Context.cc:97
int rank() const
Definition: Context.cc:91
std::shared_ptr< const Time > time() const
Definition: Context.cc:117
std::shared_ptr< EnthalpyConverter > enthalpy_converter() const
Definition: Context.cc:109
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:170