attachDetach.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011 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  //- Disallow default bitwise copy construct
111  attachDetach(const attachDetach&);
112 
113  //- Disallow default bitwise assignment
114  void operator=(const attachDetach&);
115 
116  //- Check validity of construction data
117  void checkDefinition();
118 
119  // Topological changes
120 
121  //- Attach interface
122  void attachInterface(polyTopoChange&) const;
123 
124  //- Detach interface
125  void detachInterface(polyTopoChange&) const;
126 
127  //- Calculate point match addressing
128  void calcPointMatchMap() const;
129 
130  //- Return point match map
131  const Map<label>& pointMatchMap() const;
132 
133  //- Clear addressing
134  void clearAddressing() const;
135 
136 
137  // Static data members
138 
139  //- Relative vertex position tolerance
140  static const scalar positionDifference_;
141 
142 
143 public:
144 
145  //- Runtime type information
146  TypeName("attachDetach");
147 
148 
149  // Constructors
150 
151  //- Construct from components
153  (
154  const word& name,
155  const label index,
156  const polyTopoChanger& mme,
157  const word& faceZoneName,
158  const word& masterPatchName,
159  const word& slavePatchName,
160  const scalarField& triggerTimes,
161  const bool manualTrigger = false
162  );
163 
164  //- Construct from dictionary
166  (
167  const word& name,
168  const dictionary& dict,
169  const label index,
170  const polyTopoChanger& mesh
171  );
172 
173 
174  //- Destructor
175  virtual ~attachDetach();
176 
177 
178  // Member Functions
179 
180  //- Return master patch ID
181  const polyPatchID& masterPatchID() const
182  {
183  return masterPatchID_;
184  }
185 
186  //- Return slave patch ID
187  const polyPatchID& slavePatchID() const
188  {
189  return slavePatchID_;
190  }
191 
192  //- Is the interface attached?
193  bool attached() const
194  {
195  return state_ == ATTACHED;
196  }
198  const Switch& manualTrigger() const
199  {
200  return manualTrigger_;
201  }
202 
203  // Manually set attach. Use only with manual trigger
204  bool setAttach() const;
205 
206  // Manually set detach. Use only with manual trigger
207  bool setDetach() const;
208 
209  //- Check for topology change
210  virtual bool changeTopology() const;
211 
212  //- Insert the layer addition/removal instructions
213  // into the topological change
214  virtual void setRefinement(polyTopoChange&) const;
215 
216  //- Modify motion points to comply with the topological change
217  virtual void modifyMotionPoints(pointField& motionPoints) const;
218 
219  //- Force recalculation of locally stored data on topological change
220  virtual void updateMesh(const mapPolyMesh&);
221 
222  //- Get reference to trigger times
223  const scalarField& triggerTimes() const
224  {
225  return triggerTimes_;
226  }
227 
228 
229  //- Write
230  virtual void write(Ostream&) const;
231 
232  //- Write dictionary
233  virtual void writeDict(Ostream&) const;
234 };
235 
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 } // End namespace Foam
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 #endif
244 
245 // ************************************************************************* //
bool attached() const
Is the interface attached?
Definition: attachDetach.H:192
dictionary dict
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
const polyPatchID & masterPatchID() const
Return master patch ID.
Definition: attachDetach.H:180
virtual void modifyMotionPoints(pointField &motionPoints) const
Modify motion points to comply with the topological change.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
Definition: attachDetach.C:404
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.
Definition: Switch.H:60
const word & name() const
Return name of this modifier.
const scalarField & triggerTimes() const
Get reference to trigger times.
Definition: attachDetach.H:222
label index() const
Return the index of this modifier.
TypeName("attachDetach")
Runtime type information.
virtual void write(Ostream &) const
Write.
Definition: attachDetach.C:453
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
const polyPatchID & slavePatchID() const
Return slave patch ID.
Definition: attachDetach.H:186
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 bool changeTopology() const
Check for topology change.
Definition: attachDetach.C:336
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
bool setAttach() const
Definition: attachDetach.C:306
const Switch & manualTrigger() const
Definition: attachDetach.H:197
virtual void writeDict(Ostream &) const
Write dictionary.
Definition: attachDetach.C:464
Direct mesh changes based on v1.3 polyTopoChange syntax.
virtual ~attachDetach()
Destructor.
Definition: attachDetach.C:298
bool setDetach() const
Definition: attachDetach.C:321
Namespace for OpenFOAM.