Loading...
Searching...
No Matches
lumpedPointTools.C
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-2020 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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
27#include "lumpedPointTools.H"
28#include "IFstream.H"
29#include "IOobjectList.H"
30#include "volFields.H"
31#include "points0MotionSolver.H"
34// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
35
36namespace Foam
37{
38
39template<class GeoFieldType>
41(
42 const pointMesh::Mesh& mesh,
43 const IOobject* io
44)
45{
46 if (io && io->isHeaderClass<GeoFieldType>())
47 {
48 Info<< "Reading " << io->headerClassName()
49 << ' ' << io->name() << endl;
50
52 (
54 (
55 io->name(),
56 io->instance(),
57 io->local(),
58 io->db(),
61 io->registerObject()
62 ),
63 mesh
64 );
65 }
66
67 return nullptr;
68}
70} // End namespace Foam
71
72
73// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74
77(
78 const dictionary& dict,
80 bool degrees
81)
82{
83 quaternion::eulerOrderNames.readIfPresent
84 (
85 "rotationOrder",
86 dict,
87 rotOrder
88 );
89
90 dict.readIfPresent("degrees", degrees);
91
92 Info<<"Reading states\n";
93 List<dictionary> entries(dict.lookup("response"));
94
95 label statei = 0;
96
97 // List<lumpedPointStateTuple>
99
100 for (const dictionary& subDict : entries)
101 {
102 states[statei] =
104 (
105 subDict.get<scalar>("time"),
106 lumpedPointState(subDict)
107 );
108
109 ++statei;
111
112 return states;
113}
114
115
118(
119 Istream& is,
120 quaternion::eulerOrder rotOrder,
121 bool degrees
122)
124 dictionary dict(is);
125 return lumpedPointStates(dict, rotOrder, degrees);
126}
127
128
131(
132 const fileName& file,
133 quaternion::eulerOrder rotOrder,
134 bool degrees
135)
137 IFstream is(file);
138 return lumpedPointStates(is, rotOrder, degrees);
139}
140
141
147
148
151{
153}
154
155
157(
158 const polyMesh& mesh
159)
160{
161 IOobjectList objects0(mesh, "0");
162
163 pointMesh pMesh(mesh);
164
165 autoPtr<pointVectorField> displacePtr =
167 (
168 pMesh,
169 objects0.findObject("pointDisplacement")
170 );
171
172 if (!displacePtr)
173 {
174 Info<< "No valid pointDisplacement" << endl;
175 return labelList();
177
178 return lumpedPointPatchList(*displacePtr);
179}
180
181
182Foam::label
184(
185 const pointVectorField& pvf,
186 const pointField& points0
187)
188{
189 return
190 lumpedPointDisplacementPointPatchVectorField::setPatchControls
192 pvf,
193 points0
194 );
195}
196
197
199(
200 const fvMesh& mesh,
201 const pointField& points0
202)
203{
204 IOobjectList objects0(mesh, "0");
205
206 pointMesh pMesh(mesh);
207
208 autoPtr<pointVectorField> displacePtr =
210 (
211 pMesh,
212 objects0.findObject("pointDisplacement")
213 );
214
215 if (!displacePtr)
216 {
217 Info<< "No valid pointDisplacement" << endl;
218 return 0;
219 }
220
221 return setPatchControls(*displacePtr, points0);
222}
223
224
226(
227 const fvMesh& mesh
228)
231
233}
234
235
237(
238 const pointVectorField& pvf,
239 const pointField& points0
240)
241{
242 return
245 pvf,
246 points0
247 );
248}
249
250
252(
253 const fvMesh& mesh,
254 const pointField& points0
255)
256{
257 IOobjectList objects0(mesh, "0");
258
259 pointMesh pMesh(mesh);
260
261 autoPtr<pointVectorField> displacePtr =
263 (
264 pMesh,
265 objects0.findObject("pointDisplacement")
266 );
267
268 if (!displacePtr)
269 {
270 Info<< "No valid pointDisplacement" << endl;
271 return 0;
272 }
273
274 return setInterpolators(*displacePtr, points0);
275}
276
277
279(
280 const fvMesh& mesh
281)
282{
283 pointIOField points0(points0Field(mesh));
284
285 return setInterpolators(mesh, points0);
286}
287
288
289// ************************************************************************* //
Input from file stream as an ISstream, normally using std::ifstream for the actual input.
Definition IFstream.H:55
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable,...
const IOobject * findObject(const word &objName) const
Return const pointer to the object found by name.
@ MUST_READ
Reading required.
@ AUTO_WRITE
Automatically write from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition autoPtr.H:178
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for handling file names.
Definition fileName.H:75
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
static label setPatchControls(const pointVectorField &pvf, const pointField &points0)
Set all patch controls for patches of this type.
static labelList patchIds(const pointVectorField &pvf)
The ids for all patches of this type.
static label setInterpolators(const pointVectorField &pvf, const pointField &points0)
Set all patch controls for patches of this type.
The state of lumped points corresponds to positions and rotations.
Mesh representing a set of points created from polyMesh.
Definition pointMesh.H:49
pointMesh Mesh
The mesh type.
Definition pointMesh.H:93
static IOobject points0IO(const polyMesh &mesh)
Return IO object for points0.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
static const Enum< eulerOrder > eulerOrderNames
The names for Euler-angle and Tait-Bryan angles, including "rollPitchYaw" and "yawPitchRoll" aliases.
Definition quaternion.H:132
eulerOrder
Euler-angle rotation order.
Definition quaternion.H:116
dynamicFvMesh & mesh
const auto & io
label setPatchControls(const pointVectorField &pvf, const pointField &points0)
Return the patch-ids associated with a "lumpedPointDisplacement" type.
labelList lumpedPointPatchList(const pointVectorField &pvf)
Return the patch-ids associated with a "lumpedPointDisplacement" type.
label setInterpolators(const pointVectorField &pvf, const pointField &points0)
Return the patch-ids associated with a "lumpedPointDisplacement" type.
List< lumpedPointStateTuple > lumpedPointStates(const dictionary &dict, quaternion::eulerOrder rotOrder=quaternion::eulerOrder::ZXZ, bool degrees=false)
Load a list of states from a dictionary.
pointIOField points0Field(const polyMesh &mesh)
Return the 0 or constant points field.
Namespace for OpenFOAM.
static autoPtr< GeoFieldType > loadPointField(const pointMesh::Mesh &mesh, const IOobject *io)
List< label > labelList
A List of labels.
Definition List.H:62
messageStream Info
Information stream (stdout output on master, null elsewhere).
GeometricField< vector, pointPatchField, pointMesh > pointVectorField
vectorIOField pointIOField
pointIOField is a vectorIOField.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
vectorField pointField
pointField is a vectorField.
Tuple2< scalar, lumpedPointState > lumpedPointStateTuple
dictionary dict
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::NO_REGISTER)))