2828#include " world_builder/assert.h"
2929#include " world_builder/coordinate_system.h"
3030#include " world_builder/nan.h"
31+ #include " world_builder/objects/natural_coordinate.h"
3132#include " world_builder/point.h"
3233#include " world_builder/utilities.h"
3334#include " world_builder/world.h"
@@ -921,13 +922,13 @@ int main(int argc, char **argv)
921922
922923 const double dlong = opening_angle_long_rad / static_cast <double >(n_cell_x);
923924 const double dlat = dim == 3 ? opening_angle_lat_rad / static_cast <double >(n_cell_y) : 0 .;
924- const double lr = outer_radius - inner_radius;
925- const double dr = lr / static_cast <double >(n_cell_z);
926925
927926 grid_x.resize (n_p);
928927 grid_y.resize (dim == 3 ? n_p : 0 );
929928 grid_z.resize (n_p);
930929 grid_depth.resize (n_p);
930+ std::vector<double > domain_height (n_p);
931+ std::vector<double > cell_height (n_p);
931932
932933 std::cout << " [4/6] Building the grid: stage 1 of 3 \r " ;
933934 std::cout.flush ();
@@ -938,8 +939,10 @@ int main(int argc, char **argv)
938939 for (size_t j = 1 ; j <= n_cell_z + 1 ; ++j)
939940 {
940941 grid_x[counter] = x_min + (static_cast <double >(i) - 1.0 ) * dlong;
941- grid_z[counter] = inner_radius + (static_cast <double >(j) - 1.0 ) * dr;
942- grid_depth[counter] = lr - (static_cast <double >(j) - 1.0 ) * dr;
942+ domain_height [counter]= outer_radius - inner_radius;
943+ cell_height[counter] = domain_height[counter] / static_cast <double >(n_cell_z);
944+ grid_z[counter] = inner_radius + (static_cast <double >(j) - 1.0 ) * cell_height[counter];
945+ grid_depth[counter] = domain_height[counter] - (static_cast <double >(j) - 1.0 ) * cell_height[counter];
943946 counter++;
944947 }
945948 }
@@ -953,8 +956,16 @@ int main(int argc, char **argv)
953956 {
954957 grid_x[counter] = x_min + (static_cast <double >(i) - 1.0 ) * dlong;
955958 grid_y[counter] = y_min + (static_cast <double >(j) - 1.0 ) * dlat;
956- grid_z[counter] = inner_radius + (static_cast <double >(k) - 1.0 ) * dr;
957- grid_depth[counter] = lr - (static_cast <double >(k) - 1.0 ) * dr;
959+ // todo: actual position if that is what we decide on?
960+ std::vector<std::array<unsigned ,3 >> properties;
961+ properties.push_back ({{6 ,0 ,0 }}); // topography
962+ const std::array<double ,3 > coords = {{grid_x[counter], grid_y[counter],inner_radius}};
963+ world->properties (coords, 0 ,properties);
964+ const double topography = world->properties (coords, 0 ,properties)[0 ];
965+ domain_height[counter] = outer_radius + topography - inner_radius;
966+ cell_height[counter] = domain_height[counter] / static_cast <double >(n_cell_z);
967+ grid_z[counter] = inner_radius + (static_cast <double >(k) - 1.0 ) * cell_height[counter];
968+ grid_depth[counter] = domain_height[counter] - (static_cast <double >(k) - 1.0 ) * cell_height[counter];
958969 counter++;
959970 }
960971 }
@@ -970,50 +981,50 @@ int main(int argc, char **argv)
970981 // position 0 of this cell
971982 grid_x[counter] = x_min + static_cast <double >(i) * dlong;
972983 grid_y[counter] = y_min + static_cast <double >(j) * dlat;
973- grid_z[counter] = inner_radius + static_cast <double >(k) * dr ;
974- grid_depth[counter] = lr - static_cast <double >(k) * dr ;
984+ grid_z[counter] = inner_radius + static_cast <double >(k) * cell_height[counter] ;
985+ grid_depth[counter] = domain_height[counter] - static_cast <double >(k) * cell_height[counter] ;
975986 counter++;
976987 // position 1 of this cell
977988 grid_x[counter] = x_min + (static_cast <double >(i) + 1.0 ) * dlong;
978989 grid_y[counter] = y_min + static_cast <double >(j) * dlat;
979- grid_z[counter] = inner_radius + static_cast <double >(k) * dr ;
980- grid_depth[counter] = lr - static_cast <double >(k) * dr ;
990+ grid_z[counter] = inner_radius + static_cast <double >(k) * cell_height[counter] ;
991+ grid_depth[counter] = domain_height[counter] - static_cast <double >(k) * cell_height[counter] ;
981992 counter++;
982993 // position 2 of this cell
983994 grid_x[counter] = x_min + (static_cast <double >(i) + 1.0 ) * dlong;
984995 grid_y[counter] = y_min + (static_cast <double >(j) + 1.0 ) * dlat;
985- grid_z[counter] = inner_radius + static_cast <double >(k) * dr ;
986- grid_depth[counter] = lr - static_cast <double >(k) * dr ;
996+ grid_z[counter] = inner_radius + static_cast <double >(k) * cell_height[counter] ;
997+ grid_depth[counter] = domain_height[counter] - static_cast <double >(k) * cell_height[counter] ;
987998 counter++;
988999 // position 3 of this cell
9891000 grid_x[counter] = x_min + static_cast <double >(i) * dlong;
9901001 grid_y[counter] = y_min + (static_cast <double >(j) + 1.0 ) * dlat;
991- grid_z[counter] = inner_radius + static_cast <double >(k) * dr ;
992- grid_depth[counter] = lr - static_cast <double >(k) * dr ;
1002+ grid_z[counter] = inner_radius + static_cast <double >(k) * cell_height[counter] ;
1003+ grid_depth[counter] = domain_height[counter] - static_cast <double >(k) * cell_height[counter] ;
9931004 counter++;
9941005 // position 0 of this cell
9951006 grid_x[counter] = x_min + static_cast <double >(i) * dlong;
9961007 grid_y[counter] = y_min + static_cast <double >(j) * dlat;
997- grid_z[counter] = inner_radius + (static_cast <double >(k) + 1.0 ) * dr ;
998- grid_depth[counter] = lr - (static_cast <double >(k) + 1.0 ) * dr ;
1008+ grid_z[counter] = inner_radius + (static_cast <double >(k) + 1.0 ) * cell_height[counter] ;
1009+ grid_depth[counter] = domain_height[counter] - (static_cast <double >(k) + 1.0 ) * cell_height[counter] ;
9991010 counter++;
10001011 // position 1 of this cell
10011012 grid_x[counter] = x_min + (static_cast <double >(i) + 1.0 ) * dlong;
10021013 grid_y[counter] = y_min + static_cast <double >(j) * dlat;
1003- grid_z[counter] = inner_radius + (static_cast <double >(k) + 1.0 ) * dr ;
1004- grid_depth[counter] = lr - (static_cast <double >(k) + 1.0 ) * dr ;
1014+ grid_z[counter] = inner_radius + (static_cast <double >(k) + 1.0 ) * cell_height[counter] ;
1015+ grid_depth[counter] = domain_height[counter] - (static_cast <double >(k) + 1.0 ) * cell_height[counter] ;
10051016 counter++;
10061017 // position 2 of this cell
10071018 grid_x[counter] = x_min + (static_cast <double >(i) + 1.0 ) * dlong;
10081019 grid_y[counter] = y_min + (static_cast <double >(j) + 1.0 ) * dlat;
1009- grid_z[counter] = inner_radius + (static_cast <double >(k) + 1.0 ) * dr ;
1010- grid_depth[counter] = lr - (static_cast <double >(k) + 1.0 ) * dr ;
1020+ grid_z[counter] = inner_radius + (static_cast <double >(k) + 1.0 ) * cell_height[counter] ;
1021+ grid_depth[counter] = domain_height[counter] - (static_cast <double >(k) + 1.0 ) * cell_height[counter] ;
10111022 counter++;
10121023 // position 3 of this cell
10131024 grid_x[counter] = x_min + static_cast <double >(i) * dlong;
10141025 grid_y[counter] = y_min + (static_cast <double >(j) + 1.0 ) * dlat;
1015- grid_z[counter] = inner_radius + (static_cast <double >(k) + 1.0 ) * dr ;
1016- grid_depth[counter] = lr - (static_cast <double >(k) + 1.0 ) * dr ;
1026+ grid_z[counter] = inner_radius + (static_cast <double >(k) + 1.0 ) * cell_height[counter] ;
1027+ grid_depth[counter] = domain_height[counter] - (static_cast <double >(k) + 1.0 ) * cell_height[counter] ;
10171028 WBAssert (counter < n_p, " Assert counter smaller then n_P: counter = " << counter << " , n_p = " << n_p);
10181029 counter++;
10191030 }
@@ -1567,6 +1578,7 @@ int main(int argc, char **argv)
15671578 std::vector<vtu11::DataSetInfo> dataSetInfo
15681579 {
15691580 { " Depth" , vtu11::DataSetType::PointData, 1 },
1581+ { " Topography" , vtu11::DataSetType::PointData, 1 },
15701582 { " Temperature" , vtu11::DataSetType::PointData, 1 },
15711583 { " velocity" , vtu11::DataSetType::PointData, 3 },
15721584 { " Tag" , vtu11::DataSetType::PointData, 1 },
@@ -1580,6 +1592,7 @@ int main(int argc, char **argv)
15801592 std::cout.flush ();
15811593
15821594 std::vector<std::array<unsigned ,3 >> properties;
1595+ properties.push_back ({{6 ,0 ,0 }}); // topography
15831596 properties.push_back ({{1 ,0 ,0 }}); // temperature
15841597
15851598 properties.push_back ({{5 ,0 ,0 }}); // velocity
@@ -1591,13 +1604,14 @@ int main(int argc, char **argv)
15911604
15921605
15931606 // compute temperature
1594- std::vector<vtu11::DataSetData> data_set (4 +compositions);
1607+ std::vector<vtu11::DataSetData> data_set (5 +compositions);
15951608 data_set[0 ] = grid_depth;
15961609 data_set[1 ].resize (n_p);
1597- data_set[2 ].resize (n_p*3 );
1598- data_set[3 ].resize (n_p);
1610+ data_set[2 ].resize (n_p);
1611+ data_set[3 ].resize (n_p*3 );
1612+ data_set[4 ].resize (n_p);
15991613 for (size_t c = 0 ; c < compositions; ++c)
1600- data_set[4 +c].resize (n_p);
1614+ data_set[5 +c].resize (n_p);
16011615
16021616 if (dim == 2 )
16031617 {
@@ -1606,13 +1620,14 @@ int main(int argc, char **argv)
16061620 const std::array<double ,2 > coords = {{grid_x[i], grid_z[i]}};
16071621 std::vector<double > output = world->properties (coords, grid_depth[i],properties);
16081622 data_set[1 ][i] = output[0 ];
1609- data_set[2 ][3 *i] = output[1 ];
1610- data_set[2 ][3 *i+1 ] = output[2 ];
1611- data_set[2 ][3 *i+2 ] = output[3 ];
1612- data_set[3 ][i] = output[4 ];
1623+ data_set[2 ][i] = output[1 ];
1624+ data_set[3 ][3 *i] = output[2 ];
1625+ data_set[3 ][3 *i+1 ] = output[3 ];
1626+ data_set[3 ][3 *i+2 ] = output[4 ];
1627+ data_set[4 ][i] = output[5 ];
16131628 for (size_t c = 0 ; c < compositions; ++c)
16141629 {
1615- data_set[4 +c][i] = output[5 +c];
1630+ data_set[5 +c][i] = output[6 +c];
16161631 }
16171632 });
16181633 }
@@ -1623,13 +1638,14 @@ int main(int argc, char **argv)
16231638 const std::array<double ,3 > coords = {{grid_x[i], grid_y[i], grid_z[i]}};
16241639 std::vector<double > output = world->properties (coords, grid_depth[i],properties);
16251640 data_set[1 ][i] = output[0 ];
1626- data_set[2 ][3 *i] = output[1 ];
1627- data_set[2 ][3 *i+1 ] = output[2 ];
1628- data_set[2 ][3 *i+2 ] = output[3 ];
1629- data_set[3 ][i] = output[4 ];
1641+ data_set[2 ][i] = output[1 ];
1642+ data_set[3 ][3 *i] = output[2 ];
1643+ data_set[3 ][3 *i+1 ] = output[3 ];
1644+ data_set[3 ][3 *i+2 ] = output[4 ];
1645+ data_set[4 ][i] = output[5 ];
16301646 for (size_t c = 0 ; c < compositions; ++c)
16311647 {
1632- data_set[4 +c][i] = output[5 +c];
1648+ data_set[5 +c][i] = output[6 +c];
16331649 }
16341650 });
16351651 }
0 commit comments