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 -------------------------------------------------------------------------------
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 \*---------------------------------------------------------------------------*/
27 
28 #include "symmetryPlanePolyPatch.H"
30 #include "symmetryPolyPatch.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(symmetryPlanePolyPatch, 0);
37 
38  addToRunTimeSelectionTable(polyPatch, symmetryPlanePolyPatch, word);
39  addToRunTimeSelectionTable(polyPatch, symmetryPlanePolyPatch, dictionary);
40 }
41 
42 
43 // * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
44 
46 {
47  if (n_ == vector::rootMax)
48  {
49  if (returnReduce(size(), sumOp<label>()))
50  {
51  const vectorField& nf(faceNormals());
52  n_ = gAverage(nf);
53 
54  if (debug)
55  {
56  Info<< "Patch " << name() << " calculated average normal "
57  << n_ << endl;
58  }
59 
60 
61  // Check the symmetry plane is planar
62  forAll(nf, facei)
63  {
64  if (magSqr(n_ - nf[facei]) > SMALL)
65  {
67  << "Symmetry plane '" << name() << "' is not planar."
68  << endl
69  << "At local face at "
70  << primitivePatch::faceCentres()[facei]
71  << " the normal " << nf[facei]
72  << " differs from the average normal " << n_
73  << " by " << magSqr(n_ - nf[facei]) << endl
74  << "Either split the patch into planar parts"
75  << " or use the " << symmetryPolyPatch::typeName
76  << " patch type"
77  << exit(FatalError);
78  }
79  }
80  }
81  }
82 }
83 
84 
85 // * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * //
86 
88 (
89  const word& name,
90  const label size,
91  const label start,
92  const label index,
93  const polyBoundaryMesh& bm,
94  const word& patchType
95 )
96 :
97  polyPatch(name, size, start, index, bm, patchType),
98  n_(vector::rootMax)
99 {}
100 
101 
103 (
104  const word& name,
105  const dictionary& dict,
106  const label index,
107  const polyBoundaryMesh& bm,
108  const word& patchType
109 )
110 :
111  polyPatch(name, dict, index, bm, patchType),
112  n_(vector::rootMax)
113 {}
114 
115 
117 (
118  const symmetryPlanePolyPatch& pp,
119  const polyBoundaryMesh& bm
120 )
121 :
122  polyPatch(pp, bm),
123  n_(pp.n_)
124 {}
125 
126 
128 (
129  const symmetryPlanePolyPatch& pp,
130  const polyBoundaryMesh& bm,
131  const label index,
132  const label newSize,
133  const label newStart
134 )
135 :
136  polyPatch(pp, bm, index, newSize, newStart),
137  n_(pp.n_)
138 {}
139 
140 
142 (
143  const symmetryPlanePolyPatch& pp,
144  const polyBoundaryMesh& bm,
145  const label index,
146  const labelUList& mapAddressing,
147  const label newStart
148 )
149 :
150  polyPatch(pp, bm, index, mapAddressing, newStart),
151  n_(pp.n_)
152 {}
153 
154 
155 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::VectorSpace< Vector< scalar >, scalar, 3 >::rootMax
static const Vector< scalar > rootMax
Definition: VectorSpace.H:119
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:94
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:63
Foam::gAverage
Type gAverage(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:604
Foam::PstreamBuffers
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Definition: PstreamBuffers.H:88
symmetryPolyPatch.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::sumOp
Definition: ops.H:213
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::magSqr
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Foam::Field< vector >
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::symmetryPlanePolyPatch
Symmetry-plane patch.
Definition: symmetryPlanePolyPatch.H:50
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::symmetryPlanePolyPatch::symmetryPlanePolyPatch
symmetryPlanePolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType)
Construct from components.
Definition: symmetryPlanePolyPatch.C:88
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
symmetryPlanePolyPatch.H
Foam::symmetryPlanePolyPatch::calcGeometry
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
Definition: symmetryPlanePolyPatch.C:45
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::UList< label >
Foam::PrimitivePatch::faceNormals
const Field< point_type > & faceNormals() const
Return face unit normals for patch.
Definition: PrimitivePatch.C:445
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::patchIdentifier::name
const word & name() const noexcept
The patch name.
Definition: patchIdentifier.H:135
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::PrimitivePatch::faceCentres
const Field< point_type > & faceCentres() const
Return face centres for patch.
Definition: PrimitivePatch.C:400