Loading...
Searching...
No Matches
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
59 labelList cellIDs;
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 {
90 FatalIOErrorInFunction(dict)
91 << "No matching cellZones: " << cellZoneName << nl
92 << " Valid zones : "
93 << flatOutput(mesh.cellZones().names()) << nl
94 << " Valid groups: "
95 << flatOutput(mesh.cellZones().groupNames())
96 << nl
97 << exit(FatalIOError);
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_ = returnReduceAnd(pointIDs_.empty());
135
136 if (moveAllCells_)
137 {
138 Info<< "Applying motion to entire mesh" << endl;
139 }
140}
141
142
143// ************************************************************************* //
if(patchID !=-1)
for(const label curEdgei :curPointEdges)
Foam::cellZoneMesh.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
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:81
A class for handling words, derived from Foam::string.
Definition word.H:66
zoneMotion(const dictionary &dict, const polyMesh &mesh)
Construct from dictionary.
Definition zoneMotion.C:32
dynamicFvMesh & mesh
const labelIOList & zoneIDs
Definition correctPhi.H:59
List< label > labelList
A List of labels.
Definition List.H:62
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
bool returnReduceAnd(const bool value, const int communicator=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
dictionary dict