symmetryPlanePolyPatch.C
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) 2013-2015 OpenFOAM Foundation
9  Copyright (C) 2022,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 \*---------------------------------------------------------------------------*/
28 
29 #include "symmetryPlanePolyPatch.H"
31 #include "symmetryPolyPatch.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(symmetryPlanePolyPatch, 0);
38 
41 }
42 
43 
44 // * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
45 
47 {
48  if (n_ == vector::rootMax)
49  {
50  if (returnReduceOr(size()))
51  {
52  // Instead of using the average unit-normal use an area weighted
53  // average instead. This avoids problem when adding zero-sized
54  // faces since these have a calculated area vector of (0 0 0)
55  const auto& areas = faceAreas();
56 
57  n_ = gSum(areas).normalise(ROOTVSMALL);
58 
59  if (debug)
60  {
61  Info<< "Patch " << name() << " calculated average normal "
62  << n_ << endl;
63  }
64 
65 
66  // Check the symmetry plane is planar
67  forAll(areas, facei)
68  {
69  const scalar a = mag(areas[facei]);
70 
71  // Calculate only if non-zero area
72  if (a > ROOTVSMALL)
73  {
74  const vector nf(areas[facei]/a);
75 
76  if (magSqr(n_ - nf) > SMALL)
77  {
79  << "Symmetry plane '" << name()
80  << "' is not planar." << endl
81  << "At local face at "
82  << primitivePatch::faceCentres()[facei]
83  << " the normal " << nf
84  << " differs from the average normal " << n_
85  << " by " << magSqr(n_ - nf) << endl
86  << "Either split the patch into planar parts"
87  << " or use the " << symmetryPolyPatch::typeName
88  << " patch type"
89  << exit(FatalError);
90  }
91  }
92  }
93  }
94  }
95 }
96 
97 
98 // * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * //
99 
101 (
102  const word& name,
103  const label size,
104  const label start,
105  const label index,
106  const polyBoundaryMesh& bm,
107  const word& patchType
108 )
109 :
110  polyPatch(name, size, start, index, bm, patchType),
111  n_(vector::rootMax)
112 {}
113 
114 
116 (
117  const word& name,
118  const dictionary& dict,
119  const label index,
120  const polyBoundaryMesh& bm,
121  const word& patchType
122 )
123 :
124  polyPatch(name, dict, index, bm, patchType),
125  n_(vector::rootMax)
126 {}
127 
128 
130 (
131  const symmetryPlanePolyPatch& pp,
132  const polyBoundaryMesh& bm
133 )
134 :
135  polyPatch(pp, bm),
136  n_(pp.n_)
137 {}
138 
139 
141 (
142  const symmetryPlanePolyPatch& pp,
143  const polyBoundaryMesh& bm,
144  const label index,
145  const label newSize,
146  const label newStart
147 )
148 :
149  polyPatch(pp, bm, index, newSize, newStart),
150  n_(pp.n_)
151 {}
152 
153 
155 (
156  const symmetryPlanePolyPatch& pp,
157  const polyBoundaryMesh& bm,
158  const label index,
159  const labelUList& mapAddressing,
160  const label newStart
161 )
162 :
163  polyPatch(pp, bm, index, mapAddressing, newStart),
164  n_(pp.n_)
165 {}
166 
167 
168 // ************************************************************************* //
dictionary dict
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:608
symmetryPlanePolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType)
Construct from components.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
Type gSum(const FieldField< Field, Type > &f)
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
A class for handling words, derived from Foam::string.
Definition: word.H:63
const Field< point_type > & faceCentres() const
Return face centres for patch.
Vector< scalar > vector
Definition: vector.H:57
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
const word & name() const noexcept
The patch name.
const vectorField::subField faceAreas() const
Return face normals.
Definition: polyPatch.C:307
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
Buffers for inter-processor communications streams (UOPstream, UIPstream).
messageStream Info
Information stream (stdout output on master, null elsewhere)
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:69
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Namespace for OpenFOAM.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)