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 "faBoundaryMesh.H"
32 #include "wedgePolyPatch.H"
33 #include "polyMesh.H"
34 #include "faMesh.H"
35 
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40  defineTypeNameAndDebug(wedgeFaPatch, 0);
41  addToRunTimeSelectionTable(faPatch, wedgeFaPatch, dictionary);
42 }
43 
44 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
45 
46 void Foam::wedgeFaPatch::findAxisPoint() const
47 {
48  // Find axis point
49 
50  const labelList& ptLabels = pointLabels();
51 
52  const labelListList& ptEdges = pointEdges();
53 
54  const vectorField& points = boundaryMesh().mesh().points();
55 
56  const scalarField& magL = magEdgeLengths();
57 
58  forAll(ptEdges, pointI)
59  {
60  if (ptEdges[pointI].size() == 1)
61  {
62  scalar r = mag((I-axis()*axis())&points[ptLabels[pointI]]);
63 
64  if (r < magL[ptEdges[pointI][0]])
65  {
66  axisPoint_ = ptLabels[pointI];
67  break;
68  }
69  }
70  }
71 
72  axisPointChecked_ = true;
73 }
74 
75 
76 // * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * //
77 
79 (
80  const word& name,
81  const dictionary& dict,
82  const label index,
83  const faBoundaryMesh& bm,
84  const word& patchType
85 )
86 :
87  faPatch(name, dict, index, bm, patchType),
88  wedgePolyPatchPtr_(nullptr),
89  axisPoint_(-1),
90  axisPointChecked_(false)
91 {
92  if (ngbPolyPatchIndex() < 0)
93  {
95  << "Neighbour polyPatch index is not specified for faPatch "
96  << this->name() << exit(FatalError);
97  }
98 
99  const auto* wedgePtr = isA<wedgePolyPatch>
100  (
101  bm.mesh().mesh().boundaryMesh()[ngbPolyPatchIndex()]
102  );
103 
104  if (wedgePtr)
105  {
106  wedgePolyPatchPtr_ = wedgePtr;
107  }
108  else
109  {
111  << "Neighbour polyPatch is not of type "
112  << wedgePolyPatch::typeName
113  << exit(FatalError);
114  }
115 }
116 
117 
118 // ************************************************************************* //
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:598
const vector & axis() const
Return axis of the wedge.
Definition: wedgeFaPatch.H:109
const labelList & pointLabels() const
Return patch point labels.
Definition: faPatch.C:276
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:462
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:74
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:67
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:72
Finite area boundary mesh.
const labelListList & pointEdges() const
Return patch point-edge addressing.
Definition: faPatch.C:287
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:183
Namespace for OpenFOAM.
label ngbPolyPatchIndex() const noexcept
The neighbour polyPatch index.
Definition: faPatch.H:359
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)