twoDPointCorrector.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-2015 OpenFOAM Foundation
9  Copyright (C) 2024 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::twoDPointCorrector
29 
30 Description
31  Class applies a two-dimensional correction to mesh motion point field.
32 
33  The correction guarantees that the mesh does not get twisted during motion
34  and thus introduce a third dimension into a 2-D problem.
35 
36  The operation is performed by looping through all edges approximately
37  normal to the plane and enforcing their orthogonality onto the plane by
38  adjusting points on their ends.
39 
40 SourceFiles
41  twoDPointCorrector.C
42 
43 \*---------------------------------------------------------------------------*/
44 
45 #ifndef Foam_twoDPointCorrector_H
46 #define Foam_twoDPointCorrector_H
47 
48 #include "MeshObject.H"
49 #include "pointField.H"
50 #include "labelList.H"
51 #include "vector.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 // Forward Declarations
59 class polyMesh;
60 
61 /*---------------------------------------------------------------------------*\
62  Class twoDPointCorrector Declaration
63 \*---------------------------------------------------------------------------*/
64 
66 :
67  public MeshObject<polyMesh, UpdateableMeshObject, twoDPointCorrector>
68 {
69  // Private Typedefs
70 
71  typedef MeshObject
72  <
73  polyMesh,
77 
78 
79  // Private Data
80 
81  //- Is 2D correction required, i.e. is the mesh
82  bool required_;
83 
84  //- Flag to indicate a wedge geometry
85  mutable bool isWedge_;
86 
87  //- 2-D plane unit normal
88  mutable std::unique_ptr<vector> planeNormalPtr_;
89 
90  //- Indices of edges normal to plane
91  mutable std::unique_ptr<labelList> normalEdgeIndicesPtr_;
92 
93  //- Wedge axis (if wedge geometry)
94  mutable vector wedgeAxis_;
95 
96  //- Wedge angle (if wedge geometry)
97  mutable scalar wedgeAngle_;
98 
99 
100  // Private Member Functions
101 
102  //- No copy construct
103  twoDPointCorrector(const twoDPointCorrector&) = delete;
104 
105  //- No copy assignment
106  void operator=(const twoDPointCorrector&) = delete;
107 
108 
109  //- Calculate addressing
110  void calcAddressing() const;
111 
112  //- Clear addressing
113  void clearAddressing() const;
114 
115  //- Snap a point to the wedge patch(es)
116  void snapToWedge(const vector& n, const point& A, point& p) const;
117 
118 
119  // Static data members
120 
121  //- Edge orthogonality tolerance
122  static const scalar edgeOrthogonalityTol;
123 
124 
125 public:
126 
127  // Declare name of the class and its debug switch
128  ClassName("twoDPointCorrector");
129 
130 
131  // Constructors
132 
133  //- Construct from components
135 
136 
137  //- Destructor
139 
140 
141  // Member Functions
142 
143  //- Is 2D correction required, i.e. is the mesh a wedge or slab
144  bool required() const
145  {
146  return required_;
147  }
148 
149  //- Return plane normal
150  const vector& planeNormal() const;
151 
152  //- Return indices of normal edges.
153  const labelList& normalEdgeIndices() const;
154 
155  //- Return direction normal to plane
156  direction normalDir() const;
157 
158  //- Correct motion points
159  void correctPoints(pointField& p) const;
160 
161  //- Correct motion displacements
162  void correctDisplacement(const pointField& p, vectorField& disp) const;
163 
164  //- Update topology
165  void updateMesh(const mapPolyMesh&);
166 
167  //- Correct weighting factors for moving mesh.
168  bool movePoints();
169 };
170 
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 } // End namespace Foam
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 #endif
179 
180 // ************************************************************************* //
void updateMesh(const mapPolyMesh &)
Update topology.
uint8_t direction
Definition: direction.H:46
const labelList & normalEdgeIndices() const
Return indices of normal edges.
ClassName("twoDPointCorrector")
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
void correctPoints(pointField &p) const
Correct motion points.
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:152
void correctDisplacement(const pointField &p, vectorField &disp) const
Correct motion displacements.
bool required() const
Is 2D correction required, i.e. is the mesh a wedge or slab.
Class applies a two-dimensional correction to mesh motion point field.
const polyMesh & mesh() const noexcept
Reference to the mesh.
Definition: MeshObject.H:257
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
const vector & planeNormal() const
Return plane normal.
bool movePoints()
Correct weighting factors for moving mesh.
direction normalDir() const
Return direction normal to plane.
label n
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
volScalarField & p
static const Foam::dimensionedScalar A("", Foam::dimPressure, 611.21)
Namespace for OpenFOAM.
UpdateableMeshObject(const word &objName, const objectRegistry &obr)
Construct from name and instance on registry.
Definition: MeshObject.H:354