mappedFvPatchBaseBase.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2023 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 "mappedFvPatchBaseBase.H"
27 #include "fvMesh.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
34 }
35 
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
40 :
41  patch_(patch),
42  mapper_(refCast<const mappedPatchBaseBase>(patch.patch()))
43 {}
44 
45 
46 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
47 
49 {}
50 
51 
52 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
53 
55 (
56  const fvPatch& patch
57 )
58 {
59  if (!isA<mappedFvPatchBaseBase>(patch))
60  {
62  << "Patch " << patch.name() << " is not of type "
63  << typeName << exit(FatalError);
64  }
65 
66  return refCast<const mappedFvPatchBaseBase>(patch);
67 }
68 
69 
71 {
72  const fvMesh& mesh = patch_.boundaryMesh().mesh();
73 
74  return mesh.time().foundObject<fvMesh>(mapper_.nbrRegionName());
75 }
76 
77 
79 {
80  const fvMesh& mesh = patch_.boundaryMesh().mesh();
81 
82  return mesh.time().lookupObject<fvMesh>(mapper_.nbrRegionName());
83 }
84 
85 
87 {
88  const fvMesh& nbrMesh = this->nbrMesh();
89 
90  const label patchi =
91  nbrMesh.boundaryMesh().findIndex(mapper_.nbrPatchName());
92 
93  if (patchi == -1)
94  {
96  << "Cannot find patch " << mapper_.nbrPatchName()
97  << " in region " << mapper_.nbrRegionName() << endl
98  << "Valid patches are " << nbrMesh.boundaryMesh().names()
99  << exit(FatalError);
100  }
101 
102  return nbrMesh.boundary()[patchi];
103 }
104 
105 
106 // ************************************************************************* //
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:418
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:857
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
virtual const word & name() const
Return name.
Definition: fvPatch.H:126
Base class for fv patches that provide mapping between two fv patches.
mappedFvPatchBaseBase(const fvPatch &patch)
Construct from a patch.
const fvPatch & nbrFvPatch() const
Get the patch to map from.
static const mappedFvPatchBaseBase & getMap(const fvPatch &patch)
Cast the given fvPatch to a mappedFvPatchBaseBase. Handle errors.
bool haveNbr() const
Is the neighbour available?
const fvMesh & nbrMesh() const
Get the mesh for the region to map from.
virtual ~mappedFvPatchBaseBase()
Destructor.
Base class for engines and poly patches which provide mapping between two poly patches.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
bool foundObject(const word &name) const
Is the named Type in registry.
label findIndex(const word &patchName) const
Find patch index given a name.
wordList names() const
Return the list of patch names.
const polyMesh & mesh() const
Return the mesh reference.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:404
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
label patchi
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:129
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
defineTypeNameAndDebug(combustionModel, 0)
error FatalError