wedgeFaPatch.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) 2016-2017 Wikki Ltd
9  Copyright (C) 2021-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 "wedgeFaPatch.H"
31 #include "faMesh.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(wedgeFaPatch, 0);
38  addToRunTimeSelectionTable(faPatch, wedgeFaPatch, dictionary);
39 }
40 
41 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
42 
43 void Foam::wedgeFaPatch::findAxisPoint() const
44 {
45  // Find axis point
46 
47  const labelList& ptLabels = pointLabels();
48 
49  const labelListList& ptEdges = pointEdges();
50 
51  const vectorField& points = boundaryMesh().mesh().points();
52 
53  const scalarField& magL = magEdgeLengths();
54 
55  forAll(ptEdges, pointI)
56  {
57  if (ptEdges[pointI].size() == 1)
58  {
59  scalar r = mag((I-axis()*axis())&points[ptLabels[pointI]]);
60 
61  if (r < magL[ptEdges[pointI][0]])
62  {
63  axisPoint_ = ptLabels[pointI];
64  break;
65  }
66  }
67  }
68 
69  axisPointChecked_ = true;
70 }
71 
72 
73 // * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * //
74 
76 (
77  const word& name,
78  const dictionary& dict,
79  const label index,
80  const faBoundaryMesh& bm,
81  const word& patchType
82 )
83 :
84  faPatch(name, dict, index, bm, patchType),
85  wedgePolyPatchPtr_(nullptr),
86  axisPoint_(-1),
87  axisPointChecked_(false)
88 {
89  if (ngbPolyPatchIndex() < 0)
90  {
92  << "Neighbour polyPatch index is not specified for faPatch "
93  << this->name() << exit(FatalError);
94  }
95 
96  const auto* wedgePtr = isA<wedgePolyPatch>
97  (
98  bm.mesh().mesh().boundaryMesh()[ngbPolyPatchIndex()]
99  );
100 
101  if (wedgePtr)
102  {
103  wedgePolyPatchPtr_ = wedgePtr;
104  }
105  else
106  {
108  << "Neighbour polyPatch is not of type "
109  << wedgePolyPatch::typeName
110  << exit(FatalError);
111  }
112 }
113 
114 
115 // ************************************************************************* //
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
const vector & axis() const
Return axis of the wedge.
Definition: wedgeFaPatch.H:109
const labelList & pointLabels() const
Return patch point labels.
Definition: faPatch.C:267
virtual label size() const
Patch size is the number of edge labels, but can be overloaded.
Definition: faPatch.H:392
const scalarField & magEdgeLengths() const
Return edge length magnitudes, like the faMesh::magLe() method.
Definition: faPatch.C:450
List< labelList > labelListList
List of labelList.
Definition: labelList.H:38
static const faMesh & mesh(const polyMesh &pMesh)
The single-region finite-area region on the polyMesh. Uses lookupObject semantics - Fatal if non-exis...
Definition: faMesh.C:158
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
const pointField & points
static const Identity< scalar > I
Definition: Identity.H:100
A class for handling words, derived from Foam::string.
Definition: word.H:63
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const pointField & points() const
Return local points.
Definition: faMeshI.H:60
const faMesh & mesh() const noexcept
Return the mesh reference.
const word & name() const noexcept
The patch name.
defineTypeNameAndDebug(combustionModel, 0)
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:72
wedgeFaPatch(const word &name, const dictionary &dict, const label index, const faBoundaryMesh &bm, const word &patchType)
Construct from dictionary.
Definition: wedgeFaPatch.C:69
Finite area boundary mesh.
const labelListList & pointEdges() const
Return patch point-edge addressing.
Definition: faPatch.C:278
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< label > labelList
A List of labels.
Definition: List.H:62
const faBoundaryMesh & boundaryMesh() const noexcept
Return boundaryMesh reference.
Definition: faPatch.C:174
Namespace for OpenFOAM.
label ngbPolyPatchIndex() const noexcept
The neighbour polyPatch index.
Definition: faPatch.H:359
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)