dynamicMultiMotionSolverFvMesh.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-2022 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
30#include "volFields.H"
31#include "bitSet.H"
32#include "syncTools.H"
33
34// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35
36namespace Foam
37{
40 (
44 );
46 (
49 doInit
50 );
51}
52
53
54// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
55
57(
58 const IOobject& io,
59 const bool doInit
60)
61:
62 dynamicFvMesh(io, doInit)
63{
64 if (doInit)
65 {
66 init(false); // do not initialise lower levels
67 }
68}
69
70
72{
73 if (doInit)
74 {
75 dynamicFvMesh::init(doInit);
76 }
77
78 IOdictionary dynDict
79 (
81 (
82 "dynamicMeshDict",
83 time().constant(),
84 *this,
87 false
88 )
89 );
90 const dictionary& dynamicMeshCoeffs = dynDict.subDict(typeName + "Coeffs");
91
92 motionPtr_.resize(dynamicMeshCoeffs.size());
93 pointIDs_.resize(dynamicMeshCoeffs.size());
94
95 label zonei = 0;
96
97 bitSet movePts;
98
99 for (const entry& dEntry : dynamicMeshCoeffs)
100 {
101 if (dEntry.isDict())
102 {
103 const dictionary& subDict = dEntry.dict();
104
105 wordRe cellZoneName;
106 subDict.readEntry("cellZone", cellZoneName);
107
108 // Also handles groups, multiple zones (as wordRe match) ...
109 labelList zoneIDs = cellZones().indices(cellZoneName);
110
111 if (zoneIDs.empty())
112 {
113 FatalIOErrorInFunction(dynamicMeshCoeffs)
114 << "No matching cellZones: " << cellZoneName << nl
115 << " Valid zones : "
116 << flatOutput(cellZones().names()) << nl
117 << " Valid groups: "
118 << flatOutput(cellZones().groupNames())
119 << nl
120 << exit(FatalIOError);
121 }
122
124
125 motionPtr_.set
126 (
127 zonei,
129 (
130 *this,
131 IOdictionary(io, subDict)
132 )
133 );
134
135
136 // Markup points associated with cell zone(s)
137
138 movePts.reset();
139 movePts.resize(nPoints());
140
141 for (const label zoneID : zoneIDs)
142 {
143 for (const label celli : cellZones()[zoneID])
144 {
145 for (const label facei : cells()[celli])
146 {
147 movePts.set(faces()[facei]);
148 }
149 }
150 }
151
153 (
154 *this, movePts, orEqOp<unsigned int>(), 0u
155 );
156
157 pointIDs_[zonei] = movePts.sortedToc();
158
159 Info<< "Applying motionSolver " << motionPtr_[zonei].type()
160 << " to "
161 << returnReduce(pointIDs_[zonei].size(), sumOp<label>())
162 << " points of cellZone " << cellZoneName << endl;
163
164 ++zonei;
165 }
166 }
167
168 motionPtr_.resize(zonei);
169 pointIDs_.resize(zonei);
170
171 // Assume changed ...
172 return true;
173}
174
175
176// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
177
179{
180 pointField transformedPts(points());
181
182 forAll(motionPtr_, zonei)
183 {
184 const labelList& zonePoints = pointIDs_[zonei];
185
186 const pointField newPoints(motionPtr_[zonei].newPoints());
187
188 for (const label pointi : zonePoints)
189 {
190 transformedPts[pointi] = newPoints[pointi];
191 }
192 }
193
194 fvMesh::movePoints(transformedPts);
195
196 static bool hasWarned = false;
197
198 volVectorField* Uptr = getObjectPtr<volVectorField>("U");
199
200 if (Uptr)
201 {
203 }
204 else if (!hasWarned)
205 {
206 hasWarned = true;
207
209 << "Did not find volVectorField U."
210 << " Not updating U boundary conditions." << endl;
211 }
212
213 return true;
214}
215
216
217// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
void correctBoundaryConditions()
Correct boundary field.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
@ MUST_READ_IF_MODIFIED
Definition: IOobject.H:180
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
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
Definition: UListI.H:427
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
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
Abstract base class for geometry and/or topology changing fvMesh.
Definition: dynamicFvMesh.H:81
Mesh motion described per cellZone. Individual motion solvers solve over whole domain but are only ap...
virtual bool init(const bool doInit)
Initialise all non-demand-driven data.
virtual bool update()
Update the mesh for both mesh motion and topology change.
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:70
virtual bool movePoints()
Avoid masking surfaceInterpolation method.
constant condensation/saturation model.
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 wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:83
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
const pointField & points
label nPoints
const cellShapeList & cells
const labelIOList & zoneIDs
Definition: correctPhi.H:59
const labelIOList & zoneID
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
#define WarningInFunction
Report a warning using Foam::Warning.
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
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.
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
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333