introvoyz042's picture
Migrated from GitHub
5a600cf verified
Raw History Blame Contribute Delete
3.1 kB
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "lineUniform.H"
#include "DynamicList.H"
#include "polyMesh.H"
#include "sampledSetCloud.H"
#include "points.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace sampledSets
{
defineTypeNameAndDebug(lineUniform, 0);
addToRunTimeSelectionTable(sampledSet, lineUniform, word);
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::sampledSets::lineUniform::calcSamples
(
DynamicList<point>& samplingPositions,
DynamicList<scalar>& samplingDistances,
DynamicList<label>& samplingSegments,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces
) const
{
// Calculate all sampling points
const scalarField ts(linearSequence01(nPoints_));
const pointField points((1 - ts)*start_ + ts*end_);
// Calculate the sampling topology
points::calcSamples
(
mesh(),
points,
samplingPositions,
samplingDistances,
samplingSegments,
samplingCells,
samplingFaces
);
// Overwrite the distances
forAll(samplingPositions, i)
{
samplingDistances[i] = mag(samplingPositions[i] - start_);
}
// This set is ordered. Distances have been created.
return true;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sampledSets::lineUniform::lineUniform
(
const word& name,
const polyMesh& mesh,
const dictionary& dict
)
:
sampledSet(name, mesh, dict),
start_(dict.lookup("start")),
end_(dict.lookup("end")),
nPoints_(dict.lookup<label>("nPoints"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sampledSets::lineUniform::~lineUniform()
{}
// ************************************************************************* //