searchableSurface.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) 2011-2021 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 "searchableSurface.H"
27 #include "Time.H"
28 #include "triSurface.H"
29 #include "OSspecific.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
37 }
38 
40 
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
45 (
46  const word& searchableSurfaceType,
47  const IOobject& io,
48  const dictionary& dict
49 )
50 {
51  dictConstructorTable::iterator cstrIter =
52  dictConstructorTablePtr_->find(searchableSurfaceType);
53 
54  if (cstrIter == dictConstructorTablePtr_->end())
55  {
57  << "Unknown searchableSurface type " << searchableSurfaceType
58  << endl << endl
59  << "Valid searchableSurface types : " << endl
60  << dictConstructorTablePtr_->sortedToc()
61  << exit(FatalError);
62  }
63 
64  return autoPtr<searchableSurface>(cstrIter()(io, dict));
65 }
66 
67 
68 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
69 
71 :
72  regIOobject(io)
73 {}
74 
75 
76 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
77 
79 {}
80 
81 
82 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
83 
85 {
86  return geometryDir_;
87 }
88 
89 
91 {
92  if
93  (
94  isDir
95  (
96  time.rootPath()/time.globalCaseName()/time.constant()/
98  )
99  )
100  {
102  }
103  else if
104  (
105  isDir
106  (
107  time.rootPath()/time.globalCaseName()/time.constant()/
108  triSurface::typeName
109  )
110  )
111  {
112  return triSurface::typeName;
113  }
114  else
115  {
117  }
118 }
119 
120 
122 (
123  const pointField& sample,
124  const scalarField& nearestDistSqr,
125  List<pointIndexHit>& info,
126  vectorField& normal,
127  labelList& region
128 ) const
129 {
130  findNearest(sample, nearestDistSqr, info);
131  getNormal(info, normal);
132  getRegion(info, region);
133 }
134 
135 
136 // ************************************************************************* //
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
static const word & constant()
Return constant name.
Definition: TimePaths.H:122
const fileName & globalCaseName() const
Return global case name.
Definition: TimePaths.H:100
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
const fileName & rootPath() const
Explicitly inherit rootPath from TimePaths to disambiguate from.
Definition: TimePaths.H:94
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
static word geometryDir_
Name of the directory for the geometry files.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
searchableSurface(const IOobject &io)
virtual ~searchableSurface()
Destructor.
static const word & geometryDir()
Return the geometry directory name.
static autoPtr< searchableSurface > New(const word &surfaceType, const IOobject &io, const dictionary &dict)
Return a reference to the selected searchableSurface.
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
defineTypeNameAndDebug(combustionModel, 0)
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
Definition: POSIX.C:539
error FatalError
dictionary dict