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
Array_impl.hh
Go to the documentation of this file.
1/* Copyright (C) 2020, 2021, 2022, 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#ifndef PISM_ARRAY_IMPL_HH
20#define PISM_ARRAY_IMPL_HH
21
22#include <map>
23#include <memory>
24#include <string>
25#include <vector>
26
27#include "pism/util/array/Array.hh"
28
29#include <gsl/gsl_interp.h>
30
31#include "pism/util/petscwrappers/Vec.hh"
32#include "pism/util/Interpolation1D.hh"
33#include "pism/util/VariableMetadata.hh"
34
35namespace pism {
36namespace array {
37
39 Impl() {
41
42 da.reset();
43
45 dof = 1;
47
48 ghosted = true;
49
50 report_range = true;
51
52 name = "uninitialized variable";
53
54 zlevels = {0.0};
55
56 state_counter = 0;
58
59 bsearch_accel = nullptr;
60 }
61 //! If true, report range when regridding.
63
64 //! The array itself
65 //!
66 //! Note: do not access this directly (via `m_impl->v`). Use `vec()` instead.
68
69 //! Name of the field. In general this is *not* the name of the corresponding NetCDF
70 //! variable.
71 std::string name;
72
73 //! Metadata (NetCDF variable attributes)
74 std::vector<SpatialVariableMetadata> metadata;
75
76 //! The computational grid
77 std::shared_ptr<const Grid> grid;
78
79 //! number of "degrees of freedom" per grid point
80 unsigned int dof;
81
82 //! stencil width supported by the DA
83 unsigned int da_stencil_width;
84
85 //! true if this Array is ghosted
86 bool ghosted;
87
88 //! distributed mesh manager (DM)
89 //!
90 //! Note: do not access this directly (via `m_impl->da`). Use `dm()` instead.
91 std::shared_ptr<petsc::DM> da;
92
93 //! If true, use DMDAVecGetArrayDOF() in begin_access()
95
96 //! Map plane viewers. It is a map because a temporary Array can be used to view
97 //! different quantities
98 std::map<std::string,std::shared_ptr<petsc::Viewer> > map_viewers;
99
100 // used in begin_access() and end_access()
102
103 //! Internal array::Array "revision number"
105
106 // 2D Interpolation type (used by regrid())
108
109 //! Vertical levels (for 3D fields)
110 std::vector<double> zlevels;
111
112 // binary search accelerator (used for interpolation in a column in 3D fields)
113 gsl_interp_accel *bsearch_accel;
114};
115
116void global_to_local(petsc::DM &dm, Vec source, Vec destination);
117
118// set default value or stop with an error message (during regridding)
119void set_default_value_or_stop(const VariableMetadata &variable, io::Default default_value,
120 const Logger &log, Vec output);
121
122} // end of namespace array
123} // end of namespace pism
124
125#endif /* PISM_ARRAY_IMPL_HH */
A basic logging class.
Definition Logger.hh:40
void global_to_local(petsc::DM &dm, Vec source, Vec destination)
Definition Array.cc:53
void set_default_value_or_stop(const VariableMetadata &variable, io::Default default_value, const Logger &log, Vec output)
Definition Array.cc:358
bool begin_access_use_dof
If true, use DMDAVecGetArrayDOF() in begin_access()
Definition Array_impl.hh:94
int state_counter
Internal array::Array "revision number".
bool ghosted
true if this Array is ghosted
Definition Array_impl.hh:86
std::shared_ptr< const Grid > grid
The computational grid.
Definition Array_impl.hh:77
InterpolationType interpolation_type
std::map< std::string, std::shared_ptr< petsc::Viewer > > map_viewers
Definition Array_impl.hh:98
bool report_range
If true, report range when regridding.
Definition Array_impl.hh:62
gsl_interp_accel * bsearch_accel
unsigned int da_stencil_width
stencil width supported by the DA
Definition Array_impl.hh:83
std::vector< SpatialVariableMetadata > metadata
Metadata (NetCDF variable attributes)
Definition Array_impl.hh:74
std::vector< double > zlevels
Vertical levels (for 3D fields)
std::shared_ptr< petsc::DM > da
Definition Array_impl.hh:91
unsigned int dof
number of "degrees of freedom" per grid point
Definition Array_impl.hh:80