diff --git a/src/OpenFOAM/primitives/coordinate/systems/coordinateSystems.C b/src/OpenFOAM/primitives/coordinate/systems/coordinateSystems.C index 073094af1a..91b35c5287 100644 --- a/src/OpenFOAM/primitives/coordinate/systems/coordinateSystems.C +++ b/src/OpenFOAM/primitives/coordinate/systems/coordinateSystems.C @@ -116,6 +116,22 @@ Foam::coordinateSystems::coordinateSystems(const IOobject& io) } +Foam::coordinateSystems::coordinateSystems(const objectRegistry& obr) +: + coordinateSystems + ( + IOobject + ( + typeName, + obr.time().constant(), + obr, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ) + ) +{} + + Foam::coordinateSystems::coordinateSystems ( const IOobject& io, @@ -162,20 +178,7 @@ const Foam::coordinateSystems& Foam::coordinateSystems::New } // Read construct from registry - return obr.store - ( - new coordinateSystems - ( - IOobject - ( - typeName, - obr.time().constant(), - obr, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE - ) - ) - ); + return obr.store(new coordinateSystems(obr)); } diff --git a/src/OpenFOAM/primitives/coordinate/systems/coordinateSystems.H b/src/OpenFOAM/primitives/coordinate/systems/coordinateSystems.H index 294e4255c5..de5b756425 100644 --- a/src/OpenFOAM/primitives/coordinate/systems/coordinateSystems.H +++ b/src/OpenFOAM/primitives/coordinate/systems/coordinateSystems.H @@ -107,6 +107,10 @@ public: //- Read construct from IOobject explicit coordinateSystems(const IOobject& io); + //- Read construct "coordinateSystems" from "constant" + //- using given registry + explicit coordinateSystems(const objectRegistry& obr); + //- Construct from IOobject and PtrList content coordinateSystems ( diff --git a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C index fe4765d050..3f2c7e8ad6 100644 --- a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C +++ b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,6 +31,7 @@ License #include "fvMesh.H" #include "volFields.H" #include "volPointInterpolation.H" +#include "cartesianCS.H" #include "addToRunTimeSelectionTable.H" #include "PtrList.H" @@ -51,6 +52,64 @@ namespace Foam // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +Foam::plane Foam::sampledCuttingPlane::definePlane +( + const polyMesh& mesh, + const dictionary& dict +) +{ + plane pln(dict); + + bool adjust = false; + const dictionary* dictptr = nullptr; + coordSystem::cartesian cs; + + if (dict.found(coordinateSystem::typeName_(), keyType::LITERAL)) + { + // Create with registry to allow lookup from globally defined + // coordinate systems? + + auto csPtr = + coordinateSystem::New(mesh, dict, coordinateSystem::typeName_()); + + if (csPtr) + { + adjust = true; + cs = csPtr(); + } + } + else if + ( + (dictptr = dict.findDict("transform", keyType::LITERAL)) != nullptr + ) + { + adjust = true; + cs = coordSystem::cartesian(*dictptr); + } + + + // Make plane relative to the Cartesian coordinate system + if (adjust) + { + const point orig = cs.globalPosition(pln.origin()); + const vector norm = cs.globalVector(pln.normal()); + + DebugInfo + << "plane " + << " origin:" << pln.origin() + << " normal:" << pln.normal() + << " =>" + << " origin:" << orig << " normal:" << norm + << endl; + + // Reassign the plane + pln = plane(orig, norm); + } + + return pln; +} + + void Foam::sampledCuttingPlane::checkBoundsIntersection ( const plane& pln, @@ -512,7 +571,7 @@ Foam::sampledCuttingPlane::sampledCuttingPlane ) : sampledSurface(name, mesh, dict), - plane_(dict), + plane_(definePlane(mesh, dict)), offsets_(), isoParams_ ( diff --git a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.H b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.H index 68b543611c..fa9bb98231 100644 --- a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.H +++ b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -60,6 +60,8 @@ Usage exposedPatchName | name for zone subset | optional | regularise | Face simplification (enum or bool) | no | true mergeTol | tolerance for merging points | no | 1e-6 + coordinateSystem | define plane within given cartesian system | no | + transform | define plane within given cartesian system | no | \endtable Note @@ -73,8 +75,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef sampledCuttingPlane_H -#define sampledCuttingPlane_H +#ifndef Foam_sampledCuttingPlane_H +#define Foam_sampledCuttingPlane_H #include "sampledSurface.H" #include "plane.H" @@ -153,6 +155,10 @@ class sampledCuttingPlane // Private Member Functions + //- Define plane from dictionary entry and apply any coordinate + //- transformations + static plane definePlane(const polyMesh& mesh, const dictionary& dict); + //- Check and warn if bounding box does not intersect mesh or plane void checkBoundsIntersection ( diff --git a/src/sampling/sampledSurface/sampledPlane/sampledPlane.C b/src/sampling/sampledSurface/sampledPlane/sampledPlane.C index cfd6e99a1b..1233385b2a 100644 --- a/src/sampling/sampledSurface/sampledPlane/sampledPlane.C +++ b/src/sampling/sampledSurface/sampledPlane/sampledPlane.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2021 OpenCFD Ltd. + Copyright (C) 2017-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -50,6 +50,65 @@ namespace Foam // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +Foam::plane Foam::sampledPlane::definePlane +( + const polyMesh& mesh, + const dictionary& dict +) +{ + plane pln(dict); + + bool adjust = false; + const dictionary* dictptr = nullptr; + coordSystem::cartesian cs; + + if (dict.found(coordinateSystem::typeName_(), keyType::LITERAL)) + { + // Create with registry to allow lookup from globally defined + // coordinate systems? + + auto csPtr = + coordinateSystem::New(mesh, dict, coordinateSystem::typeName_()); + + if (csPtr) + { + adjust = true; + cs = csPtr(); + } + } + else if + ( + (dictptr = dict.findDict("transform", keyType::LITERAL)) != nullptr + ) + { + adjust = true; + cs = coordSystem::cartesian(*dictptr); + } + + + // Make plane relative to the Cartesian coordinate system + if (adjust) + { + const point orig = cs.globalPosition(pln.origin()); + const vector norm = cs.globalVector(pln.normal()); + + DebugInfo + << "plane " + << " origin:" << pln.origin() + << " normal:" << pln.normal() + << " =>" + << " origin:" << orig + << " normal:" << norm + << endl; + + // Reassign the plane + pln = plane(orig, norm); + } + + return pln; +} + + Foam::bitSet Foam::sampledPlane::cellSelection(const bool warn) const { return cuttingPlane::cellSelection @@ -105,7 +164,7 @@ Foam::sampledPlane::sampledPlane ) : sampledSurface(name, mesh, dict), - cuttingPlane(plane(dict)), + cuttingPlane(definePlane(mesh, dict)), zoneNames_(), bounds_(dict.getOrDefault("bounds", boundBox::invertedBox)), triangulate_(dict.getOrDefault("triangulate", true)), @@ -117,31 +176,6 @@ Foam::sampledPlane::sampledPlane dict.readEntry("zone", zoneNames_.first()); } - - // Make plane relative to the coordinateSystem (Cartesian) - // allow lookup from global coordinate systems - if (dict.found(coordinateSystem::typeName_())) - { - coordSystem::cartesian cs - ( - coordinateSystem::New(mesh, dict, coordinateSystem::typeName_()) - ); - plane& pln = planeDesc(); - - const point orig = cs.globalPosition(pln.origin()); - const vector norm = cs.globalVector(pln.normal()); - - DebugInfo - << "plane " << name << " :" - << " origin:" << origin() - << " normal:" << normal() - << " defined within a local coordinateSystem" << endl; - - // Reassign the plane - pln = plane(orig, norm); - } - - if (debug) { Info<< "plane " << name << " :" diff --git a/src/sampling/sampledSurface/sampledPlane/sampledPlane.H b/src/sampling/sampledSurface/sampledPlane/sampledPlane.H index b261f2b56f..1f7fd6f556 100644 --- a/src/sampling/sampledSurface/sampledPlane/sampledPlane.H +++ b/src/sampling/sampledSurface/sampledPlane/sampledPlane.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -49,14 +49,15 @@ Usage Where the sub-entries comprise: \table - Property | Description | Required | Default - type | plane | yes | - planeType | Plane description (pointAndNormal etc) | no | - triangulate | triangulate faces | no | true - bounds | limit with bounding box | no | - zone | limit to cell zone (name or regex) | no | - zones | limit to cell zones (names, regexs) | no | - coordinateSystem | define plane within given coordinate system | no | + Property | Description | Reqd | Default + type | plane | yes | + planeType | Plane description (pointAndNormal etc) | no | + triangulate | triangulate faces | no | true + bounds | limit with bounding box | no | + zone | limit to cell zone (name or regex) | no | + zones | limit to cell zones (names, regexs) | no | + coordinateSystem | define plane within given cartesian system | no | + transform | define plane within given cartesian system | no | \endtable SeeAlso @@ -73,8 +74,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef sampledPlane_H -#define sampledPlane_H +#ifndef Foam_sampledPlane_H +#define Foam_sampledPlane_H #include "sampledSurface.H" #include "cuttingPlane.H" @@ -110,6 +111,10 @@ class sampledPlane // Private Member Functions + //- Define plane from dictionary entry and apply any coordinate + //- transformations + static plane definePlane(const polyMesh& mesh, const dictionary& dict); + //- Define cell selection from zones and bounding box. // Optionally check and warn if the plane does not intersect // with the bounds of the mesh (or submesh) or if the bounding box diff --git a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/common/constant/porosityProperties b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/common/constant/porosityProperties index 69bdf2d0a9..c599e22edd 100644 --- a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/common/constant/porosityProperties +++ b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/common/constant/porosityProperties @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v2112 | +| \\ / O peration | Version: v2206 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -26,8 +26,9 @@ porosity1 coordinateSystem { origin (0 0 0); - e1 (0.70710678 0.70710678 0); - e2 (0 0 1); + rotation axisAngle; + axis (0 0 1); + angle 45; } } diff --git a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/system/sampling b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/system/sampling index ed1e407fbc..bc310e2476 100644 --- a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/system/sampling +++ b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/system/sampling @@ -94,7 +94,7 @@ plane writeControl writeTime; surfaceFormat vtk; - fields ( cellZoneID ); + fields ( cellZoneID U ); surfaces { @@ -105,6 +105,24 @@ plane normal (0 0 1); interpolate false; } + + slices + { + type cuttingPlane; + point (0 0 0); + normal (1 0 0); + offsets (0.02 0.04 0.06 0.08); + + interpolate true; + + transform + { + origin (0 0 0); + rotation axisAngle; + axis (0 0 1); + angle 45; + } + } } } diff --git a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/system/snappyHexMeshDict b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/system/snappyHexMeshDict index 17ae1de916..3fef6fcd15 100644 --- a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/system/snappyHexMeshDict +++ b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/system/snappyHexMeshDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v2112 | +| \\ / O peration | Version: v2206 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -55,8 +55,7 @@ geometry transform { origin (2 2 0); - e1 (1 0 0); - e3 (0 0 1); + rotation none; } } herring diff --git a/tutorials/mesh/snappyHexMesh/iglooWithFridgesDirectionalRefinement/system/snappyHexMeshDict b/tutorials/mesh/snappyHexMesh/iglooWithFridgesDirectionalRefinement/system/snappyHexMeshDict index 1901c39878..9042c8580b 100644 --- a/tutorials/mesh/snappyHexMesh/iglooWithFridgesDirectionalRefinement/system/snappyHexMeshDict +++ b/tutorials/mesh/snappyHexMesh/iglooWithFridgesDirectionalRefinement/system/snappyHexMeshDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v2112 | +| \\ / O peration | Version: v2206 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -53,28 +53,17 @@ geometry surface box1; scale (1.0 1.0 2.1); - // Old syntax transform { - coordinateSystem - { - type cartesian; - origin (2 2 0); - rotation - { - type axes; - e1 (1 0 0); - e3 (0 0 1); - } - } + origin (2 2 0); + rotation none; } } herring { surface box1; - scale (1.0 1.0 2.1); + scale (1.0 1.0 2.1); - // Simplified syntax transform { origin (3.5 3 0);