20 #include "pism/util/ColumnInterpolation.hh"
27 const std::vector<double> &new_z_fine)
28 : m_z_fine(new_z_fine), m_z_coarse(new_z_coarse) {
33 unsigned int k_max_result)
const {
34 std::vector<double> result(
Mz_fine());
40 unsigned int k_max_result,
41 double *result)
const {
50 double *result)
const {
51 const unsigned int Mzfine =
Mz_fine();
52 const unsigned int Mzcoarse =
Mz_coarse();
54 for (
unsigned int k = 0;
k < Mzfine; ++
k) {
55 if (
k > k_max_result) {
63 if (m == Mzcoarse - 1) {
64 result[
k] = input[Mzcoarse - 1];
69 result[
k] = input[m] + incr * (input[m + 1] - input[m]);
74 double *result)
const {
75 unsigned int k = 0, m = 0;
77 for (m = 0; m < Mz - 2 and
k <= k_max_result; ++m) {
90 d1 = (f1 - f0) * dz_inv,
91 d2 = (f2 - f0) * dz1_inv,
92 b = (
d2 - d1) * dz2_inv,
93 a = d1 - b * (z1 -
z0),
96 for (;
m_z_fine[
k] < z1 and
k <= k_max_result; ++
k) {
99 result[
k] = s * (a + b * s) + c;
111 lambda = (f1 - f0) / (z1 -
z0);
119 const double f0 = input[Mz - 1];
120 for (;
k <= k_max_result; ++
k) {
134 for (
unsigned int k = 0;
k < N - 1; ++
k) {
138 result[
k] = input[m] + increment * (input[m + 1] - input[m]);
180 const std::vector<double>& z_output) {
181 std::vector<unsigned int> result(z_output.size());
184 for (
unsigned int k = 0;
k < z_output.size(); ++
k) {
186 if (z_output[
k] <= z_input.front()) {
191 if (z_output[
k] >= z_input.back()) {
192 result[
k] = z_input.size() - 1;
196 while (z_input[m + 1] < z_output[
k]) {
223 const double eps = 1.0e-8;
230 for (
unsigned int m = 0; m < N; ++m) {
void coarse_to_fine_quadratic(const double *input, unsigned int ks, double *result) const
std::vector< double > m_z_fine
std::vector< double > m_z_coarse
unsigned int Mz_fine() const
const std::vector< double > & z_coarse() const
void coarse_to_fine_linear(const double *input, unsigned int ks, double *result) const
std::vector< unsigned int > m_coarse2fine
std::vector< double > m_constants
void init_interpolation()
unsigned int Mz_coarse() const
std::vector< unsigned int > m_fine2coarse
void coarse_to_fine(const double *input, unsigned int ks, double *result) const
ColumnInterpolation(const std::vector< double > &z_coarse, const std::vector< double > &z_fine)
const std::vector< double > & z_fine() const
bool m_use_linear_interpolation
void fine_to_coarse(const double *input, double *result) const
double max(const array::Scalar &input)
Finds maximum over all the values in an array::Scalar object. Ignores ghosts.
double min(const array::Scalar &input)
Finds minimum over all the values in an array::Scalar object. Ignores ghosts.
static std::vector< unsigned int > init_interpolation_indexes(const std::vector< double > &z_input, const std::vector< double > &z_output)