mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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.
This commit is contained in:
@ -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<point> 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);
|
||||
|
||||
// Local to global (Cartesian)
|
||||
{
|
||||
const tensor& rotTensor = coordSys_.R();
|
||||
// Global Cartesian
|
||||
pt = csys_.globalPosition(pt);
|
||||
|
||||
forAll(sampleCoords, i)
|
||||
{
|
||||
sampleCoords[i] = Foam::transform(rotTensor, sampleCoords[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
forAll(sampleCoords, sampleI)
|
||||
{
|
||||
label celli = queryMesh.findCell(sampleCoords[sampleI]);
|
||||
const label celli = queryMesh.findCell(pt);
|
||||
|
||||
if (celli != -1)
|
||||
{
|
||||
samplingPts.append(sampleCoords[sampleI]);
|
||||
samplingPts.append(pt);
|
||||
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<label>& pointsDensity,
|
||||
const Vector<scalar>& spanBox
|
||||
)
|
||||
:
|
||||
sampledSet(name, mesh, searchEngine, axis),
|
||||
coordSys_(origin),
|
||||
csys_(csys),
|
||||
pointsDensity_(pointsDensity),
|
||||
spanBox_(spanBox)
|
||||
{
|
||||
@ -180,7 +159,7 @@ Foam::arraySet::arraySet
|
||||
)
|
||||
:
|
||||
sampledSet(name, mesh, searchEngine, dict),
|
||||
coordSys_(dict),
|
||||
csys_(dict), // Note: no indirect cs with this constructor
|
||||
pointsDensity_(dict.get<labelVector>("pointsDensity")),
|
||||
spanBox_(dict.get<vector>("spanBox"))
|
||||
{
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -49,17 +49,14 @@ SourceFiles
|
||||
#include "sampledSet.H"
|
||||
#include "labelVector.H"
|
||||
#include "DynamicList.H"
|
||||
#include "coordinateSystem.H"
|
||||
#include "cartesianCS.H"
|
||||
#include "cylindricalCS.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
class passiveParticle;
|
||||
template<class Type> class particle;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class arraySet Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -70,8 +67,8 @@ class arraySet
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Coordinate system
|
||||
coordinateSystem coordSys_;
|
||||
//- Local Cartesian coordinate system
|
||||
coordSystem::cartesian csys_;
|
||||
|
||||
//- Point density vector
|
||||
labelVector pointsDensity_;
|
||||
@ -111,7 +108,7 @@ public:
|
||||
const polyMesh& mesh,
|
||||
const meshSearch& searchEngine,
|
||||
const word& axis,
|
||||
const coordinateSystem& coordSys,
|
||||
const coordSystem::cartesian& csys,
|
||||
const Vector<label>& pointsDensity,
|
||||
const Vector<scalar>& spanBox
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user