Loading...
Searching...
No Matches
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
52Foam::multiSolidBodyMotionSolver::multiSolidBodyMotionSolver
53(
54 const polyMesh& mesh,
55 const IOdictionary& dict
56)
57:
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: "
85 << flatOutput(mesh.cellZones().groupNames())
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.
label size() const noexcept
The number of elements in list.
Definition DLListBase.H:194
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
void resize(const label len)
Adjust allocated size of list.
Definition ListI.H:153
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
void reset()
Clear all bits but do not adjust the addressable size.
A List with indirect addressing. Like IndirectList but does not store addressing.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition bitSet.H:61
labelList sortedToc() const
The indices of the on bits as a sorted labelList.
Definition bitSetI.H:441
void set(const bitSet &bitset)
Set specified bits from another bitset.
Definition bitSetI.H:502
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition dictionary.C:441
A keyword and a list of tokens is an 'entry'.
Definition entry.H:66
A class for handling keywords in dictionaries.
Definition keyType.H:69
Virtual base class for mesh motion solver.
const polyMesh & mesh() const
Return reference to mesh.
const dictionary & coeffDict() const
Const access to the coefficients dictionary.
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.
Virtual base class for displacement motion solvers, where the point motion is relative to a set of fi...
points0MotionSolver(const points0MotionSolver &)=delete
No copy construct.
pointIOField points0_
Starting points.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
static autoPtr< solidBodyMotionFunction > New(const word &motionType, const dictionary &dict, const Time &runTime)
Construct and dispatch motionType with dictionary and Time.
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:75
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Definition tmp.H:215
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition error.H:629
const pointField & points
const labelIOList & zoneIDs
Definition correctPhi.H:59
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
messageStream Info
Information stream (stdout output on master, null elsewhere).
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Definition FlatOutput.H:217
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
vectorField pointField
pointField is a vectorField.
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:125
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299
Spatial transformation functions for primitive fields.