Peano 4
Loading...
Searching...
No Matches
NetCDFHelper.cpp
Go to the documentation of this file.
1#include "NetCDFHelper.hpp"
2double applications::exahype2::swe::parser::NetCDFHelper::transformIndexSimulationToCDFRange(double i_z, double i_nZ, double i_min_z_cdf, double i_max_z_cdf){
3 // TODO with an offset defined, min_z should probably be adjusted
4 double min_z = 0.0;
5 double max_z = i_nZ;
6 double m = ((i_max_z_cdf - i_min_z_cdf) / (max_z - min_z));
7 double b = i_min_z_cdf - m * min_z; // correction for y-intercept in index interpolation
8
9 double ret = m * i_z + b;
10
11 return ret;
12}
13
14int applications::exahype2::swe::parser::NetCDFHelper::transformIndexCDFRangeToArray(double i_x, double i_y, double i_min_x, double i_min_y, double i_max_x, double i_max_y, size_t i_xDim, size_t i_yDim){
15 int x_index;
16 int y_index;
17 {
18 size_t maxIndex = (i_xDim - 1);
19 // Mesh width of data in x dimension
20 double dx = ((i_min_x - i_max_x) / i_xDim);
21 // f(0) = b
22 double b = i_min_x / dx;
23 double m = maxIndex / (i_max_x - i_min_x);
24 x_index = floor(m * i_x + b);
25 }
26 {
27 size_t maxIndex = (i_yDim - 1);
28 // Mesh width of data in y dimension
29 double dy = ((i_min_y - i_max_y) / i_yDim);
30 // f(0) = b
31 double b = i_min_y / dy;
32 double m = maxIndex / (i_max_y - i_min_y);
33 y_index = floor(m * i_y + b);
34 }
35 return y_index * i_xDim + x_index;
36}
we integrate over each cell and then take the sum across each of the cells We also consider the terms that enter the f$ so we are integrating with f$ phi_k phi_k dx
int transformIndexCDFRangeToArray(double i_x, double i_y, double i_min_x, double i_min_y, double i_max_x, double i_max_y, size_t i_xDim, size_t i_yDim)
Transforms coordinate pair from netCDF plane to 1D row-wise array index.
double transformIndexSimulationToCDFRange(double i_z, double i_nZ, double i_min_z_cdf, double i_max_z_cdf)
Transforms coordinate from simulation plane to netCDF plane.