attachDetach.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::attachDetach
26 
27 Description
28  Attach/detach boundary mesh modifier. This modifier takes a set of
29  internal faces and converts them into boundary faces and vice versa
30  based on the given activation switch.
31 
32  The patch is oriented using the flip map in the face zone. The
33  oriented faces are put into the master patch and their mirror
34  images into the slave.
35 
36 SourceFiles
37  attachDetach.C
38  attachInterface.C
39  detachInterface.C
40  attachDetachPointMatchMap.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef attachDetach_H
45 #define attachDetach_H
46 
47 #include "polyMeshModifier.H"
48 #include "polyPatchID.H"
49 #include "ZoneIDs.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class attachDetach Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class attachDetach
61 :
62  public polyMeshModifier
63 {
64  // Data types
65 
66  //- State of the modifier
67  enum modifierState
68  {
69  UNKNOWN,
70  ATTACHED,
71  DETACHED
72  };
73 
74 
75  // Private Data
76 
77  //- Master face zone ID
78  faceZoneID faceZoneID_;
79 
80  //- Master patch ID. Holds faces with original orientation
81  polyPatchID masterPatchID_;
82 
83  //- Slave patch ID. Holds mirrored faces
84  polyPatchID slavePatchID_;
85 
86  //- List of trigger times
87  scalarField triggerTimes_;
88 
89  //- Use manual trigger
90  Switch manualTrigger_;
91 
92  //- Trigger time index
93  mutable label triggerIndex_;
94 
95  //- State of the modifier
96  mutable modifierState state_;
97 
98  //- Attach/detach trigger
99  mutable bool trigger_;
100 
101 
102  // Private addressing data. Created on topology change
103 
104  //- Map of matching points
105  mutable Map<label>* pointMatchMapPtr_;
106 
107 
108  // Private Member Functions
109 
110  //- Check validity of construction data
111  void checkDefinition();
112 
113  // Topological changes
114 
115  //- Attach interface
116  void attachInterface(polyTopoChange&) const;
117 
118  //- Detach interface
119  void detachInterface(polyTopoChange&) const;
120 
121  //- Calculate point match addressing
122  void calcPointMatchMap() const;
123 
124  //- Return point match map
125  const Map<label>& pointMatchMap() const;
126 
127  //- Clear addressing
128  void clearAddressing() const;
129 
130 
131  // Static Data Members
132 
133  //- Relative vertex position tolerance
134  static const scalar positionDifference_;
135 
136 
137 public:
138 
139  //- Runtime type information
140  TypeName("attachDetach");
141 
142 
143  // Constructors
144 
145  //- Construct from components
147  (
148  const word& name,
149  const label index,
150  const polyTopoChanger& mme,
151  const word& faceZoneName,
152  const word& masterPatchName,
153  const word& slavePatchName,
154  const scalarField& triggerTimes,
155  const bool manualTrigger = false
156  );
157 
158  //- Construct from dictionary
160  (
161  const word& name,
162  const dictionary& dict,
163  const label index,
164  const polyTopoChanger& mesh
165  );
166 
167  //- Disallow default bitwise copy construction
168  attachDetach(const attachDetach&) = delete;
169 
170 
171  //- Destructor
172  virtual ~attachDetach();
173 
174 
175  // Member Functions
176 
177  //- Return master patch ID
178  const polyPatchID& masterPatchID() const
179  {
180  return masterPatchID_;
181  }
182 
183  //- Return slave patch ID
184  const polyPatchID& slavePatchID() const
185  {
186  return slavePatchID_;
187  }
188 
189  //- Is the interface attached?
190  bool attached() const
191  {
192  return state_ == ATTACHED;
193  }
195  const Switch& manualTrigger() const
196  {
197  return manualTrigger_;
198  }
199 
200  // Manually set attach. Use only with manual trigger
201  bool setAttach() const;
202 
203  // Manually set detach. Use only with manual trigger
204  bool setDetach() const;
205 
206  //- Check for topology change
207  virtual bool changeTopology() const;
208 
209  //- Insert the layer addition/removal instructions
210  // into the topological change
211  virtual void setRefinement(polyTopoChange&) const;
212 
213  //- Modify motion points to comply with the topological change
214  virtual void modifyMotionPoints(pointField& motionPoints) const;
215 
216  //- Force recalculation of locally stored data on topological change
217  virtual void updateMesh(const mapPolyMesh&);
218 
219  //- Get reference to trigger times
220  const scalarField& triggerTimes() const
221  {
222  return triggerTimes_;
223  }
224 
225  //- Write
226  virtual void write(Ostream&) const;
227 
228  //- Write dictionary
229  virtual void writeDict(Ostream&) const;
230 
231 
232  // Member Operators
233 
234  //- Disallow default bitwise assignment
235  void operator=(const attachDetach&) = delete;
236 };
237 
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 } // End namespace Foam
242 
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 
245 #endif
246 
247 // ************************************************************************* //
virtual void write(Ostream &) const
Write.
Definition: attachDetach.C:453
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
Definition: attachDetach.C:404
dictionary dict
void operator=(const attachDetach &)=delete
Disallow default bitwise assignment.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
const polyPatchID & masterPatchID() const
Return master patch ID.
Definition: attachDetach.H:177
bool attached() const
Is the interface attached?
Definition: attachDetach.H:189
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
bool setAttach() const
Definition: attachDetach.C:306
TypeName("attachDetach")
Runtime type information.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
dynamicFvMesh & mesh
List of mesh modifiers defining the mesh dynamics.
A class for handling words, derived from string.
Definition: word.H:59
virtual void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
Definition: attachDetach.C:440
Virtual base class for mesh modifiers.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
Attach/detach boundary mesh modifier. This modifier takes a set of internal faces and converts them i...
Definition: attachDetach.H:59
const Switch & manualTrigger() const
Definition: attachDetach.H:194
virtual void writeDict(Ostream &) const
Write dictionary.
Definition: attachDetach.C:464
virtual bool changeTopology() const
Check for topology change.
Definition: attachDetach.C:336
bool setDetach() const
Definition: attachDetach.C:321
Direct mesh changes based on v1.3 polyTopoChange syntax.
const scalarField & triggerTimes() const
Get reference to trigger times.
Definition: attachDetach.H:219
const polyPatchID & slavePatchID() const
Return slave patch ID.
Definition: attachDetach.H:183
const word & name() const
Return name of this modifier.
virtual void modifyMotionPoints(pointField &motionPoints) const
Modify motion points to comply with the topological change.
label index() const
Return the index of this modifier.
virtual ~attachDetach()
Destructor.
Definition: attachDetach.C:298
attachDetach(const word &name, const label index, const polyTopoChanger &mme, const word &faceZoneName, const word &masterPatchName, const word &slavePatchName, const scalarField &triggerTimes, const bool manualTrigger=false)
Construct from components.
Definition: attachDetach.C:234
Namespace for OpenFOAM.