diff --git a/src/mesh/blockMesh/blockMesh/blockMesh.C b/src/mesh/blockMesh/blockMesh/blockMesh.C index 0e30e3cf21..b7826fdd48 100644 --- a/src/mesh/blockMesh/blockMesh/blockMesh.C +++ b/src/mesh/blockMesh/blockMesh/blockMesh.C @@ -147,14 +147,12 @@ bool Foam::blockMesh::readPointTransforms(const dictionary& dict) { transformType_ = transformTypes::NO_TRANSFORM; - const dictionary* dictptr = dict.findDict("transform", keyType::LITERAL); + // Optional (cartesian) coordinate system transform + auto csysPtr = coordinateSystem::NewIfPresent(dict, "transform"); - if (dictptr) + if (csysPtr) { - // Optional cartesian coordinate system transform, since JUL-2021 - // - 'origin' (READ_IF_PRESENT) - transform_ = - coordSystem::cartesian(*dictptr, IOobjectOption::READ_IF_PRESENT); + transform_ = csysPtr(); // Non-zero origin? if (magSqr(transform_.origin()) > ROOTVSMALL) diff --git a/src/parallel/decompose/decompositionMethods/geomDecomp/geomDecomp.C b/src/parallel/decompose/decompositionMethods/geomDecomp/geomDecomp.C index 15c4a65bfa..9c69a595e4 100644 --- a/src/parallel/decompose/decompositionMethods/geomDecomp/geomDecomp.C +++ b/src/parallel/decompose/decompositionMethods/geomDecomp/geomDecomp.C @@ -84,14 +84,12 @@ void Foam::geomDecomp::readCoeffs() } setOrder(); - // Optional cartesian coordinate system transform - const dictionary* dictptr = - coeffsDict_.findDict("transform", keyType::LITERAL); + // Optional (cartesian) coordinate system transform + auto csysPtr = coordinateSystem::NewIfPresent(coeffsDict_, "transform"); - if (dictptr) + if (csysPtr) { - // 'origin' (READ_IF_PRESENT) - csys_ = coordinateSystem(*dictptr, IOobjectOption::READ_IF_PRESENT); + csys_ = csysPtr(); } else if (equal(delta_, 0)) { diff --git a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C index 143e0a7b0e..2623b11235 100644 --- a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C +++ b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C @@ -60,34 +60,21 @@ Foam::plane Foam::sampledCuttingPlane::definePlane { plane pln(dict); - bool adjust = false; - const dictionary* dictptr = nullptr; - coordSystem::cartesian cs; + // Optional (cartesian) coordinate transform. + // - with registry to allow lookup from globally defined systems - // Create with registry to allow lookup from globally defined - // coordinate systems. + auto csysPtr = coordinateSystem::NewIfPresent(mesh, dict); - auto csPtr = coordinateSystem::NewIfPresent(mesh, *dictptr); - - if (csPtr) + if (!csysPtr) { - adjust = true; - cs = csPtr(); + csysPtr = coordinateSystem::NewIfPresent(dict, "transform"); } - else if - ( - (dictptr = dict.findDict("transform", keyType::LITERAL)) != nullptr - ) - { - // 'origin' (READ_IF_PRESENT) - adjust = true; - cs = coordSystem::cartesian(*dictptr, IOobjectOption::READ_IF_PRESENT); - } - // Make plane relative to the Cartesian coordinate system - if (adjust) + if (csysPtr) { + coordSystem::cartesian cs(csysPtr()); + const point orig = cs.globalPosition(pln.origin()); const vector norm = cs.globalVector(pln.normal()); diff --git a/src/sampling/sampledSurface/sampledPlane/sampledPlane.C b/src/sampling/sampledSurface/sampledPlane/sampledPlane.C index 4604e22965..0de30644c3 100644 --- a/src/sampling/sampledSurface/sampledPlane/sampledPlane.C +++ b/src/sampling/sampledSurface/sampledPlane/sampledPlane.C @@ -58,34 +58,21 @@ Foam::plane Foam::sampledPlane::definePlane { plane pln(dict); - bool adjust = false; - const dictionary* dictptr = nullptr; - coordSystem::cartesian cs; + // Optional (cartesian) coordinate transform. + // - with registry to allow lookup from globally defined systems - // Create with registry to allow lookup from globally defined - // coordinate systems. + auto csysPtr = coordinateSystem::NewIfPresent(mesh, dict); - auto csPtr = coordinateSystem::NewIfPresent(mesh, dict); - - if (csPtr) + if (!csysPtr) { - adjust = true; - cs = csPtr(); + csysPtr = coordinateSystem::NewIfPresent(dict, "transform"); } - else if - ( - (dictptr = dict.findDict("transform", keyType::LITERAL)) != nullptr - ) - { - // 'origin' (READ_IF_PRESENT) - adjust = true; - cs = coordSystem::cartesian(*dictptr, IOobjectOption::READ_IF_PRESENT); - } - // Make plane relative to the Cartesian coordinate system - if (adjust) + if (csysPtr) { + coordSystem::cartesian cs(csysPtr()); + const point orig = cs.globalPosition(pln.origin()); const vector norm = cs.globalVector(pln.normal());