24 int haloDepth,std::ostream &messageStream)
28 messageStream <<
"grid::PBS::ParallelSetup: Error gridSizes empty." << std::endl;
42 if(periodicDirs.size() !=
numDim){
43 periodicDirs.resize(
numDim,0);
45 for(
int iDim = 0;iDim <
numDim;iDim++){
46 isPeriodic.resize(numDim,
false);
47 if(periodicDirs[iDim] > 0)
48 isPeriodic[iDim] =
true;
51 std::vector<int> haloDepths(2*numDim,haloDepth);
60 messageStream <<
"grid::PBS::ParallelSetup: Cartesian setup:" << std::endl;
69 partitionInterval,messageStream)){
70 messageStream <<
"grid::PBS::ParallelSetup:Error: Partitioning failed." << std::endl;
75 std::vector<size_t> extendGrid(2*numDim,0);
77 std::vector<bool> haveNeighbors(2*numDim,
true);
78 for(
int iDim = 0;iDim <
numDim; iDim++){
80 extendGrid[2*iDim] = haloDepths[2*iDim];
81 extendGrid[2*iDim+1] = haloDepths[2*iDim+1];
83 if(partitionInterval[iDim].first == 0) {
84 haveNeighbors[2*iDim] =
false;
86 extendGrid[2*iDim] = haloDepths[2*iDim];
88 if(partitionInterval[iDim].second == (gridSizes[iDim]-1)){
89 haveNeighbors[2*iDim + 1] =
false;
91 extendGrid[2*iDim + 1] = haloDepths[2*iDim+1];
96 messageStream <<
"grid::PBS::ParallelSetup: Configuring grid extensions (";
98 messageStream <<
")" << std::endl;
103 messageStream <<
"grid::PBS::ParallelSetup:Error: finalization failed." << std::endl;
139 if(inName == topoName)
return(iType);
148 return(std::string(
topoNames[(
int)NUMTOPOTYPE]));
159 if(collisionInterval.NNodes() == 0)
161 int numDim = partitionSubInterval.size();
162 returnValue = collisionInterval;
163 for(
int iDim = 0;iDim <
numDim;iDim++){
164 collisionInterval[iDim].first -= partitionInterval[iDim].first;
165 collisionInterval[iDim].second -= partitionInterval[iDim].first;
166 returnValue[iDim].first = collisionInterval[iDim].first + partitionBufferInterval[iDim].first;
167 returnValue[iDim].second = collisionInterval[iDim].second + partitionBufferInterval[iDim].first;
181 int numDim = gridSizes.size();
186 std::istringstream Istr(inString);
188 std::string regionName;
189 int normalDirection = 0;
190 Istr >> regionName >> normalDirection;
191 if(regionName.empty())
194 if(std::abs(normalDirection) >
numDim)
201 for(
int iDim = 0;iDim <
numDim;iDim++){
203 int leftBoundary = (iDim+1);
204 int rightBoundary = -leftBoundary;
206 if(normalDirection == leftBoundary){
207 regionInterval[iDim].first = 0;
208 regionInterval[iDim].second = 0;
209 }
else if(normalDirection == rightBoundary){
210 regionInterval[iDim].first = gridInterval[iDim].second;
211 regionInterval[iDim].second = gridInterval[iDim].second;
218 Istr >> iStart >> iEnd;
219 if((iStart != 0) && (iEnd != 0)){
222 regionInterval[iDim].first = gridInterval[iDim].second + iStart;
225 regionInterval[iDim].first = iStart;
229 regionInterval[iDim].second = gridInterval[iDim].second + iEnd;
232 regionInterval[iDim].second = iEnd;
236 if(regionInterval[iDim].first > gridInterval[iDim].second)
238 if(regionInterval[iDim].first > regionInterval[iDim].second)
240 if(regionInterval[iDim].second > gridInterval[iDim].second)
247 regionInterval.
Sync();
264 messageStream <<
"grid::PBS::ComputeMetrics: Computing uniform grid metrics." 267 messageStream <<
"grid::PBS::ComputeMetrics: Warning: grid spacings of invalid size (" 268 <<
dX.size() <<
" != " << numDim <<
"), attempting to generate." 276 int index1 = partitionBufferInterval[0].first;
277 int index2 = index1+1;
278 dX[0] = gridCoordinates[index2] - gridCoordinates[index1];
279 }
else if (numDim == 2) {
281 littleBox[0].second = littleBox[0].first+1;
282 littleBox[1].second = littleBox[1].first+1;
283 std::vector<size_t> littleBoxIndices;
285 dX[0] = gridCoordinates[littleBoxIndices[1]] - gridCoordinates[littleBoxIndices[0]];
290 littleBox[0].second = littleBox[0].first+1;
291 littleBox[1].second = littleBox[1].first+1;
292 littleBox[2].second = littleBox[2].first+1;
293 std::vector<size_t> littleBoxIndices;
295 dX[0] = gridCoordinates[littleBoxIndices[1]] - gridCoordinates[littleBoxIndices[0]];
301 messageStream <<
"Generated dX(";
303 messageStream <<
")" << std::endl;
309 for(
int iDim = 0;iDim <
numDim;iDim++){
311 messageStream <<
"grid::PBS::ComputeMetrics: Error: invalid grid spacings (";
313 messageStream <<
"). Aborting." << std::endl;
319 for(
int iDim = 0;iDim <
numDim;iDim++)
331 messageStream <<
"grid::PBS::ComputeMetrics: Computing metric for rectilinear grid." 334 messageStream <<
"grid::PBS::ComputeMetrics: Error: Differential operators must be set " 335 <<
"before computing rectilinear metrics." << std::endl;
345 int numDim = gridSizes.size();
358 std::vector<size_t> dOpInterval;
359 partitionBufferInterval.
Flatten(dOpInterval);
361 std::vector<size_t>::iterator dOpIt = dOpInterval.begin();
362 while(dOpIt != dOpInterval.end()){
368 int numMetricComponents =
numDim;
371 gridMetric.resize(numMetricComponents*numPointsBuffer,0);
394 int metricComponent = 1;
395 size_t dirOffset = (dDir-1)*numPointsBuffer;
396 size_t metricOffset = (metricComponent-1)*numPointsBuffer;
407 dirOffset = (dDir - 1)*numPointsBuffer;
408 metricOffset = (metricComponent - 1)*numPointsBuffer;
432 }
else if (numDim == 3) {
440 size_t dirOffset = (dDir-1)*numPointsBuffer;
450 dirOffset = (dDir-1)*numPointsBuffer;
461 dirOffset = (dDir-1)*numPointsBuffer;
487 &dOpInterval[0],&gridJacobian[0],
495 &gridMetric[metricOffset]);
501 &dOpInterval[0],&gridMetric[metricOffset],
511 }
else if (numDim == 1){
528 if(gridSizes.empty() || bufferSizes.empty() ||
529 (partInterval.
NNodes() == 0) || (partitionBufferInterval.
NNodes() == 0)){
530 messageStream <<
"grid::PBS::ComputeMetrics: Error: Grid sizes not set up." 532 <<
"grid::PBS::ComputeMetrics: Finalize() must be called before ComputeMetrics." 543 messageStream <<
"grid::PBS::ComputeMetrics: Error: Differential operators must be set " 544 <<
"before computing metrics." << std::endl;
551 int numDim = gridSizes.size();
554 }
else if (numDim == 3) {
557 }
else if (numDim > 1) {
558 messageStream <<
"grid::ComputeMetrics:Error: " 559 <<
"Unsupported number of dimensions." 578 if(gridSizes.empty() || bufferSizes.empty() ||
579 (partInterval.
NNodes() == 0) || (partitionBufferInterval.
NNodes() == 0)){
580 messageStream <<
"grid::PBS::ComputeCurvilinearMetrics: Error: Grid sizes not set up." 582 <<
"grid::PBS::ComputeCurvilinearMetrics: Finalize() must be called before ComputeMetrics." 588 messageStream <<
"grid::PBS::ComputeMetrics:Error: Cannot create 2D curvilinear metrics for " 589 <<
numDim<<
"-dimensional grid." << std::endl;
593 messageStream <<
"grid::PBS::ComputeMetrics: Computing 2d curvilinear metric." 613 std::vector<size_t> dOpInterval;
614 partitionBufferInterval.
Flatten(dOpInterval);
616 std::vector<size_t>::iterator dOpIt = dOpInterval.begin();
617 while(dOpIt != dOpInterval.end()){
623 int numMetricComponents = numDim*
numDim;
626 gridMetric.resize(numMetricComponents*numPointsBuffer,0);
631 double *xData = &gridCoordinates[0];
637 int metricComponent = 1;
638 size_t dirOffset = (dDir-1)*numPointsBuffer;
639 size_t metricOffset = (metricComponent-1)*numPointsBuffer;
650 dirOffset = (dDir - 1)*numPointsBuffer;
651 metricOffset = (metricComponent - 1)*numPointsBuffer;
674 double negOne = -1.0;
677 dirOffset = (dDir - 1)*numPointsBuffer;
678 metricOffset = (metricComponent-1)*numPointsBuffer;
684 xData,&gridMetric[metricOffset]);
690 &dOpInterval[0],&negOne,&gridMetric[metricOffset]);
696 dirOffset = (dDir - 1)*numPointsBuffer;
697 metricOffset = (metricComponent-1)*numPointsBuffer;
703 yData,&gridMetric[metricOffset]);
709 &dOpInterval[0],&negOne,&gridMetric[metricOffset]);
740 messageStream <<
"PBS::ComputeMetricIdentities: Error - grid metrics empty." << std::endl;
744 identityData.resize(
numDim,0.0);
745 messageStream <<
"PBS::ComputeMetricIdentities: Metric identities for gridType(" 746 <<
gridType <<
") are trivially zero." << std::endl;
757 if(numPointsBuffer == 0){
758 messageStream <<
"PBS::ComputeMetricIdentities: Error - no points in the grid." << std::endl;
762 messageStream <<
"PBS::ComputeMetricIdentities: Error - grid of dimension " << numDim
763 <<
" not supported." << std::endl;
774 std::vector<size_t> dOpInterval;
775 partitionBufferInterval.
Flatten(dOpInterval);
778 std::vector<size_t>::iterator dOpIt = dOpInterval.begin();
779 while(dOpIt != dOpInterval.end()){
787 identityData.resize(numDim*numPointsBuffer,0.0);
788 std::vector<double> identityComponent(numPointsBuffer);
790 int numMetricComponents = numDim*
numDim;
793 for(
int iDim = 0;iDim <
numDim;iDim++){
795 int diffDir = iDim+1;
797 for(
int jDim = 0;jDim <
numDim;jDim++){
798 size_t metricIndex = jDim*numPointsBuffer + iIndex;
800 double *metricComponent = &
gridMetric[metricIndex];
806 metricComponent,&identityComponent[0]);
809 &dOpInterval[0],&
a,&identityComponent[0],
810 &identityData[identityOffset]);
828 std::vector<int> cartNeighbors;
845 double *targetBuffer,std::ostream &messageStream,
bool exchange =
false)
849 messageStream <<
"grid::PBS::GradIJK: Error: Differential operators must be set " 850 <<
"before using GradIJK." << std::endl;
856 messageStream <<
"grid::PBS::GradIJK: Error: Data exchange failed." << std::endl;
867 int gradComponents = numComponents *
numDim;
881 std::vector<size_t> dOpInterval;
882 partitionBufferInterval.
Flatten(dOpInterval);
884 std::vector<size_t>::iterator dOpIt = dOpInterval.begin();
885 while(dOpIt != dOpInterval.end()){
890 size_t targetOffset = 0;
892 for(
int iComponent = 0;iComponent <
numComponents;iComponent++){
895 for(
int iDir = 0;iDir <
numDim;iDir++){
898 targetOffset = numPointsBuffer*targetComp++;
905 &sourceBuffer[sourceOffset],&targetBuffer[targetOffset]);
927 int numJacComponents = numDim*
numDim;
933 messageStream <<
"grid::PBS::ComputeJacobianMatrix: Error, GradIJK failed." 958 messageStream <<
"grid::PBS::ComputeJacobianMatrix2: Error, GradIJK failed." 974 if(gridSizes.empty() || bufferSizes.empty() ||
975 (partInterval.
NNodes() == 0) || (partitionBufferInterval.
NNodes() == 0)){
976 messageStream <<
"grid::PBS::ComputeCurvilinearMetrics: Error: Grid sizes not set up." 978 <<
"grid::PBS::ComputeCurvilinearMetrics: Finalize() must be called before ComputeMetrics." 983 int numDim = bufferSizes.size();
985 messageStream <<
"grid::PBS::ComputeMetrics:Error: Cannot create 3D curvilinear metrics for " 986 << numDim <<
"-dimensional grid." << std::endl;
990 messageStream <<
"grid::PBS::ComputeMetrics: Computing 3d curvilinear metric." 996 messageStream <<
"grid::PBS::ComputeCurvilinearMetrics3D: Error: " 997 <<
"ComputeJacobianMatrix failed." << std::endl;
1001 int numMetricComponents = numDim*
numDim;
1004 gridMetric.resize(numMetricComponents*numPointsBuffer,0);
1012 std::vector<size_t> dOpInterval;
1013 partitionBufferInterval.
Flatten(dOpInterval);
1015 std::vector<size_t>::iterator dOpIt = dOpInterval.begin();
1016 while(dOpIt != dOpInterval.end()){
1036 messageStream <<
"grid::PBS::ComputeCurvilinearMetrics3D: Error: Jacobian matrix exchange failed." 1043 messageStream <<
"grid::PBS::ComputeCurvilinearMetrics3D: Error: " 1044 <<
"ComputeJacobianMatrix2 failed." << std::endl;
1048 size_t componentOffset = 0;
1049 int jm1Component = 1;
1050 componentOffset = (jm1Component - 1)*numPointsBuffer;
1051 double *x_xi = &jacobianMatrix[componentOffset];
1053 componentOffset = (jm1Component - 1)*numPointsBuffer;
1054 double *x_eta = &jacobianMatrix[componentOffset];
1056 componentOffset = (jm1Component - 1)*numPointsBuffer;
1057 double *x_zeta = &jacobianMatrix[componentOffset];
1059 componentOffset = (jm1Component - 1)*numPointsBuffer;
1060 double *y_xi = &jacobianMatrix[componentOffset];
1062 componentOffset = (jm1Component - 1)*numPointsBuffer;
1063 double *y_eta = &jacobianMatrix[componentOffset];
1065 componentOffset = (jm1Component - 1)*numPointsBuffer;
1066 double *y_zeta = &jacobianMatrix[componentOffset];
1068 componentOffset = (jm1Component - 1)*numPointsBuffer;
1069 double *z_xi = &jacobianMatrix[componentOffset];
1071 componentOffset = (jm1Component - 1)*numPointsBuffer;
1072 double *z_eta = &jacobianMatrix[componentOffset];
1074 componentOffset = (jm1Component - 1)*numPointsBuffer;
1075 double *z_zeta= &jacobianMatrix[componentOffset];
1077 int j2Component = 2;
1078 componentOffset = (j2Component-1)*numPointsBuffer;
1082 componentOffset = (j2Component-1)*numPointsBuffer;
1086 componentOffset = (j2Component-1)*numPointsBuffer;
1090 componentOffset = (j2Component-1)*numPointsBuffer;
1094 componentOffset = (j2Component-1)*numPointsBuffer;
1098 componentOffset = (j2Component-1)*numPointsBuffer;
1102 componentOffset = (j2Component-1)*numPointsBuffer;
1106 componentOffset = (j2Component-1)*numPointsBuffer;
1110 componentOffset = (j2Component-1)*numPointsBuffer;
1114 componentOffset = (j2Component-1)*numPointsBuffer;
1118 componentOffset = (j2Component-1)*numPointsBuffer;
1122 componentOffset = (j2Component-1)*numPointsBuffer;
1126 componentOffset = (j2Component-1)*numPointsBuffer;
1130 componentOffset = (j2Component-1)*numPointsBuffer;
1134 componentOffset = (j2Component-1)*numPointsBuffer;
1138 componentOffset = (j2Component-1)*numPointsBuffer;
1142 componentOffset = (j2Component-1)*numPointsBuffer;
1146 componentOffset = (j2Component-1)*numPointsBuffer;
1159 y_eta,y_zeta,z_eta,z_zeta,y_eta_zeta,y_zeta_eta,zData,
1164 z_eta,z_zeta,x_eta,x_zeta,z_eta_zeta,z_zeta_eta,xData,
1169 x_eta,x_zeta,y_eta,y_zeta,x_eta_zeta,x_zeta_eta,yData,
1174 y_zeta,y_xi,z_zeta,z_xi,y_zeta_xi,y_xi_zeta,zData,
1179 z_zeta,z_xi,x_zeta,x_xi,z_zeta_xi,z_xi_zeta,xData,
1184 x_zeta,x_xi,y_zeta,y_xi,x_zeta_xi,x_xi_zeta,yData,
1189 y_xi,y_eta,z_xi,z_eta,y_xi_eta,y_eta_xi,zData,
1194 z_xi,z_eta,x_xi,x_eta,z_xi_eta,z_eta_xi,xData,
1199 x_xi,x_eta,y_xi,y_eta,x_xi_eta,x_eta_xi,yData,
1211 std::vector<size_t> fortranBufferInterval;
1212 bufferInterval.
Flatten(fortranBufferInterval);
1213 std::vector<size_t>::iterator fbIt = fortranBufferInterval.begin();
1214 while(fbIt != fortranBufferInterval.end()){
1222 if(gridSizes.empty() || bufferSizes.empty() ||
1223 (partInterval.
NNodes() == 0) || (partitionBufferInterval.
NNodes() == 0)){
1224 messageStream <<
"grid::PBS::ComputeCurvilinearMetrics: Error: Grid sizes not set up." 1226 <<
"grid::PBS::ComputeCurvilinearMetrics: Finalize() must be called before ComputeMetrics." 1231 double negOne = -1.0;
1232 double plusOne = 1.0;
1234 int numDim = bufferSizes.size();
1236 messageStream <<
"grid::PBS::ComputeMetrics:Error: Cannot create 3D curvilinear metrics for " 1237 << numDim <<
"-dimensional grid." << std::endl;
1241 messageStream <<
"grid::PBS::ComputeMetrics: Computing 3d curvilinear metric." 1247 messageStream <<
"grid::PBS::CurvilinearMetrics: Error: " 1248 <<
"ComputeJacobianMatrix failed." << std::endl;
1252 int numMetricComponents = numDim*
numDim;
1255 gridMetric.resize(numMetricComponents*numPointsBuffer,0);
1263 std::vector<size_t> dOpInterval;
1264 partitionBufferInterval.
Flatten(dOpInterval);
1266 std::vector<size_t>::iterator dOpIt = dOpInterval.begin();
1267 while(dOpIt != dOpInterval.end()){
1287 messageStream <<
"grid::PBS::ComputeCurvilinearMetrics3D: Error: Jacobian matrix exchange failed." 1299 size_t componentOffset = 0;
1300 int jm1Component = 1;
1301 componentOffset = (jm1Component - 1)*numPointsBuffer;
1302 double *x_xi = &jacobianMatrix[componentOffset];
1304 componentOffset = (jm1Component - 1)*numPointsBuffer;
1305 double *x_eta = &jacobianMatrix[componentOffset];
1307 componentOffset = (jm1Component - 1)*numPointsBuffer;
1308 double *x_zeta = &jacobianMatrix[componentOffset];
1310 componentOffset = (jm1Component - 1)*numPointsBuffer;
1311 double *y_xi = &jacobianMatrix[componentOffset];
1313 componentOffset = (jm1Component - 1)*numPointsBuffer;
1314 double *y_eta = &jacobianMatrix[componentOffset];
1316 componentOffset = (jm1Component - 1)*numPointsBuffer;
1317 double *y_zeta = &jacobianMatrix[componentOffset];
1319 componentOffset = (jm1Component - 1)*numPointsBuffer;
1320 double *z_xi = &jacobianMatrix[componentOffset];
1322 componentOffset = (jm1Component - 1)*numPointsBuffer;
1323 double *z_eta = &jacobianMatrix[componentOffset];
1325 componentOffset = (jm1Component - 1)*numPointsBuffer;
1326 double *z_zeta= &jacobianMatrix[componentOffset];
1348 int metricComponent = 1;
1349 size_t dirOffset = (dDir-1)*numPointsBuffer;
1350 size_t metricOffset = (metricComponent-1)*numPointsBuffer;
1359 dirOffset = (dDir-1)*numPointsBuffer;
1373 &fortranBufferInterval[0],z_eta,xData,&jacobianMatrix2[0]);
1376 &fortranBufferInterval[0],z_zeta,xData,&jacobianMatrix2[
numPointsBuffer]);
1379 metricComponent = 2;
1380 dirOffset = (dDir-1)*numPointsBuffer;
1381 metricOffset = (metricComponent-1)*numPointsBuffer;
1387 &jacobianMatrix2[0],&
gridMetric[metricOffset]);
1389 dirOffset = (dDir-1)*numPointsBuffer;
1403 &fortranBufferInterval[0],x_eta,yData,&jacobianMatrix2[0]);
1406 &fortranBufferInterval[0],x_zeta,yData,&jacobianMatrix2[
numPointsBuffer]);
1409 metricComponent = 3;
1410 dirOffset = (dDir-1)*numPointsBuffer;
1411 metricOffset = (metricComponent-1)*numPointsBuffer;
1417 &jacobianMatrix2[0],&
gridMetric[metricOffset]);
1419 dirOffset = (dDir-1)*numPointsBuffer;
1436 &fortranBufferInterval[0],y_zeta,zData,&jacobianMatrix2[0]);
1439 &fortranBufferInterval[0],y_xi,zData,&jacobianMatrix2[
numPointsBuffer]);
1442 metricComponent = 4;
1443 dirOffset = (dDir-1)*numPointsBuffer;
1444 metricOffset = (metricComponent-1)*numPointsBuffer;
1450 &jacobianMatrix2[0],&
gridMetric[metricOffset]);
1452 dirOffset = (dDir-1)*numPointsBuffer;
1468 &fortranBufferInterval[0],z_zeta,xData,&jacobianMatrix2[0]);
1471 &fortranBufferInterval[0],z_xi,xData,&jacobianMatrix2[
numPointsBuffer]);
1474 metricComponent = 5;
1475 dirOffset = (dDir-1)*numPointsBuffer;
1476 metricOffset = (metricComponent-1)*numPointsBuffer;
1482 &jacobianMatrix2[0],&
gridMetric[metricOffset]);
1484 dirOffset = (dDir-1)*numPointsBuffer;
1498 &fortranBufferInterval[0],x_zeta,yData,&jacobianMatrix2[0]);
1501 &fortranBufferInterval[0],x_xi,yData,&jacobianMatrix2[
numPointsBuffer]);
1504 metricComponent = 6;
1505 dirOffset = (dDir-1)*numPointsBuffer;
1506 metricOffset = (metricComponent-1)*numPointsBuffer;
1512 &jacobianMatrix2[0],&
gridMetric[metricOffset]);
1514 dirOffset = (dDir-1)*numPointsBuffer;
1529 &fortranBufferInterval[0],y_xi,zData,&jacobianMatrix2[0]);
1532 &fortranBufferInterval[0],y_eta,zData,&jacobianMatrix2[
numPointsBuffer]);
1535 metricComponent = 7;
1536 dirOffset = (dDir-1)*numPointsBuffer;
1537 metricOffset = (metricComponent-1)*numPointsBuffer;
1543 &jacobianMatrix2[0],&
gridMetric[metricOffset]);
1545 dirOffset = (dDir-1)*numPointsBuffer;
1559 &fortranBufferInterval[0],z_xi,xData,&jacobianMatrix2[0]);
1562 &fortranBufferInterval[0],z_eta,xData,&jacobianMatrix2[
numPointsBuffer]);
1565 metricComponent = 8;
1566 dirOffset = (dDir-1)*numPointsBuffer;
1567 metricOffset = (metricComponent-1)*numPointsBuffer;
1573 &jacobianMatrix2[0],&
gridMetric[metricOffset]);
1575 dirOffset = (dDir-1)*numPointsBuffer;
1589 &fortranBufferInterval[0],x_xi,yData,&jacobianMatrix2[0]);
1592 &fortranBufferInterval[0],x_eta,yData,&jacobianMatrix2[
numPointsBuffer]);
1595 metricComponent = 9;
1596 dirOffset = (dDir-1)*numPointsBuffer;
1597 metricOffset = (metricComponent-1)*numPointsBuffer;
1603 &jacobianMatrix2[0],&
gridMetric[metricOffset]);
1605 dirOffset = (dDir-1)*numPointsBuffer;
1620 int *inStencilConnectivity)
1638 if(gridSizes.empty() || bufferSizes.empty() ||
1639 (partInterval.
NNodes() == 0) || (partitionBufferInterval.
NNodes() == 0)){
1640 messageStream <<
"grid::PBS::GenerateCoordinates: Error: Grid sizes not set up." 1642 <<
"grid::PBS::GenerateCoordinates: Finalize() must be called before GenerateCoordinates." 1647 int numDim = gridSizes.size();
1649 if(gridExtents.size() != 2*
numDim){
1650 messageStream <<
"grid::PBS::GenerateCoordinates: Warning: Defaulting to physical extent [0:1] for all dimensions." 1652 gridExtents.resize(2*numDim,0);
1653 dX.resize(numDim,0);
1654 for(
int iDim = 0;iDim <
numDim;iDim++){
1655 gridExtents[2*iDim+1] = 1.0;
1656 dX[iDim] = 1.0/(double(gridSizes[iDim]-1));
1661 dX.resize(numDim,0);
1662 for(
int iDim = 0;iDim <
numDim;iDim++){
1663 dX[iDim] = (gridExtents[2*iDim+1] - gridExtents[2*iDim])/(
double(gridSizes[iDim]-1));
1670 messageStream <<
"grid::PBS::GenerateCoordinates: Using scalefactors (";
1672 messageStream <<
")" << std::endl;
1673 for(
int iDim = 0;iDim <
numDim;iDim++){
1680 bool isCartesian =
true;
1681 for(
int iDim = 0;iDim < numDim-1;iDim++){
1682 if(
dX[iDim] !=
dX[iDim+1])
1683 isCartesian =
false;
1695 for(
int iDim = 0;iDim <
numDim;iDim++){
1703 messageStream <<
"grid::PBS::GenerateCoordinates: Generating coordinates for " 1705 <<
"grid." << std::endl;
1709 size_t bufferPlane = bufferSizes[0]*bufferSizes[1];
1710 size_t bufferLine = bufferSizes[0];
1712 size_t xStart = partInterval[0].first;
1713 size_t xEnd = partInterval[0].second;
1714 size_t yStart = partInterval[1].first;
1715 size_t yEnd = partInterval[1].second;
1716 size_t zStart = partInterval[2].first;
1717 size_t zEnd = partInterval[2].second;
1719 size_t iStart = partitionBufferInterval[0].first;
1720 size_t iEnd = partitionBufferInterval[0].second;
1721 size_t jStart = partitionBufferInterval[1].first;
1722 size_t jEnd = partitionBufferInterval[1].second;
1723 size_t kStart = partitionBufferInterval[2].first;
1724 size_t kEnd = partitionBufferInterval[2].second;
1726 size_t kIndex = kStart;
1727 size_t zIndex = zStart;
1729 for(kIndex = kStart,zIndex = zStart;kIndex <= kEnd;kIndex++,zIndex++){
1730 size_t jIndex = jStart;
1731 size_t yIndex = yStart;
1732 size_t bzIndex = kIndex * (bufferPlane);
1734 for(jIndex = jStart,yIndex = yStart;jIndex <= jEnd;jIndex++,yIndex++){
1735 size_t iIndex = iStart;
1736 size_t xIndex = xStart;
1737 size_t byzIndex = bzIndex + jIndex*bufferLine;
1739 for(iIndex = iStart,xIndex = xStart;iIndex <= iEnd;iIndex++,xIndex++){
1740 size_t bufferIndex = byzIndex + iIndex;
1748 }
else if (numDim == 2) {
1750 size_t bufferLine = bufferSizes[0];
1752 size_t xStart = partInterval[0].first;
1753 size_t xEnd = partInterval[0].second;
1754 size_t yStart = partInterval[1].first;
1755 size_t yEnd = partInterval[1].second;
1757 size_t iStart = partitionBufferInterval[0].first;
1758 size_t iEnd = partitionBufferInterval[0].second;
1759 size_t jStart = partitionBufferInterval[1].first;
1760 size_t jEnd = partitionBufferInterval[1].second;
1762 size_t jIndex = jStart;
1763 size_t yIndex = yStart;
1764 for(jIndex = jStart,yIndex = yStart;jIndex <= jEnd;jIndex++,yIndex++){
1765 size_t iIndex = iStart;
1766 size_t xIndex = xStart;
1767 size_t byIndex = jIndex*bufferLine;
1769 for(iIndex = iStart,xIndex = xStart;iIndex <= iEnd;iIndex++,xIndex++){
1770 size_t bufferIndex = byIndex + iIndex;
1771 double xCoordinate = xIndex*
dX[0] + physicalExtent[0];
1776 }
else if (numDim == 1) {
1779 size_t xStart = partInterval[0].first;
1780 size_t xEnd = partInterval[0].second;
1782 size_t iStart = partitionBufferInterval[0].first;
1783 size_t iEnd = partitionBufferInterval[0].second;
1785 size_t iIndex = iStart;
1786 size_t xIndex = xStart;
1787 for(iIndex = iStart,xIndex = xStart;iIndex <= iEnd;iIndex++,xIndex++){
1800 if(bufferSizes.empty() ||
1801 (partitionBufferInterval.
NNodes() == 0) ||
1808 std::vector<size_t> myIndices;
1809 bufferInterval.
GetFlatIndices(partitionBufferInterval,myIndices);
1810 std::vector<size_t>::const_iterator indexIt = myIndices.begin();
1812 while(indexIt != myIndices.end()){
1813 const size_t myIndex(*indexIt++);
1814 if(
flagData[myIndex] == flagValue){
1815 iMask[myIndex] |= flagBit;
1823 (
const std::vector<int> &,
1824 const std::vector<double> &,
1825 const std::vector<size_t> &,
1826 const std::vector<size_t> &,
1827 std::vector<double> &),
1828 std::ostream &messageStream)
1841 if(gridSizes.empty() || bufferSizes.empty() ||
1842 (partInterval.
NNodes() == 0) || (partitionBufferInterval.
NNodes() == 0)){
1843 messageStream <<
"grid::PBS::GenerateGrid: Error: Grid sizes not set up." 1845 <<
"grid::PBS::GenerateGrid: Finalize() must be called before GenerateGrid." 1850 int numDim = gridSizes.size();
1854 std::vector<double> xyz(numDim,0);
1855 std::vector<size_t> ijk(numDim,0);
1857 size_t iIndex,jIndex,kIndex,xIndex,yIndex,zIndex;
1862 size_t bufferPlane = bufferSizes[0]*bufferSizes[1];
1863 size_t bufferLine = bufferSizes[0];
1865 size_t xStart = partInterval[0].first;
1866 size_t xEnd = partInterval[0].second;
1867 size_t yStart = partInterval[1].first;
1868 size_t yEnd = partInterval[1].second;
1869 size_t zStart = partInterval[2].first;
1870 size_t zEnd = partInterval[2].second;
1872 size_t iStart = partitionBufferInterval[0].first;
1873 size_t iEnd = partitionBufferInterval[0].second;
1874 size_t jStart = partitionBufferInterval[1].first;
1875 size_t jEnd = partitionBufferInterval[1].second;
1876 size_t kStart = partitionBufferInterval[2].first;
1877 size_t kEnd = partitionBufferInterval[2].second;
1879 for(kIndex = kStart,zIndex = zStart;kIndex <= kEnd;kIndex++,zIndex++){
1880 size_t bzIndex = kIndex * (bufferPlane);
1882 for(jIndex = jStart,yIndex = yStart;jIndex <= jEnd;jIndex++,yIndex++){
1884 size_t byzIndex = bzIndex + jIndex*bufferLine;
1885 for(iIndex = iStart,xIndex = xStart;iIndex <= iEnd;iIndex++,xIndex++){
1887 size_t bufferIndex = byzIndex + iIndex;
1888 int errorCode = GridGeneratorFunction(gridGenerationOptions,gridGenerationParameters,gridSizes,ijk,xyz);
1890 messageStream <<
"grid::GenerateGrid: User-specified GridGeneratorFunction" 1891 <<
" returned error code (" << errorCode <<
"). Aborting." << std::endl;
1900 }
else if (numDim == 2) {
1902 size_t bufferLine = bufferSizes[0];
1904 size_t xStart = partInterval[0].first;
1905 size_t xEnd = partInterval[0].second;
1906 size_t yStart = partInterval[1].first;
1907 size_t yEnd = partInterval[1].second;
1909 size_t iStart = partitionBufferInterval[0].first;
1910 size_t iEnd = partitionBufferInterval[0].second;
1911 size_t jStart = partitionBufferInterval[1].first;
1912 size_t jEnd = partitionBufferInterval[1].second;
1914 for(jIndex = jStart,yIndex = yStart;jIndex <= jEnd;jIndex++,yIndex++){
1915 size_t byIndex = jIndex*bufferLine;
1917 for(iIndex = iStart,xIndex = xStart;iIndex <= iEnd;iIndex++,xIndex++){
1919 size_t bufferIndex = byIndex + iIndex;
1920 int errorCode = GridGeneratorFunction(gridGenerationOptions,gridGenerationParameters,gridSizes,ijk,xyz);
1922 messageStream <<
"grid::GenerateGrid: User-specified GridGeneratorFunction" 1923 <<
" returned error code (" << errorCode <<
"). Aborting." << std::endl;
1930 }
else if (numDim == 1) {
1933 size_t xStart = partInterval[0].first;
1934 size_t xEnd = partInterval[0].second;
1936 size_t iStart = partitionBufferInterval[0].first;
1937 size_t iEnd = partitionBufferInterval[0].second;
1938 for(iIndex = iStart,xIndex = xStart;iIndex <= iEnd;iIndex++,xIndex++){
1940 int errorCode = GridGeneratorFunction(gridGenerationOptions,gridGenerationParameters,gridSizes,ijk,xyz);
1942 messageStream <<
"grid::GenerateGrid: User-specified GridGeneratorFunction" 1943 <<
" returned error code (" << errorCode <<
"). Aborting." << std::endl;
1953 (
const std::vector<size_t> &ijk,std::vector<double> &xyz),
1954 std::ostream &messageStream)
1964 if(gridSizes.empty() || bufferSizes.empty() ||
1965 (partInterval.
NNodes() == 0) || (partitionBufferInterval.
NNodes() == 0)){
1966 messageStream <<
"grid::PBS::GenerateCoordinates: Error: Grid sizes not set up." 1968 <<
"grid::PBS::GenerateCoordinates: Finalize() must be called before GenerateCoordinates." 1973 int numDim = gridSizes.size();
1977 std::vector<double> xyz(numDim,0);
1978 std::vector<size_t> ijk(numDim,0);
1980 size_t iIndex,jIndex,kIndex,xIndex,yIndex,zIndex;
1985 size_t bufferPlane = bufferSizes[0]*bufferSizes[1];
1986 size_t bufferLine = bufferSizes[0];
1988 size_t xStart = partInterval[0].first;
1989 size_t xEnd = partInterval[0].second;
1990 size_t yStart = partInterval[1].first;
1991 size_t yEnd = partInterval[1].second;
1992 size_t zStart = partInterval[2].first;
1993 size_t zEnd = partInterval[2].second;
1995 size_t iStart = partitionBufferInterval[0].first;
1996 size_t iEnd = partitionBufferInterval[0].second;
1997 size_t jStart = partitionBufferInterval[1].first;
1998 size_t jEnd = partitionBufferInterval[1].second;
1999 size_t kStart = partitionBufferInterval[2].first;
2000 size_t kEnd = partitionBufferInterval[2].second;
2002 for(kIndex = kStart,zIndex = zStart;kIndex <= kEnd;kIndex++,zIndex++){
2003 size_t bzIndex = kIndex * (bufferPlane);
2005 for(jIndex = jStart,yIndex = yStart;jIndex <= jEnd;jIndex++,yIndex++){
2007 size_t byzIndex = bzIndex + jIndex*bufferLine;
2008 for(iIndex = iStart,xIndex = xStart;iIndex <= iEnd;iIndex++,xIndex++){
2010 size_t bufferIndex = byzIndex + iIndex;
2011 int errorCode = XYZFunction(ijk,xyz);
2013 messageStream <<
"grid::GenerateCoordinates: User-specified XYZ function returned error code (" 2014 << errorCode <<
"). Aborting." << std::endl;
2023 }
else if (numDim == 2) {
2025 size_t bufferLine = bufferSizes[0];
2027 size_t xStart = partInterval[0].first;
2028 size_t xEnd = partInterval[0].second;
2029 size_t yStart = partInterval[1].first;
2030 size_t yEnd = partInterval[1].second;
2032 size_t iStart = partitionBufferInterval[0].first;
2033 size_t iEnd = partitionBufferInterval[0].second;
2034 size_t jStart = partitionBufferInterval[1].first;
2035 size_t jEnd = partitionBufferInterval[1].second;
2037 for(jIndex = jStart,yIndex = yStart;jIndex <= jEnd;jIndex++,yIndex++){
2038 size_t byIndex = jIndex*bufferLine;
2040 for(iIndex = iStart,xIndex = xStart;iIndex <= iEnd;iIndex++,xIndex++){
2042 size_t bufferIndex = byIndex + iIndex;
2043 int errorCode = XYZFunction(ijk,xyz);
2045 messageStream <<
"grid::GenerateCoordinates: User-specified XYZ function returned error code (" 2046 << errorCode <<
"). Aborting." << std::endl;
2053 }
else if (numDim == 1) {
2056 size_t xStart = partInterval[0].first;
2057 size_t xEnd = partInterval[0].second;
2059 size_t iStart = partitionBufferInterval[0].first;
2060 size_t iEnd = partitionBufferInterval[0].second;
2061 for(iIndex = iStart,xIndex = xStart;iIndex <= iEnd;iIndex++,xIndex++){
2063 int errorCode = XYZFunction(ijk,xyz);
2065 messageStream <<
"grid::GenerateCoordinates: User-specified XYZ function returned error code (" 2066 << errorCode <<
"). Aborting." << std::endl;
2087 std::vector<int> cartNeighbors;
2115 for(
int iDim = 0;iDim <
numDim;iDim++){
2117 size_t lastIndex = gridSizes[iDim] - 1;
2122 if(partitionInterval[iDim].first == 0){
2125 leftHaloInterval[iDim].second = partitionBufferInterval[iDim].first - 1;
2126 leftHaloInterval[iDim].first = 0;
2127 std::vector<size_t> haloIndices;
2129 std::vector<size_t>::iterator haloIndexIt = haloIndices.begin();
2130 while(haloIndexIt != haloIndices.end()){
2131 size_t haloIndex = *haloIndexIt++;
2137 if(partitionInterval[iDim].second == lastIndex) {
2140 rightHaloInterval[iDim].first = partitionBufferInterval[iDim].second + 1;
2141 rightHaloInterval[iDim].second = bufferSizes[iDim]-1;
2142 std::vector<size_t> haloIndices;
2144 std::vector<size_t>::iterator haloIndexIt = haloIndices.begin();
2145 while(haloIndexIt != haloIndices.end()){
2146 size_t haloIndex = *haloIndexIt++;
2167 messageStream <<
"grid::PBS::ExchangeJacobianMatrix: Error: jacobianMatrix of improper size (" 2179 bool inParallel =
false;
2182 inParallel = omp_in_parallel();
2184 threadId = omp_get_thread_num();
2185 numThreads = omp_get_num_threads();
2189 bool masterThread = (threadId == 0);
2203 std::vector<bool> partDims(numDim,
true);
2208 partDims[iDim] =
false;
2215 threadPartitionInterval,numThreadPartitions)){
2230 for(
int iDim = 0;iDim <
numDim;iDim++){
2231 threadPartitionBufferInterval[iDim].first -= partitionInterval[iDim].first;
2232 threadPartitionBufferInterval[iDim].second -= partitionInterval[iDim].first;
2233 threadPartitionBufferInterval[iDim].first += partitionBufferInterval[iDim].first;
2234 threadPartitionBufferInterval[iDim].second += partitionBufferInterval[iDim].first;
2236 threadPartitionBufferInterval.
Sync();
2240 for(
int iDim = 0;iDim <
numDim;iDim++){
2241 if(threadBufferInterval[iDim].first == partitionBufferInterval[iDim].first)
2242 threadBufferInterval[iDim].first = 0;
2243 if(threadBufferInterval[iDim].second == partitionBufferInterval[iDim].second)
2244 threadBufferInterval[iDim].second = bufferSizes[iDim]-1;
2246 threadBufferInterval.
Sync();
2259 std::vector<subregion>::iterator subRegionIt =
subRegions.begin();
2264 if(subPartitionInterval.
NNodes() == 0)
2267 size_t numNodesOverlap = subPartitionInterval.
NNodes();
2269 if(numNodesOverlap > 0){
2272 subPartBufferInterval = subPartitionInterval;
2274 for(
int iDim = 0;iDim <
numDim;iDim++){
2275 subPartBufferInterval[iDim].first -= partitionInterval[iDim].first;
2276 subPartBufferInterval[iDim].second -= partitionInterval[iDim].first;
2277 subPartBufferInterval[iDim].first += partitionBufferInterval[iDim].first;
2278 subPartBufferInterval[iDim].second += partitionBufferInterval[iDim].first;
2280 subPartBufferInterval.
Sync();
2284 bufferInterval.
GetFlatIndices(subPartBufferInterval,subThreadBufferIndices);
2297 std::vector<subregion>::iterator srIt =
subRegions.begin();
2305 if(numThreads == 1){
2308 std::vector<subregion>::iterator srIt =
subRegions.begin();
2336 for(
int iDim = 0;iDim <
numDim;iDim++){
2344 for(
int iDim = 0;iDim <
numDim;iDim++){
2359 for(
int iDim = 0;iDim <
numDim;iDim++){
2374 std::vector<subregion>::iterator subRegionIt =
subRegions.begin();
2379 if(numNodesOverlap > 0){
2381 for(
int iDim = 0;iDim <
numDim;iDim++){
2382 size_t nPointsRegionDim =
2396 if(allocateCoordinateData)
2401 bool inParallel =
false;
2404 inParallel = omp_in_parallel();
2406 numThreads = omp_get_num_threads();
2425 localBufferSizes = inBufferSizes;
2427 std::vector<size_t>::iterator bsIt = localBufferSizes.begin();
2428 while(bsIt != localBufferSizes.end())
2434 remoteHaloExtents = haloExtents;
2435 if(!localPartitionExtent.empty()){
2436 int numDim = haloExtents.size()/2;
2437 remoteHaloBufferExtents.resize(2*numDim);
2438 for(
int iDim = 0;iDim <
numDim;iDim++){
2440 if(leftHaloExtent.
NNodes() > 0){
2441 int haloSize = leftHaloExtent[iDim].second - leftHaloExtent[iDim].first + 1;
2443 remoteHaloBufferExtent[iDim].first = 0;
2444 remoteHaloBufferExtent[iDim].second = haloSize - 1;
2445 remoteHaloBufferExtents[iDim*2].
Copy(remoteHaloBufferExtent);
2448 if(rightHaloExtent.
NNodes() > 0){
2449 int haloSize = rightHaloExtent[iDim].second - rightHaloExtent[iDim].first + 1;
2451 remoteHaloBufferExtent[iDim].second = localBufferSizes[iDim] - 1;
2452 remoteHaloBufferExtent[iDim].first = remoteHaloBufferExtent[iDim].second - haloSize + 1;
2453 remoteHaloBufferExtents[iDim*2+1].
Copy(remoteHaloBufferExtent);
2463 threadExtents[myThreadId] = threadInterval;
2464 if(!localPartitionExtent.empty()){
2465 int numDim = threadInterval.size();
2467 threadBufferExtent = (threadInterval - globalPartitionExtent);
2468 threadBufferExtent += localPartitionExtent;
2469 for(
int iDim = 0;iDim <
numDim;iDim++){
2470 if(threadBufferExtent[iDim].first == localPartitionExtent[iDim].first){
2471 threadBufferExtent[iDim].first = 0;
2473 if(threadBufferExtent[iDim].second == localPartitionExtent[iDim].second)
2474 threadBufferExtent[iDim].second = localBufferSizes[iDim] - 1;
2481 numThreads = numThreadsIn;
2482 threadExtents.resize(numThreads,globalPartitionExtent);
2483 threadBufferExtents.resize(numThreads,localPartitionExtent);
2484 threadSendIndices.resize(numThreads);
2485 threadSendBufferIndices.resize(numThreads);
2486 threadRecvIndices.resize(numThreads);
2487 threadRecvBufferIndices.resize(numThreads);
2488 threadHaloBufferIndices.resize(numThreads);
2494 localHaloExtents = haloExtents;
2495 if(!localPartitionExtent.empty()){
2497 int numDim = haloExtents.size();
2498 localHaloBufferExtents.resize(numDim);
2499 for(
int iDim = 0;iDim <
numDim;iDim++){
2504 subThreadSendExtent += localPartitionExtent;
2506 localHaloBufferExtents[iDim].
Copy(subThreadSendExtent);
2515 std::vector<size_t> &haloSizes)
2517 std::vector<pcpp::IndexIntervalType> haloExtents;
2518 int numDim = haloSizes.size()/2;
2519 haloExtents.resize(numDim*2);
2520 for(
int iDim = 0;iDim <
numDim;iDim++){
2521 size_t numNodesDim = partitionExtent[iDim].second - partitionExtent[iDim].first + 1;
2522 bool leftHaloRequired =
false;
2523 if(haveNeighbor.empty()){
2524 if(partitionExtent[iDim].first > globalExtent[iDim].first)
2525 leftHaloRequired =
true;
2526 }
else if (haveNeighbor[2*iDim]) {
2527 leftHaloRequired =
true;
2529 if(leftHaloRequired){
2530 size_t haloSize = haloSizes[iDim*2];
2534 assert(haloSize < numNodesDim);
2535 for(
int hDim = 0;hDim <
numDim;hDim++){
2537 if(partitionExtent[iDim].first == 0){
2538 leftHaloExtent[hDim].first = globalExtent[iDim].second - haloSize + 1;
2539 leftHaloExtent[hDim].second = globalExtent[iDim].second;
2541 leftHaloExtent[hDim].first = partitionExtent[iDim].first - haloSize;
2542 leftHaloExtent[hDim].second = leftHaloExtent[hDim].first + haloSize - 1;
2545 leftHaloExtent[hDim] = partitionExtent[hDim];
2548 haloExtents[iDim*2].Copy(leftHaloExtent);
2551 bool rightHaloRequired =
false;
2552 if(haveNeighbor.empty()){
2553 if(partitionExtent[iDim].second < globalExtent[iDim].second)
2554 rightHaloRequired =
true;
2555 }
else if (haveNeighbor[2*iDim+1]) {
2556 rightHaloRequired =
true;
2559 if(rightHaloRequired){
2560 size_t haloSize = haloSizes[iDim*2+1];
2564 assert(haloSize < numNodesDim);
2565 for(
int hDim = 0;hDim <
numDim;hDim++){
2567 if(partitionExtent[iDim].second == globalExtent[iDim].second){
2568 rightHaloExtent[hDim].second = globalExtent[iDim].first + haloSize - 1;
2569 rightHaloExtent[hDim].first = globalExtent[iDim].first;
2571 rightHaloExtent[hDim].first = partitionExtent[iDim].second + 1;
2572 rightHaloExtent[hDim].second = rightHaloExtent[hDim].first + haloSize - 1;
2575 rightHaloExtent[hDim] = partitionExtent[hDim];
2578 haloExtents[iDim*2+1].Copy(rightHaloExtent);
2581 return(haloExtents);
2586 std::vector<pcpp::IndexIntervalType> haloExtents(CreateRemoteHaloExtents(globalGridExtent,globalPartitionExtent,haloSizes));
2587 return(haloExtents);
2594 std::vector<size_t> &haloSizes)
2596 std::vector<pcpp::IndexIntervalType> haloExtents;
2597 int numDim = haloSizes.size()/2;
2598 haloExtents.resize(numDim*2);
2599 for(
int iDim = 0;iDim <
numDim;iDim++){
2600 size_t numNodesDim = partitionExtent[iDim].second - partitionExtent[iDim].first + 1;
2601 bool leftHaloRequired =
false;
2602 if(haveNeighbor.empty()){
2603 if(partitionExtent[iDim].first > globalExtent[iDim].first)
2604 leftHaloRequired =
true;
2605 }
else if (haveNeighbor[iDim*2]) {
2606 leftHaloRequired =
true;
2608 if(leftHaloRequired){
2609 size_t haloSize = haloSizes[iDim*2];
2613 assert(haloSize < numNodesDim);
2614 for(
int hDim = 0;hDim <
numDim;hDim++){
2616 leftHaloExtent[hDim].first = partitionExtent[iDim].first;
2617 leftHaloExtent[hDim].second = leftHaloExtent[hDim].first + haloSize - 1;
2619 leftHaloExtent[hDim] = partitionExtent[hDim];
2622 haloExtents[iDim*2].Copy(leftHaloExtent);
2624 bool rightHaloRequired =
false;
2625 if(haveNeighbor.empty()){
2626 if(partitionExtent[iDim].second < globalExtent[iDim].second)
2627 rightHaloRequired =
true;
2628 }
else if(haveNeighbor[2*iDim+1]) {
2629 rightHaloRequired =
true;
2631 if(rightHaloRequired){
2632 size_t haloSize = haloSizes[iDim*2+1];
2636 assert(haloSize < numNodesDim);
2637 for(
int hDim = 0;hDim <
numDim;hDim++){
2639 rightHaloExtent[hDim].first = partitionExtent[iDim].second - haloSize + 1;
2640 rightHaloExtent[hDim].second = partitionExtent[hDim].second;
2642 rightHaloExtent[hDim] = partitionExtent[hDim];
2645 haloExtents[iDim*2+1].Copy(rightHaloExtent);
2648 return(haloExtents);
2653 std::vector<pcpp::IndexIntervalType> haloExtents(CreateLocalHaloExtents(globalGridExtent,globalPartitionExtent,haloSizes));
2654 return(haloExtents);
2661 haveSendData =
false;
2662 size_t totalNumSend = 0;
2663 if(localHaloExtents.empty())
2666 int numSendIntervals = localHaloExtents.size();
2667 sendIndices.resize(numSendIntervals);
2668 for(
int i = 0;i < numSendIntervals;i++){
2669 size_t numPointsSend = localHaloExtents[i].NNodes();
2670 if(numPointsSend > 0){
2677 if(localPartitionExtent.empty()){
2679 globalPartitionExtent.GetFlatIndices(localHaloExtents[i],sendIndices[i]);
2686 subHaloExtent += localPartitionExtent;
2693 totalNumSend += numPointsSend;
2696 haveSendData = (totalNumSend > 0);
2697 return(totalNumSend);
2706 if(localHaloExtents.empty())
2708 int numSendBuffers = localHaloExtents.size();
2709 threadSendIndices[threadId].resize(numSendBuffers);
2710 threadSendBufferIndices[threadId].resize(numSendBuffers);
2712 for(
int i = 0;i < numSendBuffers;i++){
2713 size_t numSendNodes = localHaloExtents[i].NNodes();
2714 std::vector<size_t> &threadSendInds(threadSendIndices[threadId][i]);
2715 std::vector<size_t> &threadSendBufferInds(threadSendBufferIndices[threadId][i]);
2716 if(numSendNodes > 0){
2733 size_t numThreadSendNodes = threadSendInterval.
NNodes();
2734 if(numThreadSendNodes > 0){
2746 if(localPartitionExtent.empty()){
2747 globalPartitionExtent.GetFlatIndices(threadSendInterval,threadSendInds);
2753 subThreadSendExtent += localPartitionExtent;
2757 bufferInterval.
GetFlatIndices(subThreadSendExtent,threadSendInds);
2762 localHaloExtents[i].GetFlatIndices(threadSendInterval,threadSendBufferInds);
2763 if(threadSendInds.size() != numThreadSendNodes){
2777 haveRecvData =
false;
2778 if(remoteHaloExtents.empty()){
2779 std::cout <<
"halo::CreateSimpleRecvBuffers: WARNING No remote halos." << std::endl;
2783 size_t totalNumRecv = 0;
2784 int numRecvIntervals = remoteHaloExtents.size();
2786 recvIndices.resize(numRecvIntervals);
2787 for(
int i = 0;i < numRecvIntervals;i++){
2788 std::vector<size_t> &recvIndex(recvIndices[i]);
2789 size_t numRemoteHaloNodes = remoteHaloExtents[i].NNodes();
2790 if(numRemoteHaloNodes > 0){
2791 if(localPartitionExtent.empty()){
2792 remoteHaloExtents[i].GetFlatIndices(remoteHaloExtents[i],recvIndex);
2795 localBufferExtent.
InitSimple(localBufferSizes);
2796 localBufferExtent.
GetFlatIndices(remoteHaloBufferExtents[i],recvIndex);
2798 assert(recvIndex.size() == remoteHaloExtents[i].NNodes());
2800 totalNumRecv += numRemoteHaloNodes;
2803 haveRecvData = (totalNumRecv > 0);
2804 return(totalNumRecv);
2812 messageId = communicationBuffers.size() - 1;
2813 }
else if(messageId != communicationBuffers.size() - 1){
2818 int numCommunicationBorders = recvIndices.size();
2820 for(
int iComm = 0;iComm < numCommunicationBorders;iComm++){
2821 std::vector<double *>::iterator mbIt = lastMessage.
sendBuffers.begin();
2833 std::vector<int *>::iterator fmbIt = lastMessage.
sendFlagBuffers.begin();
2846 communicationBuffers.pop_back();
2853 int numCommuncationBorders = recvIndices.size();
2854 if(numCommuncationBorders != sendIndices.size())
2856 int messageId = communicationBuffers.size();
2860 if(componentSize == 8) {
2861 newMessageBuffers.
sendBuffers.resize(numCommuncationBorders);
2862 newMessageBuffers.
recvBuffers.resize(numCommuncationBorders);
2867 newMessageBuffers.
numPointsSend.resize(numCommuncationBorders);
2868 newMessageBuffers.
numPointsRecv.resize(numCommuncationBorders);
2870 for(
int iComm = 0;iComm < numCommuncationBorders;iComm++){
2871 int numRecv = recvIndices[iComm].size();
2872 int numSend = sendIndices[iComm].size();
2875 if(componentSize == 8){
2876 newMessageBuffers.
sendBuffers[iComm] =
new double [numComponents * numSend];
2877 newMessageBuffers.
recvBuffers[iComm] =
new double [numComponents * numRecv];
2879 newMessageBuffers.
sendFlagBuffers[iComm] =
new int [numComponents * numSend];
2880 newMessageBuffers.
recvFlagBuffers[iComm] =
new int [numComponents * numRecv];
2883 communicationBuffers.push_back(newMessageBuffers);
2889 std::vector<messagebuffers>::iterator msgBufIt =
2890 communicationBuffers.begin();
2891 while(msgBufIt != communicationBuffers.end()){
2893 std::vector<double *>::iterator bufIt = msgBuffer.
sendBuffers.begin();
2909 std::vector<int *>::iterator flagBufIt = msgBuffer.
sendFlagBuffers.begin();
2911 if(*flagBufIt != NULL){
2912 delete [] *flagBufIt;
2919 if(*flagBufIt != NULL){
2920 delete [] *flagBufIt;
2940 assert(messageId < communicationBuffers.size());
2942 assert((componentId+numComponents) <= messageBuffers.numComponents);
2943 int numMessages = sendIndices.size();
2944 for(
int iMessage = 0;iMessage < numMessages;iMessage++){
2945 std::vector<size_t> &sendIndex(sendIndices[iMessage]);
2946 size_t numSend = sendIndex.size();
2947 for(
int componentIndex = 0;componentIndex <
numComponents;componentIndex++){
2948 for(
size_t pointIndex = 0;pointIndex < numSend;pointIndex++){
2949 size_t sendBufferIndex = pointIndex + (componentId+componentIndex)*numSend;
2951 messageBuffers.sendBuffers[iMessage][sendBufferIndex] =
2952 sourceBuffer[sourceBufferIndex+sendIndex[pointIndex]];
2972 assert(messageId < communicationBuffers.size());
2974 assert((componentId+numComponents) <= messageBuffers.numComponents);
2975 assert(messageBuffers.componentSize == 4);
2976 int numMessages = sendIndices.size();
2977 for(
int iMessage = 0;iMessage < numMessages;iMessage++){
2978 std::vector<size_t> &sendIndex(sendIndices[iMessage]);
2979 size_t numSend = sendIndex.size();
2980 for(
int componentIndex = 0;componentIndex <
numComponents;componentIndex++){
2981 for(
size_t pointIndex = 0;pointIndex < numSend;pointIndex++){
2982 size_t sendBufferIndex = pointIndex + (componentId+componentIndex)*numSend;
2984 messageBuffers.sendFlagBuffers[iMessage][sendBufferIndex] =
2985 sourceBuffer[sourceBufferIndex+sendIndex[pointIndex]];
3005 assert(messageId < communicationBuffers.size());
3007 assert((componentId+numComponents) <= messageBuffers.numComponents);
3008 int numMessages = sendIndices.size();
3009 for(
int iMessage = 0;iMessage < numMessages;iMessage++){
3010 std::vector<size_t> &threadSendIndex(threadSendIndices[threadId][iMessage]);
3011 std::vector<size_t> &threadSendBufferIndex(threadSendBufferIndices[threadId][iMessage]);
3012 std::vector<size_t> &sendIndex(sendIndices[iMessage]);
3013 size_t numThreadSend = threadSendIndex.size();
3014 size_t numSend = sendIndex.size();
3015 for(
int componentIndex = 0;componentIndex <
numComponents;componentIndex++){
3016 for(
size_t pointIndex = 0;pointIndex < numThreadSend;pointIndex++){
3017 size_t sendBufferIndex = threadSendBufferIndex[pointIndex] + (componentId+componentIndex)*numSend;
3018 size_t sourceBufferIndex = componentIndex*
numPointsBuffer + threadSendIndex[pointIndex];
3019 messageBuffers.sendBuffers[iMessage][sendBufferIndex] = sourceBuffer[sourceBufferIndex];
3039 assert(messageId < communicationBuffers.size());
3041 assert((componentId+numComponents) <= messageBuffers.numComponents);
3042 assert(messageBuffers.componentSize == 4);
3043 int numMessages = sendIndices.size();
3044 for(
int iMessage = 0;iMessage < numMessages;iMessage++){
3045 std::vector<size_t> &threadSendIndex(threadSendIndices[threadId][iMessage]);
3046 std::vector<size_t> &threadSendBufferIndex(threadSendBufferIndices[threadId][iMessage]);
3047 std::vector<size_t> &sendIndex(sendIndices[iMessage]);
3048 size_t numThreadSend = threadSendIndex.size();
3049 size_t numSend = sendIndex.size();
3050 for(
int componentIndex = 0;componentIndex <
numComponents;componentIndex++){
3051 for(
size_t pointIndex = 0;pointIndex < numThreadSend;pointIndex++){
3052 size_t sendBufferIndex = threadSendBufferIndex[pointIndex] + (componentId+componentIndex)*numSend;
3053 size_t sourceBufferIndex = componentIndex*
numPointsBuffer + threadSendIndex[pointIndex];
3054 messageBuffers.sendFlagBuffers[iMessage][sendBufferIndex] = sourceBuffer[sourceBufferIndex];
3064 assert(messageId < communicationBuffers.size());
3066 int componentSize = messageBuffers.componentSize;
3067 int numMessages = neighborRanks.size();
3070 if(componentSize == 8){
3071 assert(numMessages == messageBuffers.sendBuffers.size());
3073 assert(numMessages == messageBuffers.sendFlagBuffers.size());
3075 int messageTagBase = messageId*100;
3076 for(
int iMessage = 0;iMessage < numMessages;iMessage++){
3077 int remoteRank = neighborRanks[iMessage];
3078 if(remoteRank >= 0){
3079 int numPointsSend = messageBuffers.numPointsSend[iMessage];
3081 int messageTag = messageTagBase + iMessage;
3084 if(componentSize == 8) {
3085 double *sendBuffer = messageBuffers.sendBuffers[iMessage];
3086 inComm.
ASendBuf(sendBuffer,numSendItems,remoteRank,messageTag);
3088 int *sendBuffer = messageBuffers.sendFlagBuffers[iMessage];
3089 inComm.
ASendBuf(sendBuffer,numSendItems,remoteRank,messageTag);
3099 assert(messageId < communicationBuffers.size());
3101 int componentSize = messageBuffers.componentSize;
3102 int numMessages = neighborRanks.size();
3105 if(componentSize == 8)
3106 assert(numMessages == messageBuffers.recvBuffers.size());
3108 assert(numMessages == messageBuffers.recvFlagBuffers.size());
3109 int messageTagBase = messageId*100;
3110 for(
int iMessage = 0;iMessage < numMessages;iMessage++){
3111 int remoteRank = neighborRanks[iMessage];
3112 if(remoteRank >= 0){
3114 int iDir = iMessage%2;
3115 int numPointsRecv = messageBuffers.numPointsSend[iMessage];
3117 int messageTag = messageTagBase + iMessage;
3122 if(componentSize == 8){
3123 double *recvBuffer = messageBuffers.recvBuffers[iMessage];
3124 inComm.
ARecvBuf(recvBuffer,numRecvItems,remoteRank,messageTag);
3126 int *recvBuffer = messageBuffers.recvFlagBuffers[iMessage];
3127 inComm.
ARecvBuf(recvBuffer,numRecvItems,remoteRank,messageTag);
3148 assert(messageId < communicationBuffers.size());
3150 assert((componentId+numComponents) <= messageBuffers.numComponents);
3151 int numMessages = recvIndices.size();
3152 for(
int iMessage = 0;iMessage < numMessages;iMessage++){
3153 std::vector<size_t> &recvIndex(recvIndices[iMessage]);
3154 size_t numRecv = recvIndex.size();
3155 for(
int componentIndex = 0;componentIndex <
numComponents;componentIndex++){
3156 for(
size_t pointIndex = 0;pointIndex < numRecv;pointIndex++){
3157 size_t recvBufferIndex = pointIndex + (componentId+componentIndex)*numRecv;
3158 size_t targetBufferIndex = componentIndex*
numPointsBuffer + recvIndex[pointIndex];
3159 targetBuffer[targetBufferIndex] = messageBuffers.recvBuffers[iMessage][recvBufferIndex];
3178 assert(messageId < communicationBuffers.size());
3180 assert((componentId+numComponents) <= messageBuffers.numComponents);
3181 assert(messageBuffers.componentSize == 4);
3182 int numMessages = recvIndices.size();
3183 for(
int iMessage = 0;iMessage < numMessages;iMessage++){
3184 std::vector<size_t> &recvIndex(recvIndices[iMessage]);
3185 size_t numRecv = recvIndex.size();
3186 for(
int componentIndex = 0;componentIndex <
numComponents;componentIndex++){
3187 for(
size_t pointIndex = 0;pointIndex < numRecv;pointIndex++){
3188 size_t recvBufferIndex = pointIndex + (componentId+componentIndex)*numRecv;
3189 size_t targetBufferIndex = componentIndex*
numPointsBuffer + recvIndex[pointIndex];
3190 targetBuffer[targetBufferIndex] = messageBuffers.recvFlagBuffers[iMessage][recvBufferIndex];
3201 assert(messageId < communicationBuffers.size());
3203 assert((componentId+numComponents) <= messageBuffers.numComponents);
3204 int numMessages = recvIndices.size();
3205 for(
int iMessage = 0;iMessage < numMessages;iMessage++){
3206 std::vector<size_t> &threadRecvIndex(threadHaloBufferIndices[threadId][iMessage]);
3207 std::vector<size_t> &threadRecvBufferIndex(threadRecvBufferIndices[threadId][iMessage]);
3208 size_t recvBufferSize = recvIndices[iMessage].size();
3209 size_t numThreadRecv = threadRecvIndex.size();
3210 for(
int componentIndex = 0;componentIndex <
numComponents;componentIndex++){
3211 for(
size_t pointIndex = 0;pointIndex < numThreadRecv;pointIndex++){
3212 size_t recvBufferIndex = threadRecvBufferIndex[pointIndex] +
3213 (componentId+componentIndex)*recvBufferSize;
3214 size_t targetBufferIndex = componentIndex*
numPointsBuffer + threadRecvIndex[pointIndex];
3215 targetBuffer[targetBufferIndex] = messageBuffers.recvBuffers[iMessage][recvBufferIndex];
3227 assert(messageId < communicationBuffers.size());
3229 assert((componentId+numComponents) <= messageBuffers.numComponents);
3230 assert(messageBuffers.componentSize == 4);
3231 int numMessages = recvIndices.size();
3232 for(
int iMessage = 0;iMessage < numMessages;iMessage++){
3233 std::vector<size_t> &threadRecvIndex(threadHaloBufferIndices[threadId][iMessage]);
3234 std::vector<size_t> &threadRecvBufferIndex(threadRecvBufferIndices[threadId][iMessage]);
3235 size_t recvBufferSize = recvIndices[iMessage].size();
3236 size_t numThreadRecv = threadRecvIndex.size();
3237 for(
int componentIndex = 0;componentIndex <
numComponents;componentIndex++){
3238 for(
size_t pointIndex = 0;pointIndex < numThreadRecv;pointIndex++){
3239 size_t recvBufferIndex = threadRecvBufferIndex[pointIndex] +
3240 (componentId+componentIndex)*recvBufferSize;
3241 size_t targetBufferIndex = componentIndex*
numPointsBuffer + threadRecvIndex[pointIndex];
3242 targetBuffer[targetBufferIndex] = messageBuffers.recvFlagBuffers[iMessage][recvBufferIndex];
3254 if(remoteHaloExtents.empty()){
3255 std::cout <<
"halo::CreateThreadRecvIndices: WARNING No remote halos." << std::endl;
3266 int numRecvBuffers = remoteHaloExtents.size();
3269 threadRecvBufferIndices[threadId].resize(numRecvBuffers);
3270 threadHaloBufferIndices[threadId].resize(numRecvBuffers);
3274 for(
int i = 0;i < numRecvBuffers;i++){
3276 int recvDirection = i/2;
3277 int recvOrientation = i%2;
3278 std::vector<size_t> recvIndices;
3283 std::vector<size_t> &threadRecvBufferIndex(threadRecvBufferIndices[threadId][i]);
3284 std::vector<size_t> &threadHaloBufferIndex(threadHaloBufferIndices[threadId][i]);
3286 if(!localPartitionExtent.empty()){
3288 localBufferExtent.
InitSimple(localBufferSizes);
3290 if(overlapInterval.NNodes() > 0){
3291 remoteHaloBufferExtent.
GetFlatIndices(overlapInterval,threadRecvBufferIndex);
3292 localBufferExtent.
GetFlatIndices(overlapInterval,threadHaloBufferIndex);
3297 size_t numRemoteHaloNodes = remoteHaloExtent.
NNodes();
3302 if(numRemoteHaloNodes > 0){
3304 if(recvOrientation){
3305 if(threadExtent[recvDirection].second != globalPartitionExtent[recvDirection].second)
3308 if(threadExtent[recvDirection].first != globalPartitionExtent[recvDirection].first)
3313 checkExtent[recvDirection] = remoteHaloExtent[recvDirection];
3315 size_t totalNumComponents = 0;
3316 size_t numThreadRecvNodes = threadRecvExtent.
NNodes();
std::vector< int * > recvFlagBuffers
pcpp::IndexIntervalType partitionBufferInterval
Partition interval wrt the local buffer dimensions.
std::vector< double > gridJacobian
void SetPartitionInterval(const pcpp::IndexIntervalType &inExtent)
pcpp::IndexIntervalType partitionInterval
Partition interval wrt the grid dimensions.
std::vector< size_t > partitionSizes
Number of points in each dimension for local partition.
pcpp::IndexIntervalType regionInterval
int SimplePartitionInterval(const pcpp::IndexIntervalType &inInterval, std::vector< bool > partDirection, int partID, int numPart, pcpp::IndexIntervalType &outInterval, std::vector< int > &numPartitions)
Multi-dimensional interval partitioning (non-MPI)
void size_t int size_t int size_t int int * stencilSizes
std::vector< std::vector< size_t > > threadPartitionBufferIndices
void GetFlatIndices(const sizeextent &extent, ContainerType &indices) const
std::vector< double > scaleFactor
Grid scaling factor.
int ExchangeCoordinates()
std::vector< int > threadDecompDirs
int CreateSimpleRecvIndices()
std::vector< pcpp::IndexIntervalType > CreateLocalHaloExtents(const pcpp::IndexIntervalType &globalExtent, const pcpp::IndexIntervalType &partitionExtent, std::vector< size_t > &haloSizes)
int ARecvBuf(DataType *recvbuf, size_t nVal, unsigned int remote_rank, int tag=0)
void Flatten(ContainerType &output) const
int * stencilSizes
The number of weights for each stencil.
int ComputeCurvilinearMetrics2D(std::ostream &messageStream)
int CartNeighbors(std::vector< int > &neighborRanks)
subroutine applyoperator(numDim, dimSizes, numComponents, numPoints, opDir, opInterval, numStencils, stencilSizes, stencilStarts, numValues, stencilWeights, stencilOffsets, stencilID, U, dU)
applyoperator applies an operator specified as a stencil set to the provided state data ...
subroutine determinant3x3(numPoints, bufferSize, bufferInterval, inMatrix, matrixDeterminant)
Computes determinant of 3x3 matrix.
std::vector< int * > sendFlagBuffers
static const char * topoNames[]
int CreateSimpleSendIndices()
Creates the flat buffer indices for each whole local halo extent.
std::vector< size_t > bufferSizes
Buffer size in each dimension.
pcpp::IndexIntervalType & PartitionInterval()
void SetNumThreads(int numThreads)
int ComputeCurvilinearMetrics3D(std::ostream &messageStream)
pcpp::IndexIntervalType regionPartitionBufferInterval
int GenerateCoordinates(std::ostream &)
void size_t int size_t int size_t int int int * stencilStarts
void const size_t const size_t * gridSizes
std::vector< double > jacobianMatrix2
std::vector< double * > recvBuffers
int GenerateGrid(int(*)(const std::vector< int > &, const std::vector< double > &, const std::vector< size_t > &, const std::vector< size_t > &, std::vector< double > &), std::ostream &)
void SetDimensionExtensions(const std::vector< size_t > &inExtensions)
int SendMessage(const int messageId, const std::vector< int > &neighborRanks, fixtures::CommunicatorType &inComm)
int * stencilStarts
The starting index into the stencilWeight and stencilOffset arrays for each stencil.
int * stencilOffsets
The offsets wrt the grid point at which the stencil is being applied.
int CurvilinearMetrics(std::ostream &messageStream)
pcpp::IndexIntervalType regionPartitionInterval
int UnPackMessageBuffers(const int messageId, const int componentId, const int numComponents, double *targetBuffer)
Unpack generic recv buffers for specified message.
void CartesianSetup(std::ostream &outStream, const std::vector< int > &cartCoords, const std::vector< int > &cartDims)
subroutine yxy(numDim, numPoints, bufferSize, bufferInterval, X, Y)
YXY point-wise operator performing Y = XY (all vectors)
std::vector< size_t > numPointsSend
std::vector< int > flagData
void SetNumThreads(int numThreadsIn)
std::vector< size_t > gridSizes
Number of points in each dimension for the grid.
std::vector< int > & GridGenerationOptions()
int ASendBuf(DataType *sendBuf, size_t nVal, unsigned int remote_rank, int tag=-1)
int GradIJK(int numComponents, double *sourceBuffer, double *targetBuffer, std::ostream &messageStream, bool exchange)
const std::vector< size_t > & BufferSizes() const
int InitSubRegionFromString(const std::string &inString, const std::vector< size_t > &gridSizes, subregion &inSubRegion)
int ComputeRectilinearMetrics(std::ostream &messageStream)
void size_t int size_t int size_t int int int int double int * stencilOffsets
size_t numPointsPartition
Number of points in the partition.
int CreateMessageBuffers(int numComponents, int componentSize=8)
std::vector< int > isPeriodic
int SetupDifferentialOperator(plascom2::operators::stencilset *inStencilSet, int *inStencilConnectivity)
int ComputeJacobianMatrix(std::ostream &messageStream)
Calculates the regular/naive Jacobian matrix d(xyz)/d(ijk)
size_t numPointsBuffer
Number of points in the buffer.
int ExchangeJacobianMatrix(std::ostream &messageStream)
pcpp::IndexIntervalType & PartitionBufferInterval()
std::vector< bool > periodicDirs
const std::vector< size_t > & GridSizes() const
int PackMessageBuffers(const int messageId, const int componentId, const int numComponents, const double *sourceBuffer)
Pack generic send buffers for specified message.
void SetLocalPartitionExtent(const pcpp::IndexIntervalType &inExtent)
std::vector< pcpp::IndexIntervalType > threadPartitionIntervals
int ComputeMetrics(std::ostream &messageStream)
size_t FlagMask(int *iMask, int flagValue=0, int flagBit=1) const
std::vector< size_t > partitionBufferIndices
std::vector< pcpp::IndexIntervalType > CreateRemoteHaloExtents(const pcpp::IndexIntervalType &globalExtent, const pcpp::IndexIntervalType &partitionExtent, std::vector< size_t > &haloSizes)
void SetRemoteHaloExtents(const std::vector< pcpp::IndexIntervalType > haloExtents)
std::vector< pcpp::IndexIntervalType > threadBufferIntervals
Buffer interval owned by each thread (omp)
void SetNeighbors(const std::vector< bool > &inNeighbors)
std::vector< double * > sendBuffers
std::vector< double > jacobianMatrix
int ComputeJacobianMatrix2(std::ostream &messageStream)
Calculates the gradient of the regular/naive J^-1 d^2(xyz)/d(ijk)^2.
void Copy(const sizeextent &inExtent)
Main encapsulation of MPI.
int ResolveTopoName(const std::string &inName)
void size_t int size_t int size_t int int int int double int int double double *void size_t int size_t int int int int int double int size_t size_t size_t double double *void size_t int size_t int size_t size_t int double int double double *void size_t size_t size_t double * a
int SetupThreads(std::vector< int > &numThreadPartitions)
Encapsulation for a collection of operator stencils.
void SetThreadExtent(int myThreadId, pcpp::IndexIntervalType threadInterval)
int numValues
The total number of weights for all stencils (reqd for Fortran)
int ComputeUniformRectangularMetrics(std::ostream &messageStream)
void Overlap(const sizeextent &inextent, sizeextent &outextent) const
std::vector< double > physicalExtent
Physical grid extent (when applicable)
std::vector< double > dX
Grid spacing data structure (size depends on gridTopoType)
int ComputeMetricIdentities(std::vector< double > &identityData, std::ostream &messageStream)
int ParallelSetup(fixtures::CommunicatorType &inComm, pcpp::ParallelTopologyInfoType &cartInfo, int haloDepth, std::ostream &messageStream)
Perform cartesian communicator initialization for a grid.
void SetLocalHaloExtents(const std::vector< pcpp::IndexIntervalType > haloExtents)
int ReceiveMessage(const int messageId, const std::vector< int > &neighborRanks, fixtures::CommunicatorType &inComm)
int ExchangeNodalData(int numComponents, double *dataBuffer)
void const size_t const size_t * bufferSizes
std::vector< subregion > subRegions
Sub-regions and boundaries.
void size_t int size_t int size_t int int int int double int int double double *void size_t int size_t int int int int int double int size_t size_t size_t double double *void size_t int size_t int size_t size_t int double int double double *void size_t size_t size_t * bufferInterval
int PartitionCartesianInterval(const pcpp::IndexIntervalType &globalExtent, const std::vector< int > &cartDims, const std::vector< int > &cartCoords, pcpp::IndexIntervalType &partExtent, std::ostream &messageStream)
Get local sub-interval of an n-dimensional integer interval.
std::vector< bool > & PeriodicDirs()
const std::vector< double > & PhysicalExtent() const
std::vector< pcpp::IndexIntervalType > threadPartitionIntervals
Partition intervals owned by thread (omp)
subroutine zxy(numDim, numPoints, bufferSize, bufferInterval, X, Y, Z)
ZXY point-wise operator performing Z = XY (all vectors)
std::vector< double > & CoordinateData()
pbsintervals partitionIntervals
The relevant partition intervals.
std::vector< size_t > dimExtensions
Number of "halo/ghost" points in each (+/-) of the 2*numDim directions.
double * stencilWeights
The stencil weights.
void size_t int size_t int size_t int int int int double * stencilWeights
void size_t int size_t int size_t int * numStencils
int SetupCartesianTopology(pcpp::CommunicatorType ¶llelCommunicator, pcpp::ParallelTopologyInfoType &topologyInfo, pcpp::CommunicatorType &topoCommunicator, std::ostream &messageStream)
Sets up a communicator with Cartesian topology.
int numStencils
The number of stencils (e.g. interior + boundary)
void AllocateCoordinateData()
std::vector< pcpp::IndexIntervalType > threadPartitionBufferIntervals
Partition buffer interval owned by each thread (omp)
std::vector< size_t > numPointsRecv
subroutine yaxpy(N1, N2, N3, localInterval, a, X, Y)
subroutine yaxm1(numDim, numPoints, bufferSize, bufferInterval, a, X, Y)
YAXM1 point-wise operator performing Y = a/X (scalar a)
pcpp::IndexIntervalType ResolveBufferInterval(const pcpp::IndexIntervalType &partitionInterval, const pcpp::IndexIntervalType &partitionBufferInterval, const pcpp::IndexIntervalType &partitionSubInterval)
std::string ResolveTopoType(int inType)
Simple Block Structured Mesh object.
void SetGridInterval(const pcpp::IndexIntervalType &inExtent)
int * stencilConnectivity
std::vector< pcpp::IndexIntervalType > threadPartitionBufferIntervals
fixtures::CommunicatorType & Communicator() const
void size_t int * numComponents
subroutine metricsum4(numDim, numPoints, bufferSize, bufferInterval, buf1, buf2, buf3, buf4, buf5, buf6, buf7, metricSum)
Computes buf1*buf4 - buf2*buf3 + buf7*(buf5 - buf6)
std::vector< double > & GridGenerationParameters()
subroutine xax(numDim, numPoints, bufferSize, bufferInterval, a, X)
XAX point-wise operator performing X = aX (scalar a)
std::vector< double > gridCoordinates
The coordinate buffer.
std::vector< double > periodicLengths
int Finalize(bool allocateCoordinateData=false)
std::vector< double > gridMetric
Grid metrics (sizes depend on gridTopoType)
std::vector< int > & CartDimensions()
void InitSimple(const ContainerType &inSize)
size_t BufferSize() const
int DestroyMessageBuffer(int messageId)
void SetLocalBufferSizes(const std::vector< size_t > &inBufferSizes)
void FC_MODULE(euler, flux1d, EULER, FLUX1D)(const int *numDim
int CreateThreadRecvIndices(int threadId)
Create receive buffers for state data from neighboring processors.
std::vector< int > & CartCoordinates()
plascom2::operators::stencilset * stencilSet
Differential operator.
int CreateThreadSendIndices(int threadId)
Creates send buffers for each whole local halo extent.