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
LocalInterpCtx.hh
Go to the documentation of this file.
1// Copyright (C) 2007--2011, 2013, 2014, 2015, 2017, 2018, 2023, 2024 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;
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*/
55public:
56 LocalInterpCtx(const grid::InputGridInfo &input_grid, const Grid &internal_grid,
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 interpolation
66 std::shared_ptr<Interpolation1D> 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:290
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
Contains parameters of an input file grid.
Definition Grid.hh:68
std::shared_ptr< Grid > grid(std::shared_ptr< Context > ctx, char testname)
Definition pism.cc:176