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"
33
34// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
35
36namespace Foam
37{
38 template<class GeoFieldType>
40 (
41 const pointMesh::Mesh& mesh,
42 const IOobject* io
43 )
44 {
45 if (io && io->headerClassName() == GeoFieldType::typeName)
46 {
47 Info<< "Reading " << GeoFieldType::typeName
48 << ' ' << io->name() << endl;
49
51 (
53 (
54 io->name(),
55 io->instance(),
56 io->local(),
57 io->db(),
61 ),
62 mesh
63 );
64 }
65
66 return nullptr;
67 }
68}
69
70
71// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72
75(
76 const dictionary& dict,
78 bool degrees
79)
80{
81 quaternion::eulerOrderNames.readIfPresent
82 (
83 "rotationOrder",
84 dict,
85 rotOrder
86 );
87
88 dict.readIfPresent("degrees", degrees);
89
90 Info<<"Reading states\n";
91 List<dictionary> entries(dict.lookup("response"));
92
94
95 for (const dictionary& subDict : entries)
96 {
97 states.append
98 (
100 (
101 subDict.get<scalar>("time"),
102 lumpedPointState(subDict)
103 )
104 );
105 }
106
107 return states.shrink();
108}
109
110
113(
114 Istream& is,
115 quaternion::eulerOrder rotOrder,
116 bool degrees
117)
118{
119 dictionary dict(is);
120 return lumpedPointStates(dict, rotOrder, degrees);
121}
122
123
126(
127 const fileName& file,
128 quaternion::eulerOrder rotOrder,
129 bool degrees
130)
131{
132 IFstream is(file);
133 return lumpedPointStates(is, rotOrder, degrees);
134}
135
136
139{
140 return pointIOField(points0MotionSolver::points0IO(mesh));
141}
142
143
146{
147 return lumpedPointDisplacementPointPatchVectorField::patchIds(pvf);
148}
149
150
152(
153 const polyMesh& mesh
154)
155{
156 IOobjectList objects0(mesh, "0");
157
158 pointMesh pMesh(mesh);
159
160 autoPtr<pointVectorField> displacePtr =
161 loadPointField<pointVectorField>
162 (
163 pMesh,
164 objects0.findObject("pointDisplacement")
165 );
166
167 if (!displacePtr)
168 {
169 Info<< "No valid pointDisplacement" << endl;
170 return labelList();
171 }
172
173 return lumpedPointPatchList(*displacePtr);
174}
175
176
177Foam::label
179(
180 const pointVectorField& pvf,
181 const pointField& points0
182)
183{
184 return
185 lumpedPointDisplacementPointPatchVectorField::setPatchControls
186 (
187 pvf,
188 points0
189 );
190}
191
192
194(
195 const fvMesh& mesh,
196 const pointField& points0
197)
198{
199 IOobjectList objects0(mesh, "0");
200
201 pointMesh pMesh(mesh);
202
203 autoPtr<pointVectorField> displacePtr =
204 loadPointField<pointVectorField>
205 (
206 pMesh,
207 objects0.findObject("pointDisplacement")
208 );
209
210 if (!displacePtr)
211 {
212 Info<< "No valid pointDisplacement" << endl;
213 return 0;
214 }
215
216 return setPatchControls(*displacePtr, points0);
217}
218
219
221(
222 const fvMesh& mesh
223)
224{
226
228}
229
230
232(
233 const pointVectorField& pvf,
234 const pointField& points0
235)
236{
237 return
238 lumpedPointDisplacementPointPatchVectorField::setInterpolators
239 (
240 pvf,
241 points0
242 );
243}
244
245
247(
248 const fvMesh& mesh,
249 const pointField& points0
250)
251{
252 IOobjectList objects0(mesh, "0");
253
254 pointMesh pMesh(mesh);
255
256 autoPtr<pointVectorField> displacePtr =
257 loadPointField<pointVectorField>
258 (
259 pMesh,
260 objects0.findObject("pointDisplacement")
261 );
262
263 if (!displacePtr)
264 {
265 Info<< "No valid pointDisplacement" << endl;
266 return 0;
267 }
268
269 return setInterpolators(*displacePtr, points0);
270}
271
272
274(
275 const fvMesh& mesh
276)
277{
279
281}
282
283
284// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
DynamicList< T, SizeMin > & shrink()
Shrink the allocated space to the number of elements used.
Definition: DynamicListI.H:434
void append(const T &val)
Copy append an element to the end of this list.
Definition: DynamicListI.H:503
Input from file stream, using an ISstream.
Definition: IFstream.H:57
A primitive field of type <T> with automated input and output.
Definition: IOField.H:58
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:59
const IOobject * findObject(const word &objName) const
Return const pointer to the object found by name.
Definition: IOobjectList.C:293
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
const word & headerClassName() const noexcept
Return name of the class name read from header.
Definition: IOobjectI.H:83
const objectRegistry & db() const noexcept
Return the local objectRegistry.
Definition: IOobject.C:500
bool registerObject() const noexcept
Should object created with this IOobject be registered?
Definition: IOobjectI.H:107
const fileName & local() const noexcept
Read access to local path component.
Definition: IOobjectI.H:208
const fileName & instance() const noexcept
Read access to instance path component.
Definition: IOobjectI.H:196
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: Tuple2.H:58
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling file names.
Definition: fileName.H:76
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
The state of lumped points corresponds to positions and rotations.
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:55
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
eulerOrder
Euler-angle rotation order.
Definition: quaternion.H:104
dynamicFvMesh & mesh
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
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)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
dictionary dict
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, false)))