arcUniform.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 "arcUniform.H"
27 #include "sampledSet.H"
28 #include "DynamicList.H"
29 #include "polyMesh.H"
31 #include "word.H"
32 #include "points.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace sampledSets
39 {
42 }
43 }
44 
45 
46 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47 
48 bool Foam::sampledSets::arcUniform::calcSamples
49 (
50  DynamicList<point>& samplingPositions,
51  DynamicList<scalar>& samplingDistances,
52  DynamicList<label>& samplingSegments,
53  DynamicList<label>& samplingCells,
54  DynamicList<label>& samplingFaces
55 ) const
56 {
57  // Get the coordinate system
58  const vector axis1 = radial_ - (radial_ & normal_)*normal_;
59  const vector axis2 = normal_ ^ axis1;
60  const scalar radius = mag(axis1);
61 
62  // Compute all point locations
63  const scalarField ts(linearSequence01(nPoints_));
64  const scalarField theta((1 - ts)*startAngle_ + ts*endAngle_);
65  const scalarField c(cos(theta)), s(sin(theta));
66  const pointField points(centre_ + c*axis1 + s*axis2);
67 
68  // Calculate the sampling topology
69  points::calcSamples
70  (
71  mesh(),
72  points,
73  samplingPositions,
74  samplingDistances,
75  samplingSegments,
76  samplingCells,
77  samplingFaces
78  );
79 
80  // Overwrite the distances
81  forAll(samplingPositions, i)
82  {
83  const vector v = samplingPositions[i] - centre_;
84  const scalar theta = atan2(v & axis2, v & axis1);
85  samplingDistances[i] = radius*theta;
86  }
87 
88  // This set is ordered. Distances have been created.
89  return true;
90 }
91 
92 
93 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
94 
96 (
97  const word& name,
98  const polyMesh& mesh,
99  const dictionary& dict
100 )
101 :
103  centre_(dict.lookup("centre")),
104  normal_(normalised(dict.lookup<vector>("normal"))),
105  radial_(dict.lookup<vector>("radial")),
106  startAngle_(dict.lookup<scalar>("startAngle")),
107  endAngle_(dict.lookup<scalar>("endAngle")),
108  nPoints_(dict.lookup<scalar>("nPoints"))
109 {}
110 
111 
112 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
113 
115 {}
116 
117 
118 // ************************************************************************* //
#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 an arc.
Definition: arcUniform.H:120
virtual ~arcUniform()
Destructor.
Definition: arcUniform.C:114
arcUniform(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: arcUniform.C:96
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
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const dimensionedScalar c
Speed of light in a vacuum.
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.
dimensionedScalar sin(const dimensionedScalar &ds)
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
tmp< scalarField > linearSequence01(const label n)
Definition: scalarField.C:107
dimensionSet normalised(const dimensionSet &)
Definition: dimensionSet.C:509
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)
tmp< DimensionedField< scalar, GeoMesh, Field > > atan2(const DimensionedField< scalar, GeoMesh, PrimitiveField1 > &dsf1, const DimensionedField< scalar, GeoMesh, PrimitiveField2 > &dsf2)
dimensionedScalar cos(const dimensionedScalar &ds)
dictionary dict