FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

attachDetach.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::attachDetach
00026 
00027 Description
00028     Attach/detach boundary mesh modifier.  This modifier takes a set of
00029     internal faces and converts them into boundary faces and vice versa
00030     based on the given activation switch.
00031 
00032     The patch is oriented using the flip map in the face zone.  The
00033     oriented faces are put into the master patch and their mirror
00034     images into the slave.
00035 
00036 SourceFiles
00037     attachDetach.C
00038     attachInterface.C
00039     detachInterface.C
00040     attachDetachPointMatchMap.C
00041 
00042 \*---------------------------------------------------------------------------*/
00043 
00044 #ifndef attachDetach_H
00045 #define attachDetach_H
00046 
00047 #include <dynamicMesh/polyMeshModifier.H>
00048 #include <OpenFOAM/polyPatchID.H>
00049 #include <OpenFOAM/ZoneIDs.H>
00050 
00051 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00052 
00053 namespace Foam
00054 {
00055 
00056 /*---------------------------------------------------------------------------*\
00057                        Class attachDetach Declaration
00058 \*---------------------------------------------------------------------------*/
00059 
00060 class attachDetach
00061 :
00062     public polyMeshModifier
00063 {
00064     // Data types
00065 
00066         //- State of the modifier
00067         enum modifierState
00068         {
00069             UNKNOWN,
00070             ATTACHED,
00071             DETACHED
00072         };
00073 
00074 
00075     // Private data
00076 
00077         //- Master face zone ID
00078         faceZoneID faceZoneID_;
00079 
00080         //- Master patch ID.  Holds faces with original orientation
00081         polyPatchID masterPatchID_;
00082 
00083         //- Slave patch ID.  Holds mirrored faces
00084         polyPatchID slavePatchID_;
00085 
00086         //- List of trigger times
00087         scalarField triggerTimes_;
00088 
00089         //- Use manual trigger
00090         Switch manualTrigger_;
00091 
00092         //- Trigger time index
00093         mutable label triggerIndex_;
00094 
00095         //- State of the modifier
00096         mutable modifierState state_;
00097 
00098         //- Attach/detach trigger
00099         mutable bool trigger_;
00100 
00101 
00102         // Private addressing data.  Created on topology change
00103 
00104             //- Map of matching points
00105             mutable Map<label>* pointMatchMapPtr_;
00106 
00107 
00108     // Private Member Functions
00109 
00110         //- Disallow default bitwise copy construct
00111         attachDetach(const attachDetach&);
00112 
00113         //- Disallow default bitwise assignment
00114         void operator=(const attachDetach&);
00115 
00116         //- Check validity of construction data
00117         void checkDefinition();
00118 
00119         // Topological changes
00120 
00121             //- Attach interface
00122             void attachInterface(polyTopoChange&) const;
00123 
00124             //- Detach interface
00125             void detachInterface(polyTopoChange&) const;
00126 
00127             //- Calculate point match addressing
00128             void calcPointMatchMap() const;
00129 
00130             //- Return point match map
00131             const Map<label>& pointMatchMap() const;
00132 
00133             //- Clear addressing
00134             void clearAddressing() const;
00135 
00136 
00137     // Static data members
00138 
00139         //- Relative vertex position tolerance
00140         static const scalar positionDifference_;
00141 
00142 
00143 public:
00144 
00145     //- Runtime type information
00146     TypeName("attachDetach");
00147 
00148 
00149     // Constructors
00150 
00151         //- Construct from components
00152         attachDetach
00153         (
00154             const word& name,
00155             const label index,
00156             const polyTopoChanger& mme,
00157             const word& faceZoneName,
00158             const word& masterPatchName,
00159             const word& slavePatchName,
00160             const scalarField& triggerTimes,
00161             const bool manualTrigger = false
00162         );
00163 
00164         //- Construct from dictionary
00165         attachDetach
00166         (
00167             const word& name,
00168             const dictionary& dict,
00169             const label index,
00170             const polyTopoChanger& mesh
00171         );
00172 
00173 
00174     // Destructor
00175 
00176         virtual ~attachDetach();
00177 
00178 
00179     // Member Functions
00180 
00181         //- Return master patch ID
00182         const polyPatchID& masterPatchID() const
00183         {
00184             return masterPatchID_;
00185         }
00186 
00187         //- Return slave patch ID
00188         const polyPatchID& slavePatchID() const
00189         {
00190             return slavePatchID_;
00191         }
00192 
00193         //- Is the interface attached?
00194         bool attached() const
00195         {
00196             return state_ == ATTACHED;
00197         }
00198 
00199         const Switch& manualTrigger() const
00200         {
00201             return manualTrigger_;
00202         }
00203 
00204         // Manually set attach.  Use only with manual trigger
00205         bool setAttach() const;
00206 
00207         // Manually set detach.  Use only with manual trigger
00208         bool setDetach() const;
00209 
00210         //- Check for topology change
00211         virtual bool changeTopology() const;
00212 
00213         //- Insert the layer addition/removal instructions
00214         //  into the topological change
00215         virtual void setRefinement(polyTopoChange&) const;
00216 
00217         //- Modify motion points to comply with the topological change
00218         virtual void modifyMotionPoints(pointField& motionPoints) const;
00219 
00220         //- Force recalculation of locally stored data on topological change
00221         virtual void updateMesh(const mapPolyMesh&);
00222 
00223         //- Get reference to trigger times
00224         const scalarField& triggerTimes() const
00225         {
00226             return triggerTimes_;
00227         }
00228 
00229 
00230         //- Write
00231         virtual void write(Ostream&) const;
00232 
00233         //- Write dictionary
00234         virtual void writeDict(Ostream&) const;
00235 };
00236 
00237 
00238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00239 
00240 } // End namespace Foam
00241 
00242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00243 
00244 #endif
00245 
00246 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines