faceToFace.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) 2018 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 "faceToFace.H"
30 #include "polyMesh.H"
31 #include "faceSet.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  defineTypeNameAndDebug(faceToFace, 0);
39  addToRunTimeSelectionTable(topoSetSource, faceToFace, word);
40  addToRunTimeSelectionTable(topoSetSource, faceToFace, istream);
41  addToRunTimeSelectionTable(topoSetFaceSource, faceToFace, word);
42  addToRunTimeSelectionTable(topoSetFaceSource, faceToFace, istream);
43 }
44 
45 
46 Foam::topoSetSource::addToUsageTable Foam::faceToFace::usage_
47 (
48  faceToFace::typeName,
49  "\n Usage: faceToFace <faceSet>\n\n"
50  " Select all faces in the faceSet\n\n"
51 );
52 
53 
54 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
55 
56 Foam::faceToFace::faceToFace
57 (
58  const polyMesh& mesh,
59  const word& setName
60 )
61 :
62  topoSetFaceSource(mesh),
63  names_(one(), setName)
64 {}
65 
66 
67 Foam::faceToFace::faceToFace
68 (
69  const polyMesh& mesh,
70  const dictionary& dict
71 )
72 :
73  topoSetFaceSource(mesh),
74  names_()
75 {
76  // Look for 'sets' or 'set'
77  if (!dict.readIfPresent("sets", names_))
78  {
79  names_.resize(1);
80  dict.readEntry("set", names_.first());
81  }
82 }
83 
84 
85 Foam::faceToFace::faceToFace
86 (
87  const polyMesh& mesh,
88  Istream& is
89 )
90 :
91  topoSetFaceSource(mesh),
92  names_(one(), word(checkIs(is)))
93 {}
94 
95 
96 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
97 
98 void Foam::faceToFace::applyToSet
99 (
100  const topoSetSource::setAction action,
101  topoSet& set
102 ) const
103 {
104  if (action == topoSetSource::ADD || action == topoSetSource::NEW)
105  {
106  if (verbose_)
107  {
108  Info<< " Adding all elements of faceSet "
109  << flatOutput(names_) << nl;
110  }
111 
112  for (const word& setName : names_)
113  {
114  faceSet loadedSet(mesh_, setName);
115 
116  set.addSet(loadedSet);
117  }
118  }
119  else if (action == topoSetSource::SUBTRACT)
120  {
121  if (verbose_)
122  {
123  Info<< " Removing all elements of faceSet "
124  << flatOutput(names_) << nl;
125  }
126 
127  for (const word& setName : names_)
128  {
129  faceSet loadedSet(mesh_, setName);
130 
131  set.subtractSet(loadedSet);
132  }
133  }
134 }
135 
136 
137 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::topoSetSource::ADD
Add elements to the set.
Definition: topoSetSource.H:101
Foam::topoSetSource::addToUsageTable
Class with constructor to add usage string to table.
Definition: topoSetSource.H:124
Foam::topoSetSource::setAction
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:99
Foam::topoSetSource::NEW
Create a new set and ADD elements to it.
Definition: topoSetSource.H:106
polyMesh.H
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
faceSet.H
dict
dictionary dict
Definition: searchingEngine.H:14
faceToFace.H
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::topoSetSource::SUBTRACT
Subtract elements from the set.
Definition: topoSetSource.H:102
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::flatOutput
FlatOutput< Container > flatOutput(const Container &obj, label len=0)
Global flatOutput function.
Definition: FlatOutput.H:85
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)