PISM, A Parallel Ice Sheet Model  stable v2.1.1 committed by Constantine Khrulev on 2024-12-04 13:36:58 -0900
LocalInterpCtx.hh
Go to the documentation of this file.
1 // Copyright (C) 2007--2011, 2013, 2014, 2015, 2017, 2018, 2023 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 #ifndef PISM_LOCALINTERPCTX_H
20 #define PISM_LOCALINTERPCTX_H
21 
22 #include <array>
23 #include <vector>
24 #include <memory>
25 
26 namespace pism {
27 
28 enum InterpolationType : int;
29 class Interpolation;
30 
31 class Grid;
32 
33 namespace grid {
34 class InputGridInfo;
35 }
36 
37 //! The "local interpolation context" describes the processor's part of the source NetCDF
38 //! file (for regridding).
39 /*! The local interpolation context contains the details of how the processor's block of
40  the new computational domain fits into the domain of the netCDF file. Note that each
41  vertical column of the grid is owned by exactly one processor.
42 
43  For any particular dimension, we have a new computational domain \f$[a,b]\f$ with
44  spacing \f$h\f$ so there are \f$n = (b - a) / h\f$ interior cells, indexed by \f$\{i_0, \dots, i_n\}\f$.
45  The local processor owns a range \f$\{i_m, \dots, i_{m'}\}\f$. Suppose the netCDF file has
46  domain \f$[A,B]\f$, spacing \f$H\f$, and \f$N = (B - A) / H\f$ cells. In order to interpolate
47  onto these points, we need the indices \f$\{I_m, \dots, I_{m'}\}\f$ of the netCDF file so that
48 
49  \f[ [x(i_m), x(i_{m'})] \quad \text{is a subset of} \quad [x(I_m), x(I_{m'})] \f]
50 
51  The arrays `start` and `count` have 4 integer entries, corresponding to the dimensions
52  `t, x, y, z(zb)`.
53 */
55 public:
56  LocalInterpCtx(const grid::InputGridInfo &input_grid, const Grid &internal_grid,
57  InterpolationType type);
58  LocalInterpCtx(const grid::InputGridInfo &input_grid, const Grid &internal_grid,
59  const std::vector<double> &z_internal, InterpolationType type);
60 
61  int buffer_size() const;
62 
63  // Indices in netCDF file.
64  std::array<int, 4> start, count;
65  // indexes and coefficients for 1D linear interpolation
66  std::shared_ptr<Interpolation> x, y, z;
67 };
68 
69 } // end of namespace pism
70 
71 #endif // PISM_LOCALINTERPCTX_H
Describes the PISM grid and the distribution of data across processors.
Definition: Grid.hh:282
std::array< int, 4 > count
std::array< int, 4 > start
LocalInterpCtx(const grid::InputGridInfo &input_grid, const Grid &internal_grid, InterpolationType type)
std::shared_ptr< Interpolation > y
std::shared_ptr< Interpolation > z
std::shared_ptr< Interpolation > x
Contains parameters of an input file grid.
Definition: Grid.hh:65
InterpolationType