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

slidingInterface.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::slidingInterface
00026 
00027 Description
00028     Sliding interface mesh modifier.  Given two face zones, couple the
00029     master and slave side using a cutting procedure.
00030 
00031     The coupled faces are collected into the "coupled" zone and can become
00032     either internal or placed into a master and slave coupled zone.  The
00033     remaining faces (uncovered master or slave) are placed into the master
00034     and slave patch.
00035 
00036     The definition of the sliding interface can be either integral or partial.
00037     Integral interface implies that the slave side completely covers
00038     the master (i.e. no faces are uncovered); partial interface
00039     implies that the uncovered part of master/slave face zone should
00040     become boundary faces.
00041 
00042 SourceFiles
00043     slidingInterface.C
00044     coupleSlidingInterface.C
00045     decoupleSlidingInterface.C
00046     slidingInterfaceProjectPoints.C
00047     slidingInterfaceAttachedAddressing.C
00048     slidingInterfaceClearCouple.C
00049 
00050 \*---------------------------------------------------------------------------*/
00051 
00052 #ifndef slidingInterface_H
00053 #define slidingInterface_H
00054 
00055 #include <dynamicMesh/polyMeshModifier.H>
00056 #include <OpenFOAM/primitiveFacePatch.H>
00057 #include <OpenFOAM/polyPatchID.H>
00058 #include <OpenFOAM/ZoneIDs.H>
00059 #include <OpenFOAM/intersection.H>
00060 #include <OpenFOAM/Pair.H>
00061 
00062 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00063 
00064 namespace Foam
00065 {
00066 
00067 // Forward declaration of classes
00068 class objectHit;
00069 
00070 /*---------------------------------------------------------------------------*\
00071                       Class slidingInterface Declaration
00072 \*---------------------------------------------------------------------------*/
00073 
00074 class slidingInterface
00075 :
00076     public polyMeshModifier
00077 {
00078 public:
00079 
00080     // Public enumerations
00081 
00082         //- Type of match
00083         enum typeOfMatch
00084         {
00085             INTEGRAL,
00086             PARTIAL
00087         };
00088 
00089         //- Direction names
00090         static const NamedEnum<typeOfMatch, 2> typeOfMatchNames_;
00091 
00092 private:
00093 
00094     // Private data
00095 
00096         //- Master face zone ID
00097         faceZoneID masterFaceZoneID_;
00098 
00099         //- Slave face zone ID
00100         faceZoneID slaveFaceZoneID_;
00101 
00102         //- Cut point zone ID
00103         pointZoneID cutPointZoneID_;
00104 
00105         //- Cut face zone ID
00106         faceZoneID cutFaceZoneID_;
00107 
00108         //- Master patch ID
00109         polyPatchID masterPatchID_;
00110 
00111         //- Slave patch ID
00112         polyPatchID slavePatchID_;
00113 
00114         //- Type of match
00115         const typeOfMatch matchType_;
00116 
00117         //- Couple-decouple operation.
00118         //  If the interface is coupled, decouple it and vice versa.
00119         //  Used in conjuction with automatic mesh motion
00120         mutable Switch coupleDecouple_;
00121 
00122         //- State of the modifier
00123         mutable Switch attached_;
00124 
00125         //- Point projection algorithm
00126         intersection::algorithm projectionAlgo_;
00127 
00128         //- Trigger topological change
00129         mutable bool trigger_;
00130 
00131         // Tolerances. Initialised to static ones below.
00132 
00133             //- Point merge tolerance
00134             scalar pointMergeTol_;
00135 
00136             //- Edge merge tolerance
00137             scalar edgeMergeTol_;
00138 
00139             //- Estimated number of faces an edge goes through
00140             label nFacesPerSlaveEdge_;
00141 
00142             //- Edge-face interaction escape limit
00143             label edgeFaceEscapeLimit_;
00144 
00145             //- Integral match point adjustment tolerance
00146             scalar integralAdjTol_;
00147 
00148             //- Edge intersection master catch fraction
00149             scalar edgeMasterCatchFraction_;
00150 
00151             //- Edge intersection co-planar tolerance
00152             scalar edgeCoPlanarTol_;
00153 
00154             //- Edge end cut-off tolerance
00155             scalar edgeEndCutoffTol_;
00156 
00157 
00158         // Private addressing data.
00159 
00160             //- Cut face master face.  Gives the index of face in master patch
00161             //  the cut face has been created from.  For a slave-only face
00162             //  this will be -1
00163             mutable labelList* cutFaceMasterPtr_;
00164 
00165             //- Cut face slave face.  Gives the index of face in slave patch
00166             //  the cut face has been created from.  For a master-only face
00167             //  this will be -1
00168             mutable labelList* cutFaceSlavePtr_;
00169 
00170             //- Master zone faceCells
00171             mutable labelList* masterFaceCellsPtr_;
00172 
00173             //- Slave zone faceCells
00174             mutable labelList* slaveFaceCellsPtr_;
00175 
00176             //- Master stick-out faces
00177             mutable labelList* masterStickOutFacesPtr_;
00178 
00179             //- Slave stick-out faces
00180             mutable labelList* slaveStickOutFacesPtr_;
00181 
00182             //- Retired point mapping.
00183             //  For every retired slave side point, gives the label of the
00184             //  master point that replaces it
00185             mutable Map<label>* retiredPointMapPtr_;
00186 
00187             //- Cut edge pairs
00188             //  For cut points created by intersection two edges,
00189             //  store the master-slave edge pair used in creation
00190             mutable Map<Pair<edge> >* cutPointEdgePairMapPtr_;
00191 
00192             //- Slave point hit.  The index of master point hit by the
00193             //  slave point in projection.  For no point hit, set to -1
00194             mutable labelList* slavePointPointHitsPtr_;
00195 
00196             //- Slave edge hit.  The index of master edge hit by the
00197             //  slave point in projection.  For point or no edge  hit, set to -1
00198             mutable labelList* slavePointEdgeHitsPtr_;
00199 
00200             //- Slave face hit.  The index of master face hit by the
00201             //  slave point in projection.
00202             mutable List<objectHit>* slavePointFaceHitsPtr_;
00203 
00204             //- Master point edge hit.  The index of slave edge hit by
00205             //  a master point.  For no hit set to -1
00206             mutable labelList* masterPointEdgeHitsPtr_;
00207 
00208             //- Projected slave points
00209             mutable pointField* projectedSlavePointsPtr_;
00210 
00211 
00212     // Private Member Functions
00213 
00214         //- Disallow default bitwise copy construct
00215         slidingInterface(const slidingInterface&);
00216 
00217         //- Disallow default bitwise assignment
00218         void operator=(const slidingInterface&);
00219 
00220         //- Clear out
00221         void clearOut() const;
00222 
00223 
00224         //- Check validity of construction data
00225         void checkDefinition();
00226 
00227         //- Calculate attached addressing
00228         void calcAttachedAddressing() const;
00229 
00230         //- Calculate decoupled zone face-cell addressing
00231         void renumberAttachedAddressing(const mapPolyMesh&) const;
00232 
00233         //- Clear attached addressing
00234         void clearAttachedAddressing() const;
00235 
00236 
00237         // Topological changes
00238 
00239             //- Master faceCells
00240             const labelList& masterFaceCells() const;
00241 
00242             //- Slave faceCells
00243             const labelList& slaveFaceCells() const;
00244 
00245             //- Master stick-out faces
00246             const labelList& masterStickOutFaces() const;
00247 
00248             //- Slave stick-out faces
00249             const labelList& slaveStickOutFaces() const;
00250 
00251             //- Retired point map
00252             const Map<label>& retiredPointMap() const;
00253 
00254             //- Cut point edge pair map
00255             const Map<Pair<edge> >& cutPointEdgePairMap() const;
00256 
00257              //- Clear addressing
00258              void clearAddressing() const;
00259 
00260             //- Project slave points and compare with the current projection.
00261             //  If the projection has changed, the sliding interface
00262             //  changes topologically
00263             bool projectPoints() const;
00264 
00265             //- Couple sliding interface
00266             void coupleInterface(polyTopoChange& ref) const;
00267 
00268             //- Clear projection
00269             void clearPointProjection() const;
00270 
00271             //- Clear old couple
00272             void clearCouple(polyTopoChange& ref) const;
00273 
00274             //- Decouple interface (returns it to decoupled state)
00275             //  Note: this should not be used in normal operation of the
00276             //  sliding mesh, but only to return the mesh to its
00277             //  original state
00278             void decoupleInterface(polyTopoChange& ref) const;
00279 
00280 
00281     // Static data members
00282 
00283         //- Point merge tolerance
00284         static const scalar pointMergeTolDefault_;
00285 
00286         //- Edge merge tolerance
00287         static const scalar edgeMergeTolDefault_;
00288 
00289         //- Estimated number of faces an edge goes through
00290         static const label nFacesPerSlaveEdgeDefault_;
00291 
00292         //- Edge-face interaction escape limit
00293         static const label edgeFaceEscapeLimitDefault_;
00294 
00295         //- Integral match point adjustment tolerance
00296         static const scalar integralAdjTolDefault_;
00297 
00298         //- Edge intersection master catch fraction
00299         static const scalar edgeMasterCatchFractionDefault_;
00300 
00301         //- Edge intersection co-planar tolerance
00302         static const scalar edgeCoPlanarTolDefault_;
00303 
00304         //- Edge end cut-off tolerance
00305         static const scalar edgeEndCutoffTolDefault_;
00306 
00307 
00308 public:
00309 
00310     //- Runtime type information
00311     TypeName("slidingInterface");
00312 
00313 
00314     // Constructors
00315 
00316         //- Construct from components
00317         slidingInterface
00318         (
00319             const word& name,
00320             const label index,
00321             const polyTopoChanger& mme,
00322             const word& masterFaceZoneName,
00323             const word& slaveFaceZoneName,
00324             const word& cutPointZoneName,
00325             const word& cutFaceZoneName,
00326             const word& masterPatchName,
00327             const word& slavePatchName,
00328             const typeOfMatch tom,
00329             const bool coupleDecouple = false,
00330             const intersection::algorithm algo = intersection::VISIBLE
00331         );
00332 
00333         //- Construct from dictionary
00334         slidingInterface
00335         (
00336             const word& name,
00337             const dictionary& dict,
00338             const label index,
00339             const polyTopoChanger& mme
00340         );
00341 
00342 
00343     // Destructor
00344 
00345         virtual ~slidingInterface();
00346 
00347 
00348     // Member Functions
00349 
00350         //- Return master face zone ID
00351         const faceZoneID& masterFaceZoneID() const;
00352 
00353         //- Return slave face zone ID
00354         const faceZoneID& slaveFaceZoneID() const;
00355 
00356         //- Return true if attached
00357         bool attached() const
00358         {
00359             return attached_;
00360         }
00361 
00362         //- Check for topology change
00363         virtual bool changeTopology() const;
00364 
00365         //- Insert the layer addition/removal instructions
00366         //  into the topological change
00367         virtual void setRefinement(polyTopoChange&) const;
00368 
00369         //- Modify motion points to comply with the topological change
00370         virtual void modifyMotionPoints(pointField& motionPoints) const;
00371 
00372         //- Force recalculation of locally stored data on topological change
00373         virtual void updateMesh(const mapPolyMesh&);
00374 
00375         //- Return projected points for a slave patch
00376         const pointField& pointProjection() const;
00377 
00378         //- Set the tolerances from the values in a dictionary
00379         void setTolerances(const dictionary&, bool report=false);
00380 
00381         //- Write
00382         virtual void write(Ostream&) const;
00383 
00384         //- Write dictionary
00385         virtual void writeDict(Ostream&) const;
00386 };
00387 
00388 
00389 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00390 
00391 } // End namespace Foam
00392 
00393 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00394 
00395 #endif
00396 
00397 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines