coordSet.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2012 OpenFOAM Foundation
9  Copyright (C) 2017-2018 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::coordSet
29 
30 Description
31  Holds list of sampling positions
32 
33 SourceFiles
34  coordSet.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef coordSet_H
39 #define coordSet_H
40 
41 #include "pointField.H"
42 #include "word.H"
43 #include "Enum.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class coordSet Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 class coordSet
55 :
56  public pointField
57 {
58 public:
59 
60  // Public data types
61 
62  //- Enumeration defining the output format for coordinates
63  enum class coordFormat
64  {
65  XYZ,
66  X,
67  Y,
68  Z,
69  DISTANCE
70  };
71 
72  //- String representation of coordFormat enum
74 
75 private:
76 
77  //- Check for consistent dimensions of points and curve distance
78  void checkDimensions() const;
79 
80 
81 protected:
82 
83  //- Name
84  const word name_;
85 
86  //- Axis write type
87  const coordFormat axis_;
88 
89  //- Cumulative distance "distance" write specifier.
91 
92 
93 public:
94 
95  // Constructors
96 
97  //- Construct from components
98  // Note: curveDist will be empty
99  coordSet(const word& name, const coordFormat axisType);
100 
101  //- Construct from components
102  // Note: curveDist will be empty
103  coordSet(const word& name, const word& axis);
104 
105  //- Copy construct from components
106  coordSet
107  (
108  const word& name,
109  const word& axis,
110  const List<point>& points,
111  const scalarList& curveDist
112  );
113 
114  //- Move construct from components
115  coordSet
116  (
117  const word& name,
118  const word& axis,
121  );
122 
123 
124  // Member functions
125 
126  const word& name() const
127  {
128  return name_;
129  }
130 
131  word axis() const
132  {
133  return coordFormatNames[axis_];
134  }
135 
136  //- Set the points
137  void setPoints(const List<point>& newPoints)
138  {
139  static_cast<pointField&>(*this) = newPoints;
140  }
141 
142  //- Set the points
143  void setPoints(List<point>&& newPoints)
144  {
145  static_cast<pointField&>(*this) = std::move(newPoints);
146  }
147 
148  //- Return the cumulative distance
149  const scalarList& curveDist() const
150  {
151  return curveDist_;
152  }
153 
154  //- Set the cumulative distance
155  void setCurveDist(const scalarList& curveDist)
156  {
158  checkDimensions();
159  }
160 
161  //- Set the cumulative distance
163  {
164  curveDist_ = std::move(curveDist);
165  checkDimensions();
166  }
167 
168  //- Is axis specification a vector
169  bool hasVectorAxis() const;
170 
171  //- Get coordinate of point according to axis specification.
172  // If axis="distance" is the curveDist[index]
173  scalar scalarCoord(const label index) const;
174 
175  //- Get point according to axis="xyz" specification
176  vector vectorCoord(const label index) const;
177 
178  //- Write to stream
179  Ostream& write(Ostream& os) const;
180 };
181 
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 } // End namespace Foam
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 #endif
190 
191 // ************************************************************************* //
Foam::coordSet::name
const word & name() const
Definition: coordSet.H:125
Foam::coordSet::setCurveDist
void setCurveDist(const scalarList &curveDist)
Set the cumulative distance.
Definition: coordSet.H:154
Foam::Enum< coordFormat >
Foam::coordSet::coordFormat::Y
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::coordSet::name_
const word name_
Name.
Definition: coordSet.H:83
Foam::coordSet::setPoints
void setPoints(const List< point > &newPoints)
Set the points.
Definition: coordSet.H:136
Foam::coordSet::coordFormat
coordFormat
Enumeration defining the output format for coordinates.
Definition: coordSet.H:62
Foam::coordSet::coordFormat::XYZ
Foam::coordSet::scalarCoord
scalar scalarCoord(const label index) const
Get coordinate of point according to axis specification.
Definition: coordSet.C:132
Foam::coordSet::axis
word axis() const
Definition: coordSet.H:130
Foam::coordSet::coordSet
coordSet(const word &name, const coordFormat axisType)
Construct from components.
Definition: coordSet.C:65
Foam::Field< vector >
Foam::coordSet::curveDist
const scalarList & curveDist() const
Return the cumulative distance.
Definition: coordSet.H:148
Foam::coordSet::axis_
const coordFormat axis_
Axis write type.
Definition: coordSet.H:86
os
OBJstream os(runTime.globalPath()/outputName)
Foam::coordSet
Holds list of sampling positions.
Definition: coordSet.H:53
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::coordSet::setPoints
void setPoints(List< point > &&newPoints)
Set the points.
Definition: coordSet.H:142
Foam::coordSet::coordFormat::X
Foam::coordSet::curveDist_
scalarList curveDist_
Cumulative distance "distance" write specifier.
Definition: coordSet.H:89
pointField.H
Foam::coordSet::coordFormatNames
static const Enum< coordFormat > coordFormatNames
String representation of coordFormat enum.
Definition: coordSet.H:72
Foam::Vector< scalar >
Foam::coordSet::write
Ostream & write(Ostream &os) const
Write to stream.
Definition: coordSet.C:186
Foam::List< scalar >
Foam::coordSet::coordFormat::DISTANCE
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::coordSet::setCurveDist
void setCurveDist(scalarList &&curveDist)
Set the cumulative distance.
Definition: coordSet.H:161
Foam::coordSet::vectorCoord
vector vectorCoord(const label index) const
Get point according to axis="xyz" specification.
Definition: coordSet.C:178
Foam::coordSet::coordFormat::Z
Foam::coordSet::hasVectorAxis
bool hasVectorAxis() const
Is axis specification a vector.
Definition: coordSet.C:126
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
word.H
Enum.H