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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::attachDetach
29 
30 Description
31  Attach/detach boundary mesh modifier. This modifier takes a set of
32  internal faces and converts them into boundary faces and vice versa
33  based on the given activation switch.
34 
35  The patch is oriented using the flip map in the face zone. The
36  oriented faces are put into the master patch and their mirror
37  images into the slave.
38 
39 SourceFiles
40  attachDetach.C
41  attachInterface.C
42  detachInterface.C
43  attachDetachPointMatchMap.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef attachDetach_H
48 #define attachDetach_H
49 
50 #include "polyMeshModifier.H"
51 #include "polyPatchID.H"
52 #include "ZoneIDs.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 
59 /*---------------------------------------------------------------------------*\
60  Class attachDetach Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 class attachDetach
64 :
65  public polyMeshModifier
66 {
67  // Data Types
68 
69  //- State of the modifier
70  enum modifierState
71  {
72  UNKNOWN,
73  ATTACHED,
74  DETACHED
75  };
76 
77 
78  // Private Data
79 
80  //- Master face zone ID
81  faceZoneID faceZoneID_;
82 
83  //- Master patch ID. Holds faces with original orientation
84  polyPatchID masterPatchID_;
85 
86  //- Slave patch ID. Holds mirrored faces
87  polyPatchID slavePatchID_;
88 
89  //- List of trigger times
90  scalarField triggerTimes_;
91 
92  //- Trigger time index
93  mutable label triggerIndex_;
94 
95  //- State of the modifier
96  mutable modifierState state_;
97 
98  //- Use manual trigger
99  bool manualTrigger_;
100 
101  //- Attach/detach trigger
102  mutable bool trigger_;
103 
104 
105  // Private addressing data. Created on topology change
106 
107  //- Map of matching points
108  mutable unique_ptr<Map<label>> pointMatchMapPtr_;
109 
110 
111  // Private Member Functions
112 
113  //- No copy construct
114  attachDetach(const attachDetach&) = delete;
115 
116  //- No copy assignment
117  void operator=(const attachDetach&) = delete;
118 
119  //- Check validity of construction data
120  void checkDefinition();
121 
122  // Topological changes
123 
124  //- Attach interface
125  void attachInterface(polyTopoChange&) const;
126 
127  //- Detach interface
128  void detachInterface(polyTopoChange&) const;
129 
130  //- Calculate point match addressing
131  void calcPointMatchMap() const;
132 
133  //- Return point match map
134  const Map<label>& pointMatchMap() const;
135 
136  //- Clear addressing
137  void clearAddressing() const;
138 
139 
140  // Static data members
141 
142  //- Relative vertex position tolerance
143  static const scalar positionDifference_;
144 
145 
146 public:
147 
148  //- Runtime type information
149  TypeName("attachDetach");
150 
151 
152  // Constructors
153 
154  //- Construct from components
156  (
157  const word& name,
158  const label index,
159  const polyTopoChanger& mme,
160  const word& faceZoneName,
161  const word& masterPatchName,
162  const word& slavePatchName,
163  const scalarField& triggerTimes,
164  const bool manualTrigger = false
165  );
166 
167  //- Construct from dictionary
169  (
170  const word& name,
171  const dictionary& dict,
172  const label index,
173  const polyTopoChanger& mesh
174  );
175 
176 
177  //- Destructor
178  virtual ~attachDetach() = default;
179 
180 
181  // Member Functions
182 
183  //- Return master patch ID
184  const polyPatchID& masterPatchID() const
185  {
186  return masterPatchID_;
187  }
188 
189  //- Return slave patch ID
190  const polyPatchID& slavePatchID() const
191  {
192  return slavePatchID_;
193  }
194 
195  //- Is the interface attached?
196  bool attached() const
197  {
198  return state_ == ATTACHED;
199  }
200 
201  //- Is manually triggered?
202  bool manualTrigger() const
203  {
204  return manualTrigger_;
205  }
206 
207  // Manually set attach. Use only with manual trigger
208  bool setAttach() const;
209 
210  // Manually set detach. Use only with manual trigger
211  bool setDetach() const;
212 
213  //- Check for topology change
214  virtual bool changeTopology() const;
215 
216  //- Insert the layer addition/removal instructions
217  // into the topological change
218  virtual void setRefinement(polyTopoChange&) const;
219 
220  //- Modify motion points to comply with the topological change
221  virtual void modifyMotionPoints(pointField& motionPoints) const;
222 
223  //- Force recalculation of locally stored data on topological change
224  virtual void updateMesh(const mapPolyMesh&);
225 
226  //- Get reference to trigger times
227  const scalarField& triggerTimes() const
228  {
229  return triggerTimes_;
230  }
231 
232 
233  //- Write
234  virtual void write(Ostream&) const;
235 
236  //- Write dictionary
237  virtual void writeDict(Ostream&) const;
238 };
239 
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 } // End namespace Foam
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #endif
248 
249 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::attachDetach::changeTopology
virtual bool changeTopology() const
Check for topology change.
Definition: attachDetach.C:310
Foam::attachDetach::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
Definition: attachDetach.C:413
Foam::attachDetach::modifyMotionPoints
virtual void modifyMotionPoints(pointField &motionPoints) const
Modify motion points to comply with the topological change.
Definition: attachInterface.C:277
Foam::attachDetach::TypeName
TypeName("attachDetach")
Runtime type information.
Foam::attachDetach::writeDict
virtual void writeDict(Ostream &) const
Write dictionary.
Definition: attachDetach.C:437
Foam::polyTopoChanger
List of mesh modifiers defining the mesh dynamics.
Definition: polyTopoChanger.H:62
Foam::polyTopoChange
Direct mesh changes based on v1.3 polyTopoChange syntax.
Definition: polyTopoChange.H:99
Foam::Map< label >
Foam::polyMeshModifier::index
label index() const
Return the index of this modifier.
Definition: polyMeshModifier.H:156
ZoneIDs.H
Foam::DynamicID< faceZoneMesh >
Foam::attachDetach::write
virtual void write(Ostream &) const
Write.
Definition: attachDetach.C:426
polyPatchID.H
Foam::attachDetach
Attach/detach boundary mesh modifier. This modifier takes a set of internal faces and converts them i...
Definition: attachDetach.H:62
Foam::Field< scalar >
Foam::attachDetach::setDetach
bool setDetach() const
Definition: attachDetach.C:302
Foam::attachDetach::masterPatchID
const polyPatchID & masterPatchID() const
Return master patch ID.
Definition: attachDetach.H:183
Foam::attachDetach::setAttach
bool setAttach() const
Definition: attachDetach.C:294
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::polyMeshModifier
Virtual base class for mesh modifiers.
Definition: polyMeshModifier.H:68
Foam::attachDetach::slavePatchID
const polyPatchID & slavePatchID() const
Return slave patch ID.
Definition: attachDetach.H:189
Foam::polyMeshModifier::name
const word & name() const
Return name of this modifier.
Definition: polyMeshModifier.H:150
Foam::attachDetach::~attachDetach
virtual ~attachDetach()=default
Destructor.
Foam::attachDetach::triggerTimes
const scalarField & triggerTimes() const
Get reference to trigger times.
Definition: attachDetach.H:226
Foam::attachDetach::manualTrigger
bool manualTrigger() const
Is manually triggered?
Definition: attachDetach.H:201
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::attachDetach::attached
bool attached() const
Is the interface attached?
Definition: attachDetach.H:195
Foam::attachDetach::setRefinement
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
Definition: attachDetach.C:378
polyMeshModifier.H