surfaceDistance.H
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) 2019-2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::functionObjects::surfaceDistance
28 
29 Group
30  grpFieldFunctionObjects
31 
32 Description
33  Computes the distance to the nearest surface from a given geometry.
34 
35  Operands:
36  \table
37  Operand | Type | Location
38  input | - | -
39  output file | - | -
40  output field | volScalarField | $FOAM_CASE/<time>/surfaceDistance
41  \endtable
42 
43 Usage
44  Minimal example by using \c system/controlDict.functions:
45  \verbatim
46  surfaceDistance1
47  {
48  // Mandatory entries (unmodifiable)
49  type surfaceDistance;
50  libs (fieldFunctionObjects);
51 
52  // Mandatory entries (runtime modifiable)
53  geometry
54  {
55  motorBike.obj
56  {
57  type triSurfaceMesh;
58  name motorBike;
59  }
60  }
61 
62  // Optional entries (runtime modifiable)
63  calculateCells true;
64 
65  // Optional (inherited) entries
66  ...
67  }
68  \endverbatim
69 
70  where the entries mean:
71  \table
72  Property | Description | Type | Req'd | Dflt
73  type | Type name: surfaceDistance | word | yes | -
74  libs | Library name: fieldFunctionObjects | word | yes | -
75  geometry | Surface details | dict | yes | -
76  calculateCells | Calculate distance from cell | bool | no | true
77  \endtable
78 
79  The inherited entries are elaborated in:
80  - \link functionObject.H \endlink
81 
82  Usage by the \c postProcess utility is not available.
83 
84 See also
85  - Foam::functionObject
86  - Foam::functionObjects::fvMeshFunctionObject
87  - ExtendedCodeGuide::functionObjects::field::surfaceDistance
88 
89 SourceFiles
90  surfaceDistance.C
91 
92 \*---------------------------------------------------------------------------*/
93 
94 #ifndef functionObjects_surfaceDistance_H
95 #define functionObjects_surfaceDistance_H
96 
97 #include "fvMeshFunctionObject.H"
98 #include "searchableSurfaces.H"
99 #include "volFields.H"
100 
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102 
103 namespace Foam
104 {
105 
106 // Forward declaration of classes
107 class objectRegistry;
108 class dictionary;
109 class mapPolyMesh;
110 
111 namespace functionObjects
112 {
113 
114 /*---------------------------------------------------------------------------*\
115  Class surfaceDistance Declaration
116 \*---------------------------------------------------------------------------*/
117 
118 class surfaceDistance
119 :
120  public fvMeshFunctionObject
121 {
122 protected:
123 
124  // Protected Data
125 
126  //- Switch to calculate distance-to-cells
127  Switch doCells_;
128 
129  //- Geometry
130  autoPtr<searchableSurfaces> geomPtr_;
131 
132 
133 public:
134 
135  //- Runtime type information
136  TypeName("surfaceDistance");
137 
138 
139  // Constructors
140 
141  //- Construct for given objectRegistry and dictionary.
142  // Allow the possibility to load fields from files
144  (
145  const word& name,
146  const Time& runTime,
147  const dictionary& dict
148  );
149 
150  //- No copy construct
151  surfaceDistance(const surfaceDistance&) = delete;
152 
153  //- No copy assignment
154  void operator=(const surfaceDistance&) = delete;
155 
156 
157  //- Destructor
158  virtual ~surfaceDistance() = default;
159 
160 
161  // Member Functions
162 
163  //- Read the controls
164  virtual bool read(const dictionary&);
165 
166  //- Calculate the interpolated fields
167  virtual bool execute();
168 
169  //- Write the interpolated fields
170  virtual bool write();
171 };
172 
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 } // End namespace functionObjects
177 } // End namespace Foam
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 #endif
182 
183 // ************************************************************************* //
volFields.H
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:77
Foam::functionObjects::surfaceDistance::write
virtual bool write()
Write the interpolated fields.
Definition: surfaceDistance.C:169
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
fvMeshFunctionObject.H
Foam::functionObjects::surfaceDistance::~surfaceDistance
virtual ~surfaceDistance()=default
Destructor.
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
searchableSurfaces.H
Foam::functionObjects::surfaceDistance::doCells_
Switch doCells_
Switch to calculate distance-to-cells.
Definition: surfaceDistance.H:172
Foam::functionObjects::surfaceDistance::execute
virtual bool execute()
Calculate the interpolated fields.
Definition: surfaceDistance.C:111
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::functionObjects::surfaceDistance::surfaceDistance
surfaceDistance(const word &name, const Time &runTime, const dictionary &dict)
Construct for given objectRegistry and dictionary.
Definition: surfaceDistance.C:46
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::surfaceDistance
Computes the distance to the nearest surface from a given geometry.
Definition: surfaceDistance.H:163
Foam::functionObjects::surfaceDistance::TypeName
TypeName("surfaceDistance")
Runtime type information.
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::surfaceDistance::geomPtr_
autoPtr< searchableSurfaces > geomPtr_
Geometry.
Definition: surfaceDistance.H:175
Foam::functionObjects::surfaceDistance::read
virtual bool read(const dictionary &)
Read the controls.
Definition: surfaceDistance.C:80
Foam::functionObjects::surfaceDistance::operator=
void operator=(const surfaceDistance &)=delete
No copy assignment.