Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
11License
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
31#include "symmetryPolyPatch.H"
33// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34
35namespace Foam
36{
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 "
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
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
123:
124 polyPatch(name, dict, index, bm, patchType),
125 n_(vector::rootMax)
126{}
127
128
130(
132 const polyBoundaryMesh& bm
134:
135 polyPatch(pp, bm),
136 n_(pp.n_)
137{}
138
139
141(
143 const polyBoundaryMesh& bm,
144 const label index,
145 const label newSize,
146 const label newStart
148:
149 polyPatch(pp, bm, index, newSize, newStart),
150 n_(pp.n_)
151{}
152
153
155(
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// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Buffers for inter-processor communications streams (UOPstream, UIPstream).
label size() const noexcept
Definition UList.H:706
void size(const label n)
Definition UList.H:118
static const Form rootMax
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
label index() const noexcept
The index of this patch in the boundaryMesh.
const word & name() const noexcept
The patch name.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
A patch is a list of labels that address the faces in the global face list.
Definition polyPatch.H:73
const vectorField::subField faceAreas() const
Return face normals.
Definition polyPatch.C:326
friend class polyBoundaryMesh
Definition polyPatch.H:112
polyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType)
Construct from components.
Definition polyPatch.C:75
label start() const noexcept
Return start label of this patch in the polyMesh face list.
Definition polyPatch.H:446
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
symmetryPlanePolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType)
Construct from components.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
Namespace for handling debugging switches.
Definition debug.C:45
Namespace for OpenFOAM.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
Type gSum(const FieldField< Field, Type > &f)
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
Vector< scalar > vector
Definition vector.H:57
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
UList< label > labelUList
A UList of labels.
Definition UList.H:75
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299