| 1387 | } // namespace |
| 1388 | |
| 1389 | void Coordinates::setParallelTransform(Options* options) { |
| 1390 | |
| 1391 | auto ptoptions = options->getSection("paralleltransform"); |
| 1392 | |
| 1393 | std::string ptstr; |
| 1394 | ptoptions->get("type", ptstr, "identity"); |
| 1395 | |
| 1396 | // Convert to lower case for comparison |
| 1397 | ptstr = lowercase(ptstr); |
| 1398 | |
| 1399 | if (ptstr == "identity") { |
| 1400 | // Identity method i.e. no transform needed |
| 1401 | transform = |
| 1402 | bout::utils::make_unique<ParallelTransformIdentity>(*localmesh, ptoptions); |
| 1403 | |
| 1404 | } else if (ptstr == "shifted" or ptstr == "shiftedinterp") { |
| 1405 | // Shifted metric method |
| 1406 | |
| 1407 | Field2D zShift{localmesh}; |
| 1408 | |
| 1409 | // Read the zShift angle from the mesh |
| 1410 | std::string suffix = getLocationSuffix(location); |
| 1411 | if (localmesh->sourceHasVar("dx" + suffix)) { |
| 1412 | // Grid file has variables at this location, so should be able to read |
| 1413 | checkStaggeredGet(localmesh, "zShift", suffix); |
| 1414 | if (localmesh->get(zShift, "zShift" + suffix, 0.0, false, location)) { |
| 1415 | // No zShift variable. Try qinty in BOUT grid files |
| 1416 | if (localmesh->get(zShift, "qinty" + suffix, 0.0, false, location)) { |
| 1417 | // Failed to find either variable, cannot use ShiftedMetric |
| 1418 | throw BoutException("Could not read zShift" + suffix + " from grid file"); |
| 1419 | } |
| 1420 | } |
| 1421 | } else { |
| 1422 | if (location == CELL_YLOW and bout::build::use_metric_3d) { |
| 1423 | throw BoutException("Cannot interpolate zShift to construct ShiftedMetric when " |
| 1424 | "using 3d metrics. You must provide zShift_ylow in the grid " |
| 1425 | "file."); |
| 1426 | } |
| 1427 | Field2D zShift_centre; |
| 1428 | if (localmesh->get(zShift_centre, "zShift", 0.0, false)) { |
| 1429 | // No zShift variable. Try qinty in BOUT grid files |
| 1430 | if (localmesh->get(zShift_centre, "qinty", 0.0, false)) { |
| 1431 | // Failed to find either variable, cannot use ShiftedMetric |
| 1432 | throw BoutException("Could not read zShift from grid file"); |
| 1433 | } |
| 1434 | } |
| 1435 | |
| 1436 | fixZShiftGuards(zShift_centre); |
| 1437 | |
| 1438 | zShift = interpolateAndExtrapolate(zShift_centre, location, true, true, false, |
| 1439 | transform.get()); |
| 1440 | } |
| 1441 | |
| 1442 | fixZShiftGuards(zShift); |
| 1443 | |
| 1444 | if (ptstr == "shifted") { |
| 1445 | transform = bout::utils::make_unique<ShiftedMetric>(*localmesh, location, zShift, |
| 1446 | getUniform(zlength())); |