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 -------------------------------------------------------------------------------
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 \*---------------------------------------------------------------------------*/
28 
31 #include "transformField.H"
32 #include "cellZoneMesh.H"
33 #include "bitSet.H"
34 #include "syncTools.H"
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40  defineTypeNameAndDebug(multiSolidBodyMotionSolver, 0);
42  (
43  motionSolver,
44  multiSolidBodyMotionSolver,
45  dictionary
46  );
47 }
48 
49 
50 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
51 
52 Foam::multiSolidBodyMotionSolver::multiSolidBodyMotionSolver
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 : "
83  << flatOutput(mesh.cellZones().names()) << nl
84  << " Valid groups: "
86  << nl
87  << exit(FatalIOError);
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 // ************************************************************************* //
A class for handling keywords in dictionaries.
Definition: keyType.H:66
dictionary dict
const labelIOList & zoneIDs
Definition: correctPhi.H:59
void set(const bitSet &bitset)
Set specified bits from another bitset.
Definition: bitSetI.H:504
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:160
label nPoints() const noexcept
Number of mesh points.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
void transformPoints(vectorField &, const septernion &, const vectorField &)
Transform given vectorField of coordinates with the given septernion.
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
labelList sortedToc() const
The indices of the on bits as a sorted labelList.
Definition: bitSetI.H:447
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
const cellList & cells() const
const dictionary & coeffDict() const
Const access to the coefficients dictionary.
Definition: motionSolver.H:173
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:441
Macros for easy insertion into run-time selection tables.
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
Definition: PackedListI.H:455
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
Spatial transformation functions for primitive fields.
Foam::cellZoneMesh.
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
dynamicFvMesh & mesh
const pointField & points
labelList indices(const wordRe &matcher, const bool useGroups=true) const
Return (sorted) zone indices for all matches.
Definition: ZoneMesh.C:435
const Time & time() const noexcept
Return time registry.
static autoPtr< solidBodyMotionFunction > New(const dictionary &SBMFCoeffs, const Time &runTime)
Select constructed from the SBMFCoeffs dictionary and Time.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Definition: tmp.H:206
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1103
static void syncPointList(const polyMesh &mesh, List< T > &pointValues, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronize values on all mesh points.
virtual tmp< pointField > curPoints() const
Return point location obtained from the current motion field.
defineTypeNameAndDebug(combustionModel, 0)
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:59
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:627
Virtual base class for displacement motion solvers, where the point motion is relative to a set of fi...
A List with indirect addressing. Like IndirectList but does not store addressing. ...
Definition: faMatrix.H:56
wordList groupNames() const
A list of the zone group names (if any)
Definition: ZoneMesh.C:369
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
Definition: polyMesh.H:678
wordList names() const
A list of the zone names.
Definition: ZoneMesh.C:362
messageStream Info
Information stream (stdout output on master, null elsewhere)
void reset()
Clear all bits but do not adjust the addressable size.
Definition: PackedListI.H:551
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
const polyMesh & mesh() const
Return reference to mesh.
Definition: motionSolver.H:165
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Namespace for OpenFOAM.
A keyword and a list of tokens is an &#39;entry&#39;.
Definition: entry.H:63
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Definition: FlatOutput.H:225
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...