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