@@ -478,7 +478,35 @@ Grid::messages_struct Grid::make_new_interconnection(int64_t iDir,
478
478
// -----------------------------------------------------------------------------
479
479
480
480
481
+ bool Neutrals::exchange_old (Grid &grid) {
482
+
483
+ std::string function = " Neutrals::exchange" ;
484
+ static int iFunction = -1 ;
485
+ report.enter (function, iFunction);
486
+
487
+ bool DidWork = true ;
488
+
489
+ for (int iSpecies = 0 ; iSpecies < nSpecies; iSpecies++) {
490
+ if (species[iSpecies].DoAdvect )
491
+ DidWork = exchange_one_var (grid, species[iSpecies].density_scgc , false );
492
+ }
493
+
494
+ DidWork = exchange_one_var (grid, temperature_scgc, false );
495
+
496
+ // velocity components:
497
+ // reverse east across the pole:
498
+ DidWork = exchange_one_var (grid, velocity_vcgc[0 ], true );
499
+ // reverse north across the pole:
500
+ DidWork = exchange_one_var (grid, velocity_vcgc[1 ], true );
501
+ // don't reverse vertical across the pole:
502
+ DidWork = exchange_one_var (grid, velocity_vcgc[2 ], false );
503
+
504
+ report.exit (function);
505
+ return DidWork;
506
+ }
507
+
481
508
509
+ /*
482
510
// -----------------------------------------------------------------------------
483
511
// Exchange messages for the NEUTRALS:
484
512
// 1. (first time) Set up the exchanging interfaces between edges / side
@@ -491,7 +519,7 @@ Grid::messages_struct Grid::make_new_interconnection(int64_t iDir,
491
519
// 5. Unpack variables from all sides
492
520
// -----------------------------------------------------------------------------
493
521
494
- bool Neutrals::exchange_old (Grid &grid) {
522
+ bool Neutrals::exchange_really_old (Grid &grid) {
495
523
496
524
std::string function = "Neutrals::exchange";
497
525
static int iFunction = -1;
@@ -699,7 +727,7 @@ bool Neutrals::exchange_old(Grid &grid) {
699
727
700
728
return DidWork;
701
729
}
702
-
730
+ */
703
731
704
732
705
733
// -----------------------------------------------------------------------------
@@ -843,6 +871,7 @@ bool exchange_sides_init(Grid &grid, int64_t nVarsToPass) {
843
871
ReverseY,
844
872
XbecomesY));
845
873
874
+ report.exit (function);
846
875
return DidWork;
847
876
}
848
877
@@ -959,17 +988,20 @@ bool exchange_one_var(Grid &grid,
959
988
MPI_Barrier (aether_comm);
960
989
961
990
// If this is a cubesphere grid, interpolate ghostcells to their proper location
962
- if (grid.IsCubeSphereGrid ) {
991
+ if (grid.IsCubeSphereGrid & grid.gcInterpolationSet ) {
992
+ report.print (3 , " Interpolating Ghostcells to Proper Location" );
963
993
var_scgc = interpolate_ghostcells (var_to_pass, grid);
964
994
var_to_pass = var_scgc;
965
995
}
966
996
967
997
report.exit (function);
968
-
969
998
return DidWork;
970
999
}
971
1000
972
1001
// -----------------------------------------------------------------------------
1002
+ // This tests the ghostcell interpolation on the cubesphere by message passing
1003
+ // latitudes and longitudes and checking to see if they match where they are
1004
+ // expected to be.
973
1005
// -----------------------------------------------------------------------------
974
1006
975
1007
bool test_ghostcell_interpolation (Grid &grid) {
@@ -989,13 +1021,15 @@ bool test_ghostcell_interpolation(Grid &grid) {
989
1021
// Check the latitudes and longitudes to make sure that they map to
990
1022
// the same location after message passing
991
1023
1024
+ // original lats and lons in degrees:
992
1025
arma_cube lats = grid.geoLat_scgc * cRtoD;
993
1026
arma_cube lons = grid.geoLon_scgc * cRtoD;
994
1027
995
- arma_cube latsFixed = lats;
996
- arma_cube lonsFixed = lons;
1028
+ // save the lats and lons that are the gold standard:
1029
+ arma_cube latsGood = lats;
1030
+ arma_cube lonsGood = lons;
997
1031
998
- // Set the ghostcells to 0:
1032
+ // Set the ghostcells in the test cells to 0:
999
1033
set_gcs_to_value (lats, 0.0 , nG);
1000
1034
set_gcs_to_value (lons, 0.0 , nG);
1001
1035
@@ -1004,6 +1038,8 @@ bool test_ghostcell_interpolation(Grid &grid) {
1004
1038
didWork = exchange_one_var (grid, lats, false );
1005
1039
didWork = exchange_one_var (grid, lons, false );
1006
1040
1041
+ // Now we will go through can compare the cells from the message passed cells to
1042
+ // the saved cells:
1007
1043
if (report.test_verbose (1 )) {
1008
1044
1009
1045
// Loop through the different directions:
@@ -1042,28 +1078,27 @@ bool test_ghostcell_interpolation(Grid &grid) {
1042
1078
iEnd = nX - nG;
1043
1079
}
1044
1080
1081
+ // we really only care about one slice, so just take the first non-ghostcell slice:
1045
1082
iZ = nG;
1046
1083
std::cout << " Looping through iDir = " << iDir << " \n " ;
1047
1084
1048
1085
for (iX = iStart; iX < iEnd; iX++) {
1049
1086
for (iY = jStart; iY < jEnd; iY++) {
1050
1087
1051
1088
std::cout << " iX, iY : " << iX << " " << iY << " " ;
1052
- std::cout << " lats pre-inter : " << lats (iX, iY, iZ);
1053
- std::cout << " lats post-inter : " << latsFixed (iX, iY, iZ);
1054
- std::cout << " should be : " << grid.geoLat_scgc (iX, iY, iZ) * cRtoD;
1089
+ std::cout << " lats message passed : " << lats (iX, iY, iZ);
1090
+ std::cout << " lats pre-pass : " << latsGood (iX, iY, iZ);
1055
1091
1056
- if (!compare (latsFixed (iX, iY, iZ), grid. geoLat_scgc (iX, iY, iZ) * cRtoD )) {
1092
+ if (!compare (latsGood (iX, iY, iZ), lats (iX, iY, iZ))) {
1057
1093
std::cout << " <-- lats don't match!!! " ;
1058
1094
didWork = false ;
1059
1095
}
1060
1096
1061
1097
std::cout << " \n " ;
1062
- std::cout << " lons pre-inter : " << lons (iX, iY, iZ);
1063
- std::cout << " lons post-inter : " << lonsFixed (iX, iY, iZ);
1064
- std::cout << " should be : " << grid.geoLon_scgc (iX, iY, iZ) * cRtoD;
1098
+ std::cout << " lons message passed : " << lons (iX, iY, iZ);
1099
+ std::cout << " lons pre-pass : " << lonsGood (iX, iY, iZ);
1065
1100
1066
- if (!compare (lonsFixed (iX, iY, iZ), grid. geoLon_scgc (iX, iY, iZ) * cRtoD )) {
1101
+ if (!compare (lonsGood (iX, iY, iZ), lons (iX, iY, iZ))) {
1067
1102
std::cout << " <-- lons don't match!!! " ;
1068
1103
didWork = false ;
1069
1104
}
@@ -1073,7 +1108,7 @@ bool test_ghostcell_interpolation(Grid &grid) {
1073
1108
}
1074
1109
}
1075
1110
}
1076
-
1111
+ report. exit (function);
1077
1112
return didWork;
1078
1113
}
1079
1114
@@ -1139,6 +1174,7 @@ arma_cube interpolate_ghostcells(arma_cube varIn, Grid &grid) {
1139
1174
}
1140
1175
}
1141
1176
1177
+ report.exit (function);
1142
1178
return varOut;
1143
1179
}
1144
1180
@@ -1171,26 +1207,14 @@ bool find_ghostcell_interpolation_coefs(Grid &grid) {
1171
1207
set_gcs_to_value (xOther, 0.0 , nG);
1172
1208
1173
1209
// Message pass to get the X and Y from the other faces
1174
- report.print (1 , " starting exchange to find interpolation indices" );
1210
+ report.print (2 , " starting exchange to find interpolation indices" );
1175
1211
didWork = exchange_one_var (grid, yOther, false );
1176
1212
didWork = exchange_one_var (grid, xOther, false );
1177
1213
1178
- report.print (1 , " finished exchange" );
1179
-
1180
- for (int64_t ip = 0 ; ip < 6 ; ip++) {
1181
- MPI_Barrier (aether_comm);
1214
+ if (report.test_verbose (2 )) {
1182
1215
1183
- if (iProc == ip) {
1184
- std::cout << " ip : " << ip << " \n " ;
1185
- std::cout << " xLocal : \n " << xLocal.slice (iZ) << " \n " ;
1186
- std::cout << " yLocal : \n " << yLocal.slice (iZ) << " \n " ;
1187
- }
1188
- }
1189
-
1190
-
1191
- MPI_Barrier (aether_comm);
1216
+ std::cout << " finished exchange" ;
1192
1217
1193
- if (report.test_verbose (1 )) {
1194
1218
std::cout << " xLocal : \n " << xLocal.slice (iZ) << " \n " ;
1195
1219
std::cout << " xOther : \n " << xOther.slice (iZ) << " \n " ;
1196
1220
std::cout << " yLocal : \n " << yLocal.slice (iZ) << " \n " ;
@@ -1261,7 +1285,7 @@ bool find_ghostcell_interpolation_coefs(Grid &grid) {
1261
1285
to = xLocal.slice (iZ).col (iY);
1262
1286
}
1263
1287
1264
- if (report.test_verbose (1 )) {
1288
+ if (report.test_verbose (3 )) {
1265
1289
std::cout << " iDir : " << iDir << " \n " ;
1266
1290
std::cout << " drx : " << grid.interchangesOneVar [iDir].DoReverseX << " \n " ;
1267
1291
std::cout << " dry : " << grid.interchangesOneVar [iDir].DoReverseY << " \n " ;
@@ -1287,24 +1311,19 @@ bool find_ghostcell_interpolation_coefs(Grid &grid) {
1287
1311
std::cout << ind;
1288
1312
std::cout << " rat :\n " ;
1289
1313
std::cout << rat;
1290
- /*
1291
- for (int64_t iY = nG; iY < nY - nG; iY++) {
1292
- iy_ = grid.interchangesOneVar[iDir].index(iG, iY);
1293
- r = grid.interchangesOneVar[iDir].ratio(iG, iY);
1294
- */
1295
1314
}
1296
1315
}
1297
1316
}
1298
1317
1299
- report. print ( 1 , " finished compare " ) ;
1318
+ grid. gcInterpolationSet = true ;
1300
1319
1301
- didWork = test_ghostcell_interpolation (grid);
1320
+ if (report.test_verbose (3 ))
1321
+ didWork = test_ghostcell_interpolation (grid);
1302
1322
1303
1323
// Wait for all processors to be done.
1304
1324
MPI_Barrier (aether_comm);
1305
1325
1306
1326
report.exit (function);
1307
-
1308
1327
return didWork;
1309
1328
}
1310
1329
0 commit comments