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 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  const vectorField& nf = faceNormals();
53  n_ = gAverage(nf);
54 
55  if (debug)
56  {
57  Info<< "Patch " << name() << " calculated average normal "
58  << n_ << endl;
59  }
60 
61 
62  // Check the symmetry plane is planar
63  forAll(nf, facei)
64  {
65  if (magSqr(n_ - nf[facei]) > SMALL)
66  {
68  << "Symmetry plane '" << name() << "' is not planar."
69  << endl
70  << "At local face at "
71  << primitivePatch::faceCentres()[facei]
72  << " the normal " << nf[facei]
73  << " differs from the average normal " << n_
74  << " by " << magSqr(n_ - nf[facei]) << endl
75  << "Either split the patch into planar parts"
76  << " or use the " << symmetryPolyPatch::typeName
77  << " patch type"
78  << exit(FatalError);
79  }
80  }
81  }
82  }
83 }
84 
85 
86 // * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * //
87 
89 (
90  const word& name,
91  const label size,
92  const label start,
93  const label index,
94  const polyBoundaryMesh& bm,
95  const word& patchType
96 )
97 :
98  polyPatch(name, size, start, index, bm, patchType),
99  n_(vector::rootMax)
100 {}
101 
102 
104 (
105  const word& name,
106  const dictionary& dict,
107  const label index,
108  const polyBoundaryMesh& bm,
109  const word& patchType
110 )
111 :
112  polyPatch(name, dict, index, bm, patchType),
113  n_(vector::rootMax)
114 {}
115 
116 
118 (
119  const symmetryPlanePolyPatch& pp,
120  const polyBoundaryMesh& bm
121 )
122 :
123  polyPatch(pp, bm),
124  n_(pp.n_)
125 {}
126 
127 
129 (
130  const symmetryPlanePolyPatch& pp,
131  const polyBoundaryMesh& bm,
132  const label index,
133  const label newSize,
134  const label newStart
135 )
136 :
137  polyPatch(pp, bm, index, newSize, newStart),
138  n_(pp.n_)
139 {}
140 
141 
143 (
144  const symmetryPlanePolyPatch& pp,
145  const polyBoundaryMesh& bm,
146  const label index,
147  const labelUList& mapAddressing,
148  const label newStart
149 )
150 :
151  polyPatch(pp, bm, index, mapAddressing, newStart),
152  n_(pp.n_)
153 {}
154 
155 
156 // ************************************************************************* //
dictionary dict
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
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:598
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
const Field< point_type > & faceNormals() const
Return face unit normals for patch.
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.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
const word & name() const noexcept
The patch name.
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).
Type gAverage(const FieldField< Field, Type > &f)
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)