zoneMotion.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-2017 OpenFOAM Foundation
9 Copyright (C) 2020-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
29#include "zoneMotion.H"
30#include "syncTools.H"
31#include "bitSet.H"
32#include "cellSet.H"
33#include "cellZoneMesh.H"
34#include "dictionary.H"
35
36// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37
39(
40 const dictionary& dict,
41 const polyMesh& mesh
42)
43:
44 pointIDs_(),
45 moveAllCells_(true)
46{
47 // Specified cellSet?
48 word cellSetName;
49
50 if
51 (
52 dict.readIfPresent("cellSet", cellSetName)
53 && cellSetName == "none" // Compat: ignore 'none' placeholder
54 )
55 {
56 cellSetName.clear();
57 }
58
60 if (!cellSetName.empty())
61 {
62 Info<< "Applying motion to cellSet: " << cellSetName << endl;
63
64 cellIDs = cellSet(mesh, cellSetName).toc();
65 }
66
67
68 // Specified cellZone(s) ?
69 wordRe cellZoneName;
70
71 if
72 (
73 dict.readIfPresent("cellZone", cellZoneName)
74 && cellZoneName == "none" // Compat: ignore 'none' placeholder
75 )
76 {
77 cellZoneName.clear();
78 }
79
81 if (!cellZoneName.empty())
82 {
83 Info<< "Applying motion to cellZone: " << cellZoneName << endl;
84
85 // Also handles groups, multiple zones (as wordRe match) ...
86 zoneIDs = mesh.cellZones().indices(cellZoneName);
87
88 if (zoneIDs.empty())
89 {
91 << "No matching cellZones: " << cellZoneName << nl
92 << " Valid zones : "
94 << " Valid groups: "
96 << nl
98 }
99 }
100
101 if (!cellSetName.empty() || !cellZoneName.empty())
102 {
103 bitSet movePts(mesh.nPoints());
104
105 // Markup points associated with cell zone(s)
106 for (const label zoneID : zoneIDs)
107 {
108 for (const label celli : mesh.cellZones()[zoneID])
109 {
110 for (const label facei : mesh.cells()[celli])
111 {
112 movePts.set(mesh.faces()[facei]);
113 }
114 }
115 }
116
117 // Markup points associated with cellSet
118 for (const label celli : cellIDs)
119 {
120 for (const label facei : mesh.cells()[celli])
121 {
122 movePts.set(mesh.faces()[facei]);
123 }
124 }
125
127
128 pointIDs_ = movePts.sortedToc();
129 }
130
131
132 // No cell points selected (as set or zones) => move all points
133
134 moveAllCells_ = returnReduce(pointIDs_.empty(), andOp<bool>());
135
136 if (moveAllCells_)
137 {
138 Info<< "Applying motion to entire mesh" << endl;
139 }
140}
141
142
143// ************************************************************************* //
Foam::cellZoneMesh.
labelList cellIDs
List< Key > toc() const
The table of contents (the keys) in unsorted order.
Definition: HashTable.C:122
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 collection of cell labels.
Definition: cellSet.H:54
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
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 wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:83
void clear()
Clear string and regular expression.
Definition: wordReI.H:193
A class for handling words, derived from Foam::string.
Definition: word.H:68
Intermediate class for handling "zonified" motion. Can select motion for the entire mesh,...
Definition: zoneMotion.H:71
dynamicFvMesh & mesh
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
const labelIOList & zoneIDs
Definition: correctPhi.H:59
const labelIOList & zoneID
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
dictionary dict