meshToMesh_fvMeshTopoChanger.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2022-2025 OpenFOAM Foundation
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::fvMeshTopoChangers::meshToMesh
26 
27 Description
28  fvMeshTopoChanger which maps the fields to a new mesh or sequence of meshes
29 
30  which can optionally be mapped to repeatedly for example in multi-cycle
31  engine cases or cycled through for symmetric forward and reverse motion.
32 
33 Usage
34  \table
35  Property | Description | Required | Default value
36  libs | Libraries to load | no |
37  times | List of times for the meshes | yes |
38  repeat | Repetition period | no |
39  cycle | Cycle period | no |
40  begin | Begin time for the meshes | no | Time::beginTime()
41  timeDelta | Time tolerance used for time -> index | yes |
42  \endtable
43 
44  Examples of the mesh-to-mesh mapping for the multi-cycle
45  tutorials/incompressibleFluid/movingCone case:
46  \verbatim
47  topoChanger
48  {
49  type meshToMesh;
50 
51  libs ("libmeshToMeshTopoChanger.so");
52 
53  times (0.0015 0.003);
54 
55  cycle #calc "1.0/300.0";
56  begin 0;
57 
58  timeDelta 1e-6;
59  }
60  \endverbatim
61 
62 SourceFiles
63  meshToMesh_fvMeshTopoChanger.C
64 
65 \*---------------------------------------------------------------------------*/
66 
67 #ifndef meshToMesh_fvMeshTopoChanger_H
68 #define meshToMesh_fvMeshTopoChanger_H
69 
70 #include "fvMeshTopoChanger.H"
71 
72 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
73 
74 namespace Foam
75 {
76 namespace fvMeshTopoChangers
77 {
78 
79 /*---------------------------------------------------------------------------*\
80  Class fvMeshTopoChangers::meshToMesh Declaration
81 \*---------------------------------------------------------------------------*/
82 
83 class meshToMesh
84 :
85  public fvMeshTopoChanger
86 {
87  // Private Data
88 
89  //- List of mesh mapping times
90  scalarList times_;
91 
92  //- Time delta used for time -> index
93  scalar timeDelta_;
94 
95  //- Hash set of mesh mapping time indices
96  HashSet<int64_t, Hash<int64_t>> timeIndices_;
97 
98  //- Optional begin time for the meshes
99  // Defaults to Time::beginTime
100  scalar begin_;
101 
102  //- Optional repetition period
103  // Defaults to no repetition
104  scalar repeat_;
105 
106  //- Optional cycle period
107  scalar cycle_;
108 
109  //- The time index used for updating
110  label timeIndex_;
111 
112  //- Flag set true if the mesh has been mapped this time-step,
113  // otherwise false
114  bool mapped_;
115 
116 
117  // Private Member Functions
118 
119  //- Return true if the set of meshes are being traversed in the forward
120  // sequence or false if cycling is currently traversing the meshes in
121  // reverse order
122  bool forward() const;
123 
124  //- Return the user time mapped to the mesh sequence
125  // handling the repeat or cycle option
126  scalar meshTime() const;
127 
128  //- Interpolate U's to Uf's
129  void interpolateUfs();
130 
131 
132 public:
133 
134  //- Runtime type information
135  TypeName("meshToMesh");
136 
137 
138  // Constructors
139 
140  //- Construct from fvMesh and dictionary
141  meshToMesh(fvMesh&, const dictionary& dict);
142 
143  //- Disallow default bitwise copy construction
144  meshToMesh(const meshToMesh&) = delete;
145 
146 
147  //- Destructor
148  virtual ~meshToMesh();
149 
150 
151  // Member Functions
152 
153  scalar timeToNextMesh() const;
154 
155  //- Return true if the mesh has been mapped this time-step,
156  // otherwise false
157  bool mapped() const;
158 
159  //- Update the mesh for both mesh motion and topology change
160  virtual bool update();
161 
162  //- Update corresponding to the given map
163  virtual void topoChange(const polyTopoChangeMap&);
164 
165  //- Update from another mesh using the given map
166  virtual void mapMesh(const polyMeshMap&);
167 
168  //- Update corresponding to the given distribution map
169  virtual void distribute(const polyDistributionMap&);
170 
171 
172  // Member Operators
173 
174  //- Disallow default bitwise assignment
175  void operator=(const meshToMesh&) = delete;
176 };
177 
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 } // End namespace fvMeshTopoChangers
182 } // End namespace Foam
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 #endif
187 
188 // ************************************************************************* //
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
fvMeshTopoChanger which maps the fields to a new mesh or sequence of meshes
virtual void topoChange(const polyTopoChangeMap &)
Update corresponding to the given map.
virtual void distribute(const polyDistributionMap &)
Update corresponding to the given distribution map.
bool mapped() const
Return true if the mesh has been mapped this time-step,.
TypeName("meshToMesh")
Runtime type information.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
virtual bool update()
Update the mesh for both mesh motion and topology change.
void operator=(const meshToMesh &)=delete
Disallow default bitwise assignment.
meshToMesh(fvMesh &, const dictionary &dict)
Construct from fvMesh and dictionary.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:96
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
List< scalar > scalarList
A List of scalars.
Definition: scalarList.H:50
dictionary dict