FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 
48 #include <OpenFOAM/polyPatchID.H>
49 #include <OpenFOAM/ZoneIDs.H>
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class attachDetach Declaration
58 \*---------------------------------------------------------------------------*/
59 
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 
176  virtual ~attachDetach();
177 
178 
179  // Member Functions
180 
181  //- Return master patch ID
182  const polyPatchID& masterPatchID() const
183  {
184  return masterPatchID_;
185  }
186 
187  //- Return slave patch ID
188  const polyPatchID& slavePatchID() const
189  {
190  return slavePatchID_;
191  }
192 
193  //- Is the interface attached?
194  bool attached() const
195  {
196  return state_ == ATTACHED;
197  }
198 
199  const Switch& manualTrigger() const
200  {
201  return manualTrigger_;
202  }
203 
204  // Manually set attach. Use only with manual trigger
205  bool setAttach() const;
206 
207  // Manually set detach. Use only with manual trigger
208  bool setDetach() const;
209 
210  //- Check for topology change
211  virtual bool changeTopology() const;
212 
213  //- Insert the layer addition/removal instructions
214  // into the topological change
215  virtual void setRefinement(polyTopoChange&) const;
216 
217  //- Modify motion points to comply with the topological change
218  virtual void modifyMotionPoints(pointField& motionPoints) const;
219 
220  //- Force recalculation of locally stored data on topological change
221  virtual void updateMesh(const mapPolyMesh&);
222 
223  //- Get reference to trigger times
224  const scalarField& triggerTimes() const
225  {
226  return triggerTimes_;
227  }
228 
229 
230  //- Write
231  virtual void write(Ostream&) const;
232 
233  //- Write dictionary
234  virtual void writeDict(Ostream&) const;
235 };
236 
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 } // End namespace Foam
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 #endif
245 
246 // ************************ vim: set sw=4 sts=4 et: ************************ //