From b9f05bdc01110332897ef448cda2dd7b5e855598 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 29 Jan 2025 09:25:40 +0000 Subject: [PATCH] ENH: refineMesh: user-specified coordinate system --- etc/caseDicts/annotated/refineMeshDict | 12 +++++++++ .../meshCut/directions/directions.C | 27 ++++++++++++++++++- .../meshCut/directions/directions.H | 11 ++++---- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/etc/caseDicts/annotated/refineMeshDict b/etc/caseDicts/annotated/refineMeshDict index 60392d6fcf..d4c49c4ffe 100644 --- a/etc/caseDicts/annotated/refineMeshDict +++ b/etc/caseDicts/annotated/refineMeshDict @@ -22,12 +22,15 @@ set c0; // x,y,z axis. Specify in globalCoeffs section below. // - patchLocal : coordinate system different for every cell. Specify in // patchLocalCoeffs section below. +// - user : coordinate system provided. Usually cylindrical or spherical. +// Specify in userCoeffs section below. // - fieldBased : uses the list of field names from the directions list for // selecting the directions to cut. Meant to be used with geometricCut, but // can also be used with useHexTopology. coordinateSystem global; //coordinateSystem patchLocal; //coordinateSystem fieldBased; +//coordinateSystem user; // .. and its coefficients. x,y in this case. (normal direction is calculated // as tan1^tan2) @@ -43,6 +46,15 @@ patchLocalCoeffs tan1 (1 0 0); } +userCoeffs +{ + type cylindrical; + origin (0 0 0); + e1 (1 0 0); // tan1 direction + e3 (0 1 0); // normal direction +} + + // List of directions to refine, if global or patchLocal directions ( diff --git a/src/dynamicMesh/meshCut/directions/directions.C b/src/dynamicMesh/meshCut/directions/directions.C index 67e475aecc..2f19a97504 100644 --- a/src/dynamicMesh/meshCut/directions/directions.C +++ b/src/dynamicMesh/meshCut/directions/directions.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020,2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,6 +35,7 @@ License #include "meshTools.H" #include "hexMatcher.H" #include "globalMeshData.H" +#include "coordinateSystem.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -341,6 +342,30 @@ Foam::directions::directions operator[](nDirs++) = vectorField(1, tan2); } } + else if (coordSystem == "user") + { + const dictionary& globalDict = dict.subDict("userCoeffs"); + + auto csysPtr(coordinateSystem::New(mesh.thisDb(), globalDict)); + const auto& cs = csysPtr(); + + if (wantNormal) + { + // 'Normal' is usually e3. + vectorField& result = operator[](nDirs++); + result = cs.transform(mesh.cellCentres(), vector(0, 0, 1)); + } + if (wantTan1) + { + vectorField& result = operator[](nDirs++); + result = cs.transform(mesh.cellCentres(), vector(1, 0, 0)); + } + if (wantTan2) + { + vectorField& result = operator[](nDirs++); + result = cs.transform(mesh.cellCentres(), vector(0, 1, 0)); + } + } else if (coordSystem == "patchLocal") { const dictionary& patchDict = dict.subDict("patchLocalCoeffs"); diff --git a/src/dynamicMesh/meshCut/directions/directions.H b/src/dynamicMesh/meshCut/directions/directions.H index f4cfec2eb5..8dbeddf4f1 100644 --- a/src/dynamicMesh/meshCut/directions/directions.H +++ b/src/dynamicMesh/meshCut/directions/directions.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,10 +31,11 @@ Description Set of directions for each cell in the mesh. Either uniform and size=1 or one set of directions per cell. - Used in splitting cells. - Either all cells have similar refinement direction ('global') or - direction is dependent on local cell geometry, or loads selected fields - by name ('fieldBased'). Controlled by dictionary. + Used in splitting cells. Options: + - global : global xyz coordinate system + - user : user-defined coordinate system + - patchLocal : normal direction from (flat) given patch + - fieldBased : supply separate vectorIOField for each direction SourceFiles directions.C