pointCells.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) 2007-2019 PCOpt/NTUA
9  Copyright (C) 2013-2019 FOSS GP
10  Copyright (C) 2019-2022 OpenCFD Ltd.
11 -------------------------------------------------------------------------------
12 License
13  This file is part of OpenFOAM.
14 
15  OpenFOAM is free software: you can redistribute it and/or modify it
16  under the terms of the GNU General Public License as published by
17  the Free Software Foundation, either version 3 of the License, or
18  (at your option) any later version.
19 
20  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
21  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23  for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
27 
28 \*---------------------------------------------------------------------------*/
29 
30 #include "pointCells.H"
31 #include "fvMesh.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 
39 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 
43 
44 
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46 
47 pointCells::pointCells
48 (
49  const fvMesh& mesh,
50  const dictionary& dict
51 )
52 :
54 {
55  boolList isZeroed(mesh_.nCells(), false);
56  labelList zeroedIDs(mesh_.nCells(), -1);
57  label i(0);
58  forAll(mesh_.boundary(), patchI)
59  {
60  const fvPatch& patch = mesh_.boundary()[patchI];
61  for (const word& patchType : zeroATCPatches_)
62  {
63  if (patch.type() == patchType)
64  {
65  const labelList& meshPoints =
66  mesh_.boundaryMesh()[patchI].meshPoints();
67 
68  for (const label pointI : meshPoints)
69  {
70  const labelList& pointCells = mesh_.pointCells()[pointI];
71  for (const label cellI : pointCells)
72  {
73  if (!isZeroed[cellI])
74  {
75  zeroedIDs[i++] = cellI;
76  isZeroed[cellI] = true;
77  }
78  }
79  }
80  }
81  }
82  }
84  {
85  const label& zoneID = zeroATCZones_[zI];
86  if (zoneID != -1)
87  {
88  const labelList& zoneCells = mesh_.cellZones()[zoneID];
89  for (const label cellI : zoneCells)
90  {
91  if (!isZeroed[cellI])
92  {
93  zeroedIDs[i++] = cellI;
94  isZeroed[cellI] = true;
95  }
96  }
97  }
98  }
99  zeroedIDs.resize(i);
100  zeroATCcells_ = std::move(zeroedIDs);
101 
102  Info<< "Zeroing ATC on "
103  << returnReduce(zeroATCcells_.size(), sumOp<label>())
104  << " cells" << nl << endl;
105 }
106 
107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
108 
109 } // End namespace Foam
110 
111 // ************************************************************************* //
dictionary dict
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
Smooth ATC in cells having a point to a set of patches supplied by type.
Definition: pointCells.H:52
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.
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
labelList zeroATCcells_
Definition: zeroATCcells.H:76
dynamicFvMesh & mesh
wordList zeroATCPatches_
Definition: zeroATCcells.H:74
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition: polyMesh.H:609
A class for handling words, derived from Foam::string.
Definition: word.H:63
const fvMesh & mesh_
Definition: zeroATCcells.H:73
labelList zeroATCZones_
Definition: zeroATCcells.H:75
const labelListList & pointCells() const
Base class for selecting cells on which to zero the ATC term.
Definition: zeroATCcells.H:52
defineTypeNameAndDebug(combustionModel, 0)
void resize(const label newLen)
Adjust size of PtrList.
Definition: PtrList.C:95
label nCells() const noexcept
Number of mesh cells.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
const std::string patch
OpenFOAM patch number as a std::string.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
Definition: polyMesh.H:679
messageStream Info
Information stream (stdout output on master, null elsewhere)
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
Definition: fvMesh.H:395
List< label > labelList
A List of labels.
Definition: List.H:62
Namespace for OpenFOAM.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)