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 | Copyright (C) 2013-2014 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "symmetryPlanePolyPatch.H"
28 #include "symmetryPolyPatch.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  defineTypeNameAndDebug(symmetryPlanePolyPatch, 0);
35 
36  addToRunTimeSelectionTable(polyPatch, symmetryPlanePolyPatch, word);
37  addToRunTimeSelectionTable(polyPatch, symmetryPlanePolyPatch, dictionary);
38 }
39 
40 
41 // * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
42 
44 {
45  if (n_ == vector::rootMax)
46  {
47  if (returnReduce(size(), sumOp<label>()))
48  {
49  const vectorField& nf(faceNormals());
50  n_ = gAverage(nf);
51 
52  if (debug)
53  {
54  Info<< "Patch " << name() << " calculated average normal "
55  << n_ << endl;
56  }
57 
58 
59  // Check the symmetry plane is planar
60  forAll(nf, facei)
61  {
62  if (magSqr(n_ - nf[facei]) > SMALL)
63  {
64  FatalErrorIn("symmetryPlanePolyPatch::n()")
65  << "Symmetry plane '" << name() << "' is not planar."
66  << endl
67  << "At local face at "
68  << primitivePatch::faceCentres()[facei]
69  << " the normal " << nf[facei]
70  << " differs from the average normal " << n_
71  << " by " << magSqr(n_ - nf[facei]) << endl
72  << "Either split the patch into planar parts"
73  << " or use the " << symmetryPolyPatch::typeName
74  << " patch type"
75  << exit(FatalError);
76  }
77  }
78  }
79  }
80 }
81 
82 
83 // * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * //
84 
86 (
87  const word& name,
88  const label size,
89  const label start,
90  const label index,
91  const polyBoundaryMesh& bm,
92  const word& patchType
93 )
94 :
95  polyPatch(name, size, start, index, bm, patchType),
96  n_(vector::rootMax)
97 {}
98 
99 
101 (
102  const word& name,
103  const dictionary& dict,
104  const label index,
105  const polyBoundaryMesh& bm,
106  const word& patchType
107 )
108 :
109  polyPatch(name, dict, index, bm, patchType),
110  n_(vector::rootMax)
111 {}
112 
113 
115 (
116  const symmetryPlanePolyPatch& pp,
117  const polyBoundaryMesh& bm
118 )
119 :
120  polyPatch(pp, bm),
121  n_(pp.n_)
122 {}
123 
124 
126 (
127  const symmetryPlanePolyPatch& pp,
128  const polyBoundaryMesh& bm,
129  const label index,
130  const label newSize,
131  const label newStart
132 )
133 :
134  polyPatch(pp, bm, index, newSize, newStart),
135  n_(pp.n_)
136 {}
137 
138 
140 (
141  const symmetryPlanePolyPatch& pp,
142  const polyBoundaryMesh& bm,
143  const label index,
144  const labelUList& mapAddressing,
145  const label newStart
146 )
147 :
148  polyPatch(pp, bm, index, mapAddressing, newStart),
149  n_(pp.n_)
150 {}
151 
152 
153 // ************************************************************************* //
Buffers for inter-processor communications streams (UOPstream, UIPstream).
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
dimensioned< scalar > magSqr(const dimensioned< Type > &)
A class for handling words, derived from string.
Definition: word.H:59
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
static const Vector rootMax
Definition: Vector.H:84
messageStream Info
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
symmetryPlanePolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType)
Construct from components.
const Field< PointType > & faceCentres() const
Return face centres for patch.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::polyBoundaryMesh.
#define forAll(list, i)
Definition: UList.H:421
Macros for easy insertion into run-time selection tables.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
error FatalError
Type gAverage(const FieldField< Field, Type > &f)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)