Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::parallelFvGeometryScheme
28
29Description
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
42Usage
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
66SourceFiles
67 parallelFvGeometryScheme.C
68
69\*---------------------------------------------------------------------------*/
70
71#ifndef Foam_parallelFvGeometryScheme_H
72#define Foam_parallelFvGeometryScheme_H
73
75#include "coupledPolyPatch.H"
76
77// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
78
79namespace Foam
80{
82/*---------------------------------------------------------------------------*\
83 Class parallelFvGeometryScheme Declaration
84\*---------------------------------------------------------------------------*/
85
86class parallelFvGeometryScheme
87:
88 public fvGeometryScheme
89{
90protected:
91
92 // Protected Data
93
94 //- Dictionary for underlying scheme
96
97 //- Demand-driven construction of underlying scheme
99
100
101private:
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
116 parallelFvGeometryScheme(const parallelFvGeometryScheme&) = delete;
117
118 //- No copy assignment
119 void operator=(const parallelFvGeometryScheme&) = delete;
120
121
122public:
123
124 // Public classes
125
126 //- Transformation for oriented fields
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
149public:
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 );
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
182
183 //- Return cell-centre difference coefficients
184 virtual tmp<surfaceScalarField> deltaCoeffs() const;
185
186 //- Return non-orthogonal cell-centre difference coefficients
188
189 //- Return non-orthogonality correction vectors
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// ************************************************************************* //
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
virtual bool parallel() const
Are the cyclic planes parallel.
virtual const tensorField & forwardT() const
Return face transformation tensor.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
const fvMesh & mesh() const
Return mesh reference.
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
void operator()(const coupledPolyPatch &cpp, UList< Type > &fld) const
tmp< fvGeometryScheme > geometryPtr_
Demand-driven construction of underlying scheme.
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 > nonOrthDeltaCoeffs() const
Return non-orthogonal cell-centre difference coefficients.
const fvGeometryScheme & geometry() const
Construct underlying fvGeometryScheme.
virtual tmp< surfaceVectorField > nonOrthCorrectionVectors() const
Return non-orthogonality correction vectors.
dictionary dict_
Dictionary for underlying scheme.
virtual void movePoints()
Do what is necessary if the mesh has moved.
virtual tmp< surfaceScalarField > weights() const
Return linear difference weighting factors.
virtual tmp< surfaceScalarField > deltaCoeffs() const
Return cell-centre difference coefficients.
TypeName("parallel")
Runtime type information.
virtual void updateMesh(const mapPolyMesh &mpm)
Update mesh for topology changes.
virtual ~parallelFvGeometryScheme()=default
Destructor.
A class for managing references or pointers (no reference counting).
Definition refPtr.H:54
A class for managing temporary objects.
Definition tmp.H:75
dynamicFvMesh & mesh
const pointField & points
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Field< vector > vectorField
Specialisation of Field<T> for vector.
void transformList(const tensor &rotTensor, UList< T > &field)
Inplace transform a list of elements.
vectorField pointField
pointField is a vectorField.
labelList f(nPoints)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68