From b17bcd67b795ae66079fc20ecb1f1e76080f69d8 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 1 Oct 2018 17:10:35 +0200 Subject: [PATCH] ENH: correct suspicious coordinate system conversions (issue #1027) - arraySet : was translate + transform now use globalPosition (== transform + translate). Explicitly limit to Cartesian coordinate system for clarity. --- src/sampling/sampledSet/array/arraySet.C | 69 +++++++++--------------- src/sampling/sampledSet/array/arraySet.H | 15 +++--- 2 files changed, 30 insertions(+), 54 deletions(-) diff --git a/src/sampling/sampledSet/array/arraySet.C b/src/sampling/sampledSet/array/arraySet.C index 10ac31ac91..eb747ae80c 100644 --- a/src/sampling/sampledSet/array/arraySet.C +++ b/src/sampling/sampledSet/array/arraySet.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,7 +30,6 @@ License #include "polyMesh.H" #include "addToRunTimeSelectionTable.H" #include "word.H" -#include "transform.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -54,57 +53,37 @@ void Foam::arraySet::calcSamples { const meshSearch& queryMesh = searchEngine(); - label nTotalSamples - ( - pointsDensity_.x() - *pointsDensity_.y() - *pointsDensity_.z() - ); + const scalar dx = spanBox_.x()/(pointsDensity_.x() + 1); + const scalar dy = spanBox_.y()/(pointsDensity_.y() + 1); + const scalar dz = spanBox_.z()/(pointsDensity_.z() + 1); - List sampleCoords(nTotalSamples); + label sampleI(0); - const scalar deltax = spanBox_.x()/(pointsDensity_.x() + 1); - const scalar deltay = spanBox_.y()/(pointsDensity_.y() + 1); - const scalar deltaz = spanBox_.z()/(pointsDensity_.z() + 1); - - label p(0); for (label k=1; k<=pointsDensity_.z(); ++k) { for (label j=1; j<=pointsDensity_.y(); ++j) { for (label i=1; i<=pointsDensity_.x(); ++i) { - vector t(deltax*i , deltay*j, deltaz*k); - sampleCoords[p] = coordSys_.origin() + t; - ++p; + // Local Cartesian + point pt(i*dx*i , j*dy, k*dz); + + // Global Cartesian + pt = csys_.globalPosition(pt); + + const label celli = queryMesh.findCell(pt); + + if (celli != -1) + { + samplingPts.append(pt); + samplingCells.append(celli); + samplingFaces.append(-1); + samplingSegments.append(0); + samplingCurveDist.append(1.0 * sampleI); + } } } } - - // Local to global (Cartesian) - { - const tensor& rotTensor = coordSys_.R(); - - forAll(sampleCoords, i) - { - sampleCoords[i] = Foam::transform(rotTensor, sampleCoords[i]); - } - } - - - forAll(sampleCoords, sampleI) - { - label celli = queryMesh.findCell(sampleCoords[sampleI]); - - if (celli != -1) - { - samplingPts.append(sampleCoords[sampleI]); - samplingCells.append(celli); - samplingFaces.append(-1); - samplingSegments.append(0); - samplingCurveDist.append(1.0 * sampleI); - } - } } @@ -157,13 +136,13 @@ Foam::arraySet::arraySet const polyMesh& mesh, const meshSearch& searchEngine, const word& axis, - const coordinateSystem& origin, + const coordSystem::cartesian& csys, const Vector