@@ -36,6 +36,58 @@ bool Neutrals::exchange_old(Grid &grid) {
36
36
return DidWork;
37
37
}
38
38
39
+ void average_value_at_pole (Grid &grid, arma_cube &value, arma_cube &velocity,
40
+ int64_t iLast, int64_t iPole,
41
+ bool doesTouchPole) {
42
+ // Now let's deal with the poles:
43
+ // north pole first:
44
+ int64_t iX, nX = grid.get_nX ();
45
+ int64_t iZ, nZ = grid.get_nZ ();
46
+ int64_t nGCs = grid.get_nGCs ();
47
+ int64_t iY, iInc = 1 ;
48
+
49
+ if (iPole < iLast)
50
+ iInc = -1 ;
51
+
52
+ double weight, sumValue, sumWeight, totalValue, totalWeight, poleValue;
53
+
54
+ for (iZ = nGCs; iZ < nZ - nGCs; iZ++) {
55
+
56
+ sumValue = 0.0 ;
57
+ sumWeight = 0.0 ;
58
+
59
+ if (doesTouchPole) {
60
+ for (iX = nGCs; iX < nX - nGCs; iX++) {
61
+ // determine the weight based on the northward velocity:
62
+ weight = iInc * velocity (iX, iLast, iZ) / 1000.0 + 1.0 ;
63
+
64
+ if (weight < 0.01 )
65
+ weight = 0.01 ;
66
+
67
+ sumValue = sumValue + value (iX, iLast, iZ) * weight;
68
+ sumWeight = sumWeight + weight;
69
+ }
70
+ }
71
+
72
+ MPI_Allreduce (&sumValue, &totalValue, 1 , MPI_DOUBLE, MPI_SUM,
73
+ aether_comm);
74
+ MPI_Allreduce (&sumWeight, &totalWeight, 1 , MPI_DOUBLE, MPI_SUM,
75
+ aether_comm);
76
+ poleValue = totalValue / totalWeight;
77
+
78
+ // if (iZ == 10)
79
+ // std::cout << "pole value : " << poleValue << " " << totalValue << " " << totalWeight << " "
80
+ // << iProc << " " << doesTouchPole << "\n";
81
+
82
+ if (doesTouchPole) {
83
+ for (iX = nGCs; iX < nX - nGCs; iX++)
84
+ for (iY = iLast + iInc; iY == iPole; iY += iInc)
85
+ value (iX, iY, iZ) = poleValue;
86
+ }
87
+ }
88
+
89
+ }
90
+
39
91
// -----------------------------------------------------------------------------
40
92
// This is the main exchange messages for the neutrals.
41
93
// We are exchanging densities, temperatures, and velocities
@@ -53,7 +105,7 @@ bool Ions::exchange_old(Grid &grid) {
53
105
for (int iSpecies = 0 ; iSpecies < nSpecies; iSpecies++)
54
106
DidWork = exchange_one_var (grid, species[iSpecies].density_scgc , false );
55
107
56
- DidWork = exchange_one_var (grid, temperature_scgc, false );
108
+ // DidWork = exchange_one_var(grid, temperature_scgc, false);
57
109
DidWork = exchange_one_var (grid, electron_temperature_scgc, false );
58
110
59
111
// velocity components:
@@ -64,6 +116,25 @@ bool Ions::exchange_old(Grid &grid) {
64
116
// don't reverse vertical across the pole:
65
117
DidWork = exchange_one_var (grid, velocity_vcgc[2 ], false );
66
118
119
+ int64_t iPole = grid.get_nY () - 1 ;
120
+ int64_t iLast = iPole - nGCs;
121
+
122
+ average_value_at_pole (grid, temperature_scgc, velocity_vcgc[1 ],
123
+ iLast, iPole, grid.DoesTouchNorthPole );
124
+
125
+ for (int iSpecies = 0 ; iSpecies < nSpecies; iSpecies++)
126
+ average_value_at_pole (grid, species[iSpecies].density_scgc , velocity_vcgc[1 ],
127
+ iLast, iPole, grid.DoesTouchNorthPole );
128
+
129
+ iPole = 0 ;
130
+ iLast = nGCs;
131
+ average_value_at_pole (grid, temperature_scgc, velocity_vcgc[1 ],
132
+ iLast, iPole, grid.DoesTouchSouthPole );
133
+
134
+ for (int iSpecies = 0 ; iSpecies < nSpecies; iSpecies++)
135
+ average_value_at_pole (grid, species[iSpecies].density_scgc , velocity_vcgc[1 ],
136
+ iLast, iPole, grid.DoesTouchSouthPole );
137
+
67
138
report.exit (function);
68
139
return DidWork;
69
140
}
@@ -119,9 +190,9 @@ bool pack_border(const arma_cube &value,
119
190
int iDir) {
120
191
121
192
bool DidWork = true ;
122
- static int64_t nX = value.n_rows ;
123
- static int64_t nY = value.n_cols ;
124
- static int64_t nZ = value.n_slices ;
193
+ int64_t nX = value.n_rows ;
194
+ int64_t nY = value.n_cols ;
195
+ int64_t nZ = value.n_slices ;
125
196
126
197
int64_t iXstart, iXend;
127
198
int64_t iYstart, iYend;
@@ -221,9 +292,9 @@ bool unpack_border(arma_cube &value,
221
292
bool XbecomesY) {
222
293
223
294
bool DidWork = true ;
224
- static int64_t nX = value.n_rows ;
225
- static int64_t nY = value.n_cols ;
226
- static int64_t nZ = value.n_slices ;
295
+ int64_t nX = value.n_rows ;
296
+ int64_t nY = value.n_cols ;
297
+ int64_t nZ = value.n_slices ;
227
298
228
299
int64_t iXstart, iXend;
229
300
int64_t iYstart, iYend;
@@ -345,6 +416,7 @@ bool unpack_border(arma_cube &value,
345
416
} catch (...) {
346
417
DidWork = false ;
347
418
}
419
+
348
420
return DidWork;
349
421
}
350
422
@@ -394,7 +466,7 @@ bool pack_one_var_on_one_face(arma_cube var_scgc,
394
466
int iDirToPass,
395
467
Grid &grid) {
396
468
397
- static int nG = grid.get_nGCs ();
469
+ int nG = grid.get_nGCs ();
398
470
int iDir = grid.interchangesOneVar [iDirToPass].iFace ;
399
471
int iReceiver = grid.interchangesOneVar [iDirToPass].iProc_to ;
400
472
precision_t *buffer = grid.interchangesOneVar [iDirToPass].buffer ;
@@ -475,9 +547,9 @@ bool Grid::send_one_var_one_face(int64_t iFace) {
475
547
476
548
if (report.test_verbose (4 ))
477
549
std::cout << " in send_one_var_one_face : " << iFace << " from: " <<
478
- iProc << " to: " <<
479
- interchangesOneVar[iFace].iProc_to << " tag: " <<
480
- interchangesOneVar[iFace].iTag << " \n " ;
550
+ iProc << " to: " <<
551
+ interchangesOneVar[iFace].iProc_to << " tag: " <<
552
+ interchangesOneVar[iFace].iTag << " \n " ;
481
553
482
554
MPI_Isend (interchangesOneVar[iFace].buffer ,
483
555
interchangesOneVar[iFace].iSizeTotal ,
@@ -521,9 +593,9 @@ bool Grid::receive_one_var_one_face(int64_t iFace) {
521
593
522
594
if (report.test_verbose (4 ))
523
595
std::cout << " in receive_one_var_one_face : " << iFace << " from: " <<
524
- iProc << " to: " <<
525
- interchangesOneVar[iFace].iProc_to << " tag: " <<
526
- interchangesOneVar[iFace].iTag << " \n " ;
596
+ iProc << " to: " <<
597
+ interchangesOneVar[iFace].iProc_to << " tag: " <<
598
+ interchangesOneVar[iFace].iTag << " \n " ;
527
599
528
600
529
601
MPI_Recv (interchangesOneVar[iFace].rbuffer ,
@@ -1026,24 +1098,28 @@ bool exchange_one_var(Grid &grid,
1026
1098
int iTag, iDir, nDir;
1027
1099
int iSpecies;
1028
1100
1029
- static int64_t nX = grid.get_nX ();
1030
- static int64_t nY = grid.get_nY ();
1031
- static int64_t nZ = grid.get_nZ ();
1032
- static int64_t nG = grid.get_nGCs ();
1033
- static arma_cube var_scgc;
1101
+ int64_t nX = grid.get_nX ();
1102
+ int64_t nY = grid.get_nY ();
1103
+ int64_t nZ = grid.get_nZ ();
1104
+ int64_t nG = grid.get_nGCs ();
1105
+ arma_cube var_scgc;
1034
1106
1035
- static int64_t nVarsToPass = 1 ;
1107
+ int64_t nVarsToPass = 1 ;
1036
1108
1037
1109
if (!grid.isExchangeInitialized ) {
1038
1110
DidWork = exchange_sides_init (grid, nVarsToPass);
1039
1111
grid.isExchangeInitialized = true ;
1112
+ std::cout << " initializing : " << grid.get_gridtype () << " " << nZ << " " <<
1113
+ iProc << " \n " ;
1040
1114
}
1115
+
1041
1116
var_scgc.set_size (nX, nY, nZ);
1042
1117
1043
1118
int64_t iP;
1044
1119
precision_t oneSign = 1.0 ;
1045
1120
1046
1121
nDir = 4 ;
1122
+
1047
1123
if (grid.get_IsDipole () && grid.get_IsClosed ())
1048
1124
nDir++;
1049
1125
@@ -1139,10 +1215,10 @@ bool test_ghostcell_interpolation(Grid &grid) {
1139
1215
1140
1216
bool didWork = true ;
1141
1217
1142
- static int64_t iX, nX = grid.get_nX ();
1143
- static int64_t iY, nY = grid.get_nY ();
1144
- static int64_t iZ, nZ = grid.get_nZ ();
1145
- static int64_t nG = grid.get_nGCs ();
1218
+ int64_t iX, nX = grid.get_nX ();
1219
+ int64_t iY, nY = grid.get_nY ();
1220
+ int64_t iZ, nZ = grid.get_nZ ();
1221
+ int64_t nG = grid.get_nGCs ();
1146
1222
int64_t iStart, iEnd, jStart, jEnd, iDir;
1147
1223
1148
1224
// Check the latitudes and longitudes to make sure that they map to
@@ -1252,9 +1328,9 @@ arma_cube interpolate_ghostcells(arma_cube varIn, Grid &grid) {
1252
1328
bool didWork = true ;
1253
1329
1254
1330
int64_t iDir;
1255
- static int64_t iX, ix_, nX = grid.get_nX ();
1256
- static int64_t iY, iy_, nY = grid.get_nY ();
1257
- static int64_t iG, nG = grid.get_nGCs ();
1331
+ int64_t iX, ix_, nX = grid.get_nX ();
1332
+ int64_t iY, iy_, nY = grid.get_nY ();
1333
+ int64_t iG, nG = grid.get_nGCs ();
1258
1334
precision_t r_;
1259
1335
arma_cube varOut = varIn;
1260
1336
@@ -1322,10 +1398,10 @@ bool find_ghostcell_interpolation_coefs(Grid &grid) {
1322
1398
1323
1399
bool didWork = true ;
1324
1400
1325
- static int64_t iX, nX = grid.get_nX ();
1326
- static int64_t iY, nY = grid.get_nY ();
1327
- static int64_t iZ, nZ = grid.get_nZ ();
1328
- static int64_t nG = grid.get_nGCs ();
1401
+ int64_t iX, nX = grid.get_nX ();
1402
+ int64_t iY, nY = grid.get_nY ();
1403
+ int64_t iZ, nZ = grid.get_nZ ();
1404
+ int64_t nG = grid.get_nGCs ();
1329
1405
1330
1406
// Test to see if the longitudes are the same as the original
1331
1407
arma_cube yOther = grid.refy_angle * cRtoD;
0 commit comments