initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / dynamicMesh / attachDetach / attachDetach.H
blobae6bd490401fca2bfd18b4c64b1c98458064da06
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::attachDetach
28 Description
29     Attach/detach boundary mesh modifier.  This modifier takes a set of
30     internal faces and converts them into boundary faces and vice versa
31     based on the given activation switch.
33     The patch is oriented using the flip map in the face zone.  The
34     oriented faces are put into the master patch and their mirror
35     images into the slave.
37 SourceFiles
38     attachDetach.C
39     attachInterface.C
40     detachInterface.C
41     attachDetachPointMatchMap.C
43 \*---------------------------------------------------------------------------*/
45 #ifndef attachDetach_H
46 #define attachDetach_H
48 #include "polyMeshModifier.H"
49 #include "polyPatchID.H"
50 #include "ZoneIDs.H"
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 namespace Foam
57 /*---------------------------------------------------------------------------*\
58                        Class attachDetach Declaration
59 \*---------------------------------------------------------------------------*/
61 class attachDetach
63     public polyMeshModifier
65     // Data types
67         //- State of the modifier
68         enum modifierState
69         {
70             UNKNOWN,
71             ATTACHED,
72             DETACHED
73         };
76     // Private data
78         //- Master face zone ID
79         faceZoneID faceZoneID_;
81         //- Master patch ID.  Holds faces with original orientation
82         polyPatchID masterPatchID_;
84         //- Slave patch ID.  Holds mirrored faces
85         polyPatchID slavePatchID_;
87         //- List of trigger times
88         scalarField triggerTimes_;
90         //- Use manual trigger
91         Switch manualTrigger_;
93         //- Trigger time index
94         mutable label triggerIndex_;
96         //- State of the modifier
97         mutable modifierState state_;
99         //- Attach/detach trigger
100         mutable bool trigger_;
103         // Private addressing data.  Created on topology change
105             //- Map of matching points
106             mutable Map<label>* pointMatchMapPtr_;
109     // Private Member Functions
111         //- Disallow default bitwise copy construct
112         attachDetach(const attachDetach&);
114         //- Disallow default bitwise assignment
115         void operator=(const attachDetach&);
117         //- Check validity of construction data
118         void checkDefinition();
120         // Topological changes
122             //- Attach interface
123             void attachInterface(polyTopoChange&) const;
125             //- Detach interface
126             void detachInterface(polyTopoChange&) const;
128             //- Calculate point match addressing
129             void calcPointMatchMap() const;
131             //- Return point match map
132             const Map<label>& pointMatchMap() const;
134             //- Clear addressing
135             void clearAddressing() const;
138     // Static data members
140         //- Relative vertex position tolerance
141         static const scalar positionDifference_;
144 public:
146     //- Runtime type information
147     TypeName("attachDetach");
150     // Constructors
152         //- Construct from components
153         attachDetach
154         (
155             const word& name,
156             const label index,
157             const polyTopoChanger& mme,
158             const word& faceZoneName,
159             const word& masterPatchName,
160             const word& slavePatchName,
161             const scalarField& triggerTimes,
162             const bool manualTrigger = false
163         );
165         //- Construct from dictionary
166         attachDetach
167         (
168             const word& name,
169             const dictionary& dict,
170             const label index,
171             const polyTopoChanger& mesh
172         );
175     // Destructor
177         virtual ~attachDetach();
180     // Member Functions
182         //- Return master patch ID
183         const polyPatchID& masterPatchID() const
184         {
185             return masterPatchID_;
186         }
188         //- Return slave patch ID
189         const polyPatchID& slavePatchID() const
190         {
191             return slavePatchID_;
192         }
194         //- Is the interface attached?
195         bool attached() const
196         {
197             return state_ == ATTACHED;
198         }
200         const Switch& manualTrigger() const
201         {
202             return manualTrigger_;
203         }
205         // Manually set attach.  Use only with manual trigger
206         bool setAttach() const;
208         // Manually set detach.  Use only with manual trigger
209         bool setDetach() const;
211         //- Check for topology change
212         virtual bool changeTopology() const;
214         //- Insert the layer addition/removal instructions
215         //  into the topological change
216         virtual void setRefinement(polyTopoChange&) const;
218         //- Modify motion points to comply with the topological change
219         virtual void modifyMotionPoints(pointField& motionPoints) const;
221         //- Force recalculation of locally stored data on topological change
222         virtual void updateMesh(const mapPolyMesh&);
224         //- Get reference to trigger times
225         const scalarField& triggerTimes() const
226         {
227             return triggerTimes_;
228         }
231         //- Write
232         virtual void write(Ostream&) const;
234         //- Write dictionary
235         virtual void writeDict(Ostream&) const;
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 } // End namespace Foam
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 #endif
247 // ************************************************************************* //