multiSolidBodyMotionSolver.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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2018-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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\*---------------------------------------------------------------------------*/
28
31#include "transformField.H"
32#include "cellZoneMesh.H"
33#include "bitSet.H"
34#include "syncTools.H"
35
36// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37
38namespace Foam
39{
42 (
46 );
47}
48
49
50// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
51
53(
54 const polyMesh& mesh,
55 const IOdictionary& dict
56)
57:
58 points0MotionSolver(mesh, dict, typeName)
59{
60 SBMFs_.resize(coeffDict().size());
61 pointIDs_.resize(coeffDict().size());
62
63 label zonei = 0;
64
65 bitSet movePts;
66
67 for (const entry& dEntry : coeffDict())
68 {
69 if (dEntry.isDict())
70 {
71 const keyType& cellZoneName = dEntry.keyword();
72
73 const dictionary& subDict = dEntry.dict();
74
75 // Also handles groups, multiple zones (as wordRe match) ...
76 labelList zoneIDs = mesh.cellZones().indices(cellZoneName);
77
78 if (zoneIDs.empty())
79 {
81 << "No matching cellZones: " << cellZoneName << nl
82 << " Valid zones : "
84 << " Valid groups: "
86 << nl
88 }
89
90 SBMFs_.set
91 (
92 zonei,
94 );
95
96
97 // Markup points associated with cell zone(s)
98
99 movePts.reset();
100 movePts.resize(mesh.nPoints());
101
102 for (const label zoneID : zoneIDs)
103 {
104 for (const label celli : mesh.cellZones()[zoneID])
105 {
106 for (const label facei : mesh.cells()[celli])
107 {
108 movePts.set(mesh.faces()[facei]);
109 }
110 }
111 }
112
114 (
115 mesh, movePts, orEqOp<unsigned int>(), 0u
116 );
117
118 pointIDs_[zonei] = movePts.sortedToc();
119
120 Info<< "Applying solid body motion " << SBMFs_[zonei].type()
121 << " to "
122 << returnReduce(pointIDs_[zonei].size(), sumOp<label>())
123 << " points of cellZone " << cellZoneName << endl;
124
125 ++zonei;
126 }
127 }
128
129 SBMFs_.resize(zonei);
130 pointIDs_.resize(zonei);
131}
132
133
134// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
135
137{
138 auto ttransformedPts = tmp<pointField>::New(mesh().points());
139 auto& transformedPts = ttransformedPts.ref();
140
141 forAll(SBMFs_, zonei)
142 {
143 const labelList& zonePoints = pointIDs_[zonei];
144
145 UIndirectList<point>(transformedPts, zonePoints) = transformPoints
146 (
147 SBMFs_[zonei].transformation(),
148 pointField(points0_, zonePoints)
149 );
150 }
151
152 return ttransformedPts;
153}
154
155
156// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Foam::cellZoneMesh.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
Definition: PackedListI.H:409
void reset()
Clear all bits but do not adjust the addressable size.
Definition: PackedListI.H:505
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
A List with indirect addressing. Like IndirectList but does not store addressing.
Definition: IndirectList.H:79
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
Definition: UListI.H:427
wordList groupNames() const
A list of the zone group names (if any)
Definition: ZoneMesh.C:311
wordList names() const
A list of the zone names.
Definition: ZoneMesh.C:304
labelList indices(const wordRe &matcher, const bool useGroups=true) const
Return (sorted) zone indices for all matches.
Definition: ZoneMesh.C:377
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:66
labelList sortedToc() const
The indices of the on bits as a sorted labelList.
Definition: bitSetI.H:533
void set(const bitSet &bitset)
Set specified bits from another bitset.
Definition: bitSetI.H:590
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:460
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:70
A class for handling keywords in dictionaries.
Definition: keyType.H:71
Virtual base class for mesh motion solver.
Definition: motionSolver.H:61
const polyMesh & mesh() const
Return reference to mesh.
Definition: motionSolver.H:144
const dictionary & coeffDict() const
Const access to the coefficients dictionary.
Definition: motionSolver.H:150
Solid-body motion of the mesh specified by a run-time selectable motion function.
virtual tmp< pointField > curPoints() const
Return point location obtained from the current motion field.
const Time & time() const noexcept
Return time registry.
Virtual base class for displacement motion solvers, where the point motion is relative to a set of fi...
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1108
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
Definition: polyMesh.H:504
label nPoints() const noexcept
Number of mesh points.
const cellList & cells() const
static void syncPointList(const polyMesh &mesh, List< T > &pointValues, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronize values on all mesh points.
A class for managing temporary objects.
Definition: tmp.H:65
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
dynamicFvMesh & mesh
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
const pointField & points
const labelIOList & zoneIDs
Definition: correctPhi.H:59
const labelIOList & zoneID
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Definition: FlatOutput.H:215
IOerror FatalIOError
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
void transformPoints(vectorField &, const septernion &, const vectorField &)
Transform given vectorField of coordinates with the given septernion.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
Spatial transformation functions for primitive fields.