coordSet.H
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-2018 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 Class
25  Foam::coordSet
26 
27 Description
28  Holds list of sampling positions
29 
30 SourceFiles
31  coordSet.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef coordSet_H
36 #define coordSet_H
37 
38 #include "pointField.H"
39 #include "word.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class coordSet Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 class coordSet
51 :
52  public pointField
53 {
54 
55 public:
56 
57  // Public data types
58 
59  //- Enumeration defining the output format for coordinates
60  enum coordFormat
61  {
62  XYZ,
63  X,
64  Y,
65  Z,
66  DISTANCE
67  };
68 
69 
70 private:
71 
72  //- String representation of coordFormat enums
73  static const NamedEnum<coordFormat, 5> coordFormatNames_;
74 
75 
76 protected:
77 
78  //- Name
79  const word name_;
80 
81  //- Axis write type
82  const coordFormat axis_;
83 
84  //- Cumulative distance "distance" write specifier.
86 
87 
88 public:
89 
90  // Constructors
91 
92  //- Construct from components
93  coordSet
94  (
95  const word& name,
96  const word& axis
97  );
98 
99 
100  //- Construct from components
101  coordSet
102  (
103  const word& name,
104  const word& axis,
105  const List<point>& points,
106  const scalarList& curveDist
107  );
108 
109 
110  // Member functions
112  const word& name() const
113  {
114  return name_;
115  }
117  word axis() const
118  {
119  return coordFormatNames_[axis_];
120  }
121 
122  //- Cumulative distance
123  const scalarList& curveDist() const
124  {
125  return curveDist_;
126  }
127 
128  //- Is axis specification a vector
129  bool hasVectorAxis() const;
130 
131  //- Get coordinate of point according to axis specification.
132  // If axis="distance" is the curveDist[index]
133  scalar scalarCoord(const label index) const;
134 
135  //- Get point according to axis="xyz" specification
136  vector vectorCoord(const label index) const;
137 
138  Ostream& write(Ostream& os) const;
139 };
140 
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 } // End namespace Foam
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 #endif
149 
150 // ************************************************************************* //
word axis() const
Definition: coordSet.H:116
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
bool hasVectorAxis() const
Is axis specification a vector.
Definition: coordSet.C:84
scalarList curveDist_
Cumulative distance "distance" write specifier.
Definition: coordSet.H:84
Holds list of sampling positions.
Definition: coordSet.H:49
const pointField & points
vector vectorCoord(const label index) const
Get point according to axis="xyz" specification.
Definition: coordSet.C:126
A class for handling words, derived from string.
Definition: word.H:59
Ostream & write(Ostream &os) const
Definition: coordSet.C:134
coordFormat
Enumeration defining the output format for coordinates.
Definition: coordSet.H:59
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
const word & name() const
Definition: coordSet.H:111
coordSet(const word &name, const word &axis)
Construct from components.
Definition: coordSet.C:55
const word name_
Name.
Definition: coordSet.H:78
const coordFormat axis_
Axis write type.
Definition: coordSet.H:81
const scalarList & curveDist() const
Cumulative distance.
Definition: coordSet.H:122
Namespace for OpenFOAM.
scalar scalarCoord(const label index) const
Get coordinate of point according to axis specification.
Definition: coordSet.C:91