lumpedPointState.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) 2016-2019 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::lumpedPointState
28 
29 Description
30  The \a state of lumped points corresponds to positions and rotations.
31 
32  This class encapsulates the response from the external application and
33  serves as the entry point for applying relaxation, sub-stepping etc.
34 
35  \heading Dictionary input format
36  \table
37  Property | Description | Required | Default
38  points | List of points | yes |
39  angles | List of Euler rotation angles | yes |
40  order | The Euler-angle rotation order | no | zxz
41  degrees | Rotation angles in degrees | no | false
42  \endtable
43 
44  \heading Plain input format.
45  Blank and comment lines starting with a '#' character are ignored.
46  The angles are always in radians.
47  \verbatim
48  NumPoints
49  x0 y0 z0 eulerz0 eulerx'0 eulerz''0
50  x1 y1 z1 eulerz1 eulerx'1 eulerz''1
51  ...
52  \endverbatim
53 
54 SeeAlso
55  Foam::coordinateRotations::euler, Foam::quaternion
56 
57 SourceFiles
58  lumpedPointState.C
59  lumpedPointStateI.H
60 
61 \*---------------------------------------------------------------------------*/
62 
63 #ifndef lumpedPointState_H
64 #define lumpedPointState_H
65 
66 #include "dictionary.H"
67 #include "scalarList.H"
68 #include "pointField.H"
69 #include "scalarField.H"
70 #include "vectorField.H"
71 #include "tensorField.H"
72 #include "quaternion.H"
73 #include "Enum.H"
74 
75 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76 
77 namespace Foam
78 {
79 
80 class Istream;
81 class Ostream;
82 
83 /*---------------------------------------------------------------------------*\
84  Class lumpedPointState Declaration
85 \*---------------------------------------------------------------------------*/
86 
87 class lumpedPointState
88 {
89 public:
90 
91  //- Input format types
92  enum class inputFormatType
93  {
94  PLAIN,
95  DICTIONARY
96  };
97 
98  // Static data
99 
100  //- Names for the input format types
101  static const Enum<inputFormatType> formatNames;
102 
103 
104 private:
105 
106  // Private Data
107 
108  //- Positions of lumped points
109  pointField points_;
110 
111  //- Orientation of lumped points (as Euler angles)
112  vectorField angles_;
113 
114  //- The Euler-angle rotation order (default: zxz)
115  quaternion::eulerOrder order_;
116 
117  //- Euler angles measured in degrees
118  bool degrees_;
119 
120  //- Tensor rotation of lumped points
121  mutable tensorField* rotationPtr_;
122 
123 
124  // Private Member Functions
125 
126  void calcRotations() const;
127 
128  void readDict(const dictionary& dict);
129 
130 public:
131 
132  // Constructors
133 
134  //- Construct null
136 
137  //- Copy constructor
139 
140  //- Construct from points with zero-rotation
141  lumpedPointState(const pointField& pts);
142 
143  //- Construct from points with zero-rotation
145 
146  //- Construct from dictionary
148 
149 
150  //- Destructor
151  virtual ~lumpedPointState();
152 
153 
154  // Member Functions
155 
156  //- Has positions and consistent number of rotations?
157  inline bool valid() const;
158 
159  //- If no points were specified
160  inline bool empty() const;
161 
162  //- The number of points
163  inline label size() const;
164 
165  //- The points corresponding to mass centres
166  inline const pointField& points() const;
167 
168  //- The orientation of the points (mass centres)
169  inline const vectorField& angles() const;
170 
171  //- The local-to-global transformation for each point
172  inline const tensorField& rotations() const;
173 
174  //- Scale points by given factor.
175  // Zero and negative values are ignored.
176  void scalePoints(const scalar scaleFactor);
177 
178  //- Relax the state
179  // alpha = 1 : no relaxation
180  // alpha < 1 : relaxation
181  // alpha = 0 : do nothing
182  void relax(const scalar alpha, const lumpedPointState& prev);
183 
184  //- Read input as dictionary content
185  bool readData(Istream& is);
186 
187  //- Output as dictionary content
188  bool writeData(Ostream& os) const;
189 
190  //- Output as dictionary content
191  void writeDict(Ostream& os) const;
192 
193  //- Read input as plain content
194  bool readPlain(Istream& is);
195 
196  //- Output as plain content
197  void writePlain(Ostream& os) const;
198 
199  //- Read input from file (master process only) using specified format
200  bool readData(const inputFormatType& fmt, const fileName& file);
201 
202  //- Output as VTK file for debugging/visualization
203  // The points are joined as lines, the rotation is visualized
204  // by planes, write as VTK PolyData format.
205  void writeVTP(const fileName& outputFile, const vector& axis) const;
206 
207 
208  // Member Operators
209 
210  //- Assignment operator
211  void operator=(const lumpedPointState& rhs);
212 };
213 
214 
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 
217 } // End namespace Foam
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 #include "lumpedPointStateI.H"
222 
223 #endif
224 
225 // ************************************************************************* //
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Foam::Enum< inputFormatType >
Foam::lumpedPointState::writeDict
void writeDict(Ostream &os) const
Output as dictionary content.
Definition: lumpedPointState.C:272
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
scalarField.H
Foam::lumpedPointState::inputFormatType
inputFormatType
Input format types.
Definition: lumpedPointState.H:116
quaternion.H
Foam::lumpedPointState::operator=
void operator=(const lumpedPointState &rhs)
Assignment operator.
Definition: lumpedPointState.C:167
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
Foam::lumpedPointState::relax
void relax(const scalar alpha, const lumpedPointState &prev)
Relax the state.
Definition: lumpedPointState.C:188
Foam::lumpedPointState::~lumpedPointState
virtual ~lumpedPointState()
Destructor.
Definition: lumpedPointState.C:159
Foam::lumpedPointState::points
const pointField & points() const
The points corresponding to mass centres.
Definition: lumpedPointStateI.H:46
scalarList.H
Foam::lumpedPointState::inputFormatType::PLAIN
"plain" is a simple ASCII format
Foam::lumpedPointState
The state of lumped points corresponds to positions and rotations.
Definition: lumpedPointState.H:111
Foam::lumpedPointState::scalePoints
void scalePoints(const scalar scaleFactor)
Scale points by given factor.
Definition: lumpedPointState.C:178
Foam::label
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:62
Foam::Field< vector >
Foam::lumpedPointState::formatNames
static const Enum< inputFormatType > formatNames
Names for the input format types.
Definition: lumpedPointState.H:125
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::lumpedPointState::angles
const vectorField & angles() const
The orientation of the points (mass centres)
Definition: lumpedPointStateI.H:52
Foam::lumpedPointState::writePlain
void writePlain(Ostream &os) const
Output as plain content.
Definition: lumpedPointState.C:287
Foam::quaternion::eulerOrder
eulerOrder
Euler-angle rotation order.
Definition: quaternion.H:102
Foam::lumpedPointState::readData
bool readData(Istream &is)
Read input as dictionary content.
Definition: lumpedPointState.C:256
Foam::lumpedPointState::empty
bool empty() const
If no points were specified.
Definition: lumpedPointStateI.H:34
Foam::lumpedPointState::valid
bool valid() const
Has positions and consistent number of rotations?
Definition: lumpedPointStateI.H:28
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::lumpedPointState::writeData
bool writeData(Ostream &os) const
Output as dictionary content.
Definition: lumpedPointState.C:265
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
tensorField.H
pointField.H
Foam::Vector< scalar >
vectorField.H
Foam::lumpedPointState::writeVTP
void writeVTP(const fileName &outputFile, const vector &axis) const
Output as VTK file for debugging/visualization.
Definition: lumpedPointStateWriter.C:50
dictionary.H
Foam::lumpedPointState::rotations
const tensorField & rotations() const
The local-to-global transformation for each point.
Definition: lumpedPointStateI.H:58
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::lumpedPointState::lumpedPointState
lumpedPointState()
Construct null.
Definition: lumpedPointState.C:105
Foam::lumpedPointState::size
label size() const
The number of points.
Definition: lumpedPointStateI.H:40
Foam::lumpedPointState::readPlain
bool readPlain(Istream &is)
Read input as plain content.
Definition: lumpedPointState.C:216
lumpedPointStateI.H
Foam::lumpedPointState::inputFormatType::DICTIONARY
"dictionary" is the OpenFOAM dictionary format
Enum.H