parallelFvGeometryScheme.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) 2022 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::parallelFvGeometryScheme
28 
29 Description
30  Geometry calculation scheme with explicit sync of face-geometry
31  across processor patches.
32 
33  - applies face centre and normal (negated) to the neighbour side
34  of a processor boundary.
35  - recalculates the resulting cell volumes.
36  - mainly interesting in single-precision in that it removes the
37  different truncation error from circulating in different order. This
38  can cause problems when calculating global transformations.
39  - it does change the face normal/centre so might affect the
40  cell-closedness of the attached cells.
41 
42 Usage
43  In system/fvSchemes add a geometry scheme:
44  \verbatim
45  geometry
46  {
47  type parallel;
48 
49  // Optional underlying geometry scheme. (default is basic)
50  geometry
51  {
52  type solidBody;
53  }
54  }
55  \endverbatim
56 
57  The default behaviour will print the total number of adjusted face and
58  cell properties:
59  \verbatim
60  parallelFvGeometryScheme::movePoints() :
61  adjusted geometry of faces:113 of cells:54
62  \endverbatim
63  In addition a warning will be printed if an internal face gives a different
64  result.
65 
66 SourceFiles
67  parallelFvGeometryScheme.C
68 
69 \*---------------------------------------------------------------------------*/
70 
71 #ifndef Foam_parallelFvGeometryScheme_H
72 #define Foam_parallelFvGeometryScheme_H
73 
74 #include "basicFvGeometryScheme.H"
75 #include "coupledPolyPatch.H"
76 
77 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
78 
79 namespace Foam
80 {
81 
82 /*---------------------------------------------------------------------------*\
83  Class parallelFvGeometryScheme Declaration
84 \*---------------------------------------------------------------------------*/
85 
87 :
88  public fvGeometryScheme
89 {
90 protected:
91 
92  // Protected Data
93 
94  //- Dictionary for underlying scheme
96 
97  //- Demand-driven construction of underlying scheme
99 
100 
101 private:
102 
103  // Private Member Functions
104 
105  //- Swap processor-face geometry
106  void adjustGeometry
107  (
108  pointField& faceCentres,
109  vectorField& faceAreas
110  ) const;
111 
112  //- Swap processor-face geometry
113  void adjustGeometry();
114 
115  //- No copy construct
117 
118  //- No copy assignment
119  void operator=(const parallelFvGeometryScheme&) = delete;
120 
121 
122 public:
123 
124  // Public classes
125 
126  //- Transformation for oriented fields
127  class transformOriented
128  {
129  public:
130 
131  template<class Type>
132  void operator()(const coupledPolyPatch& cpp, UList<Type>& fld) const
133  {
134  if (cpp.parallel())
135  {
136  for (auto& f : fld)
137  {
138  f = -f;
139  }
140  }
141  else
142  {
143  transformList(-cpp.forwardT(), fld);
144  }
145  }
146  };
147 
148 
149 public:
150 
151  //- Runtime type information
152  TypeName("parallel");
153 
154 
155  // Constructors
156 
157  //- Construct from mesh
158  parallelFvGeometryScheme
159  (
160  const fvMesh& mesh,
161  const dictionary& dict
162  );
163 
164 
165  //- Destructor
166  virtual ~parallelFvGeometryScheme() = default;
167 
168 
169  // Member Functions
170 
171  //- Construct underlying fvGeometryScheme
172  const fvGeometryScheme& geometry() const;
173 
174  //- Do what is necessary if the mesh has moved
175  virtual void movePoints();
176 
177  //- Update mesh for topology changes
178  virtual void updateMesh(const mapPolyMesh& mpm);
179 
180  //- Return linear difference weighting factors
181  virtual tmp<surfaceScalarField> weights() const;
182 
183  //- Return cell-centre difference coefficients
184  virtual tmp<surfaceScalarField> deltaCoeffs() const;
185 
186  //- Return non-orthogonal cell-centre difference coefficients
187  virtual tmp<surfaceScalarField> nonOrthDeltaCoeffs() const;
188 
189  //- Return non-orthogonality correction vectors
190  virtual tmp<surfaceVectorField> nonOrthCorrectionVectors() const;
191 
192  //- Calculate geometry quantities using mesh topology and provided
193  //- points. If oldPoints provided only does local update. Returns
194  //- true if anything changed, false otherwise
195  virtual bool updateGeom
196  (
197  const pointField& points,
198  const refPtr<pointField>& oldPoints, // optional old points
199  pointField& faceCentres,
200  vectorField& faceAreas,
201  pointField& cellCentres,
202  scalarField& cellVolumes
203  ) const;
204 };
205 
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 } // End namespace Foam
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 #endif
214 
215 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
tmp< fvGeometryScheme > geometryPtr_
Demand-driven construction of underlying scheme.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
virtual const tensorField & forwardT() const
Return face transformation tensor.
Geometry calculation scheme with explicit sync of face-geometry across processor patches.
virtual bool parallel() const
Are the cyclic planes parallel.
void operator()(const coupledPolyPatch &cpp, UList< Type > &fld) const
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
virtual tmp< surfaceVectorField > nonOrthCorrectionVectors() const
Return non-orthogonality correction vectors.
const pointField & points
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual bool updateGeom(const pointField &points, const refPtr< pointField > &oldPoints, pointField &faceCentres, vectorField &faceAreas, pointField &cellCentres, scalarField &cellVolumes) const
Calculate geometry quantities using mesh topology and provided points. If oldPoints provided only doe...
virtual tmp< surfaceScalarField > weights() const
Return linear difference weighting factors.
virtual tmp< surfaceScalarField > deltaCoeffs() const
Return cell-centre difference coefficients.
const fvMesh & mesh() const
Return mesh reference.
labelList f(nPoints)
virtual void movePoints()
Do what is necessary if the mesh has moved.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
dictionary dict_
Dictionary for underlying scheme.
void transformList(const tensor &rotTensor, UList< T > &field)
Inplace transform a list of elements.
Definition: transformList.C:48
virtual void updateMesh(const mapPolyMesh &mpm)
Update mesh for topology changes.
Field< vector > vectorField
Specialisation of Field<T> for vector.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
virtual tmp< surfaceScalarField > nonOrthDeltaCoeffs() const
Return non-orthogonal cell-centre difference coefficients.
virtual ~parallelFvGeometryScheme()=default
Destructor.
TypeName("parallel")
Runtime type information.
Abstract base class for geometry calculation schemes.
const fvGeometryScheme & geometry() const
Construct underlying fvGeometryScheme.
Namespace for OpenFOAM.