fvMeshFunctionObject.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) 2016-2024 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 "fvMeshFunctionObject.H"
27 #include "Time.H"
28 #include "fvMesh.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace functionObjects
35 {
37 }
38 }
39 
40 
41 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
42 
44 (
45  const dictionary& dict,
46  const bool optional
47 ) const
48 {
49  if (dict.found("patch"))
50  {
51  const word patchName(dict.lookup("patch"));
52  const label patchIndex = mesh_.boundaryMesh().findIndex(patchName);
53 
54  if (patchIndex >= 0)
55  {
56  return labelHashSet(FixedList<label, 1>(patchIndex));
57  }
58  else
59  {
61  << "Unable to find patch " << patchName << exit(FatalIOError);
62  }
63  }
64  else if (dict.found("patches"))
65  {
66  return mesh_.boundaryMesh().patchSet
67  (
68  dict.lookup<wordReList>("patches")
69  );
70  }
71  else
72  {
73  if (!optional)
74  {
76  << "Neither 'patch' or 'patches' specified"
77  << exit(FatalIOError);
78  }
79  }
80 
81  return labelHashSet();
82 }
83 
84 
85 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
86 
88 (
89  const word& name,
90  const Time& runTime,
91  const dictionary& dict
92 )
93 :
94  regionFunctionObject(name, runTime, dict),
95  mesh_(refCast<const fvMesh>(obr_))
96 {}
97 
98 
100 (
101  const word& name,
102  const objectRegistry& obr,
103  const dictionary& dict
104 )
105 :
107  mesh_(refCast<const fvMesh>(obr_))
108 {}
109 
110 
111 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
112 
114 {}
115 
116 
117 // ************************************************************************* //
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:78
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
fvMeshFunctionObject(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
const fvMesh & mesh_
Reference to the fvMesh.
labelHashSet patchSet(const dictionary &, const bool optional=false) const
Return the patch set corresponding to the patch selection entries.
Specialisation of Foam::functionObject for a region and providing a reference to the region Foam::obj...
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
Registry of regIOobjects.
label findIndex(const word &patchName) const
Find patch index given a name.
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool usePatchGroups=true) const
Return the set of patch indices corresponding to the given names.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:404
A class for handling words, derived from string.
Definition: word.H:62
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
defineTypeNameAndDebug(adjustTimeStepToCombustion, 0)
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
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
IOerror FatalIOError
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
Definition: HashSet.H:213
dictionary dict