lineUniform.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "lineUniform.H"
27 #include "DynamicList.H"
28 #include "polyMesh.H"
29 #include "sampledSetCloud.H"
30 #include "points.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace sampledSets
38 {
41 }
42 }
43 
44 
45 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
46 
47 bool Foam::sampledSets::lineUniform::calcSamples
48 (
49  DynamicList<point>& samplingPositions,
50  DynamicList<scalar>& samplingDistances,
51  DynamicList<label>& samplingSegments,
52  DynamicList<label>& samplingCells,
53  DynamicList<label>& samplingFaces
54 ) const
55 {
56  // Calculate all sampling points
57  const scalarField ts(linearSequence01(nPoints_));
58  const pointField points((1 - ts)*start_ + ts*end_);
59 
60  // Calculate the sampling topology
61  points::calcSamples
62  (
63  mesh(),
64  points,
65  samplingPositions,
66  samplingDistances,
67  samplingSegments,
68  samplingCells,
69  samplingFaces
70  );
71 
72  // Overwrite the distances
73  forAll(samplingPositions, i)
74  {
75  samplingDistances[i] = mag(samplingPositions[i] - start_);
76  }
77 
78  // This set is ordered. Distances have been created.
79  return true;
80 }
81 
82 
83 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
84 
86 (
87  const word& name,
88  const polyMesh& mesh,
89  const dictionary& dict
90 )
91 :
93  start_(dict.lookup("start")),
94  end_(dict.lookup("end")),
95  nPoints_(dict.lookup<label>("nPoints"))
96 {}
97 
98 
99 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
100 
102 {}
103 
104 
105 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Macros for easy insertion into run-time selection tables.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:64
const polyMesh & mesh() const
Access the mesh.
Definition: sampledSetI.H:36
Uniform samples along a line.
Definition: lineUniform.H:99
lineUniform(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: lineUniform.C:86
virtual ~lineUniform()
Destructor.
Definition: lineUniform.C:101
Set of sets to sample. Call sampledSets.write() to sample&write files.
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
const pointField & points
defineTypeNameAndDebug(arcUniform, 0)
addToRunTimeSelectionTable(sampledSet, arcUniform, word)
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
tmp< scalarField > linearSequence01(const label n)
Definition: scalarField.C:107
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dictionary dict