interfaceHeight.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) 2017-2019 OpenFOAM Foundation
9  Copyright (C) 2020 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 Class
28  Foam::functionObjects::interfaceHeight
29 
30 Description
31  This function object reports the height of the interface above a set of
32  locations.
33 
34  For each location, it writes the vertical distance of the
35  interface above both the location and the lowest boundary. It also writes
36  the point on the interface from which these heights are computed. It uses
37  an integral approach, so if there are multiple interfaces above or below a
38  location then this method will generate average values.
39 
40  Operands:
41  \table
42  Operand | Type | Location
43  input | - | -
44  output file 1 | dat | $FOAM_CASE/postProcessing/<FO>/<time>/height
45  output file 2 | dat | $FOAM_CASE/postProcessing/<FO>/<time>/position
46  output field | - | -
47  \endtable
48 
49 Usage
50  Minimal example by using \c system/controlDict.functions:
51  \verbatim
52  interfaceHeight1
53  {
54  // Mandatory entries (unmodifiable)
55  type interfaceHeight;
56  libs (fieldFunctionObjects);
57 
58  // Mandatory entries (runtime modifiable)
59  locations ((0 0 0) (10 0 0) (20 0 0));
60 
61  // Optional entries (runtime modifiable)
62  alpha alpha.water;
63  liquid true;
64  direction (1 0 0);
65  interpolationScheme cellPoint;
66 
67  // Optional (inherited) entries
68  ...
69  }
70  \endverbatim
71 
72  where the entries mean:
73  \table
74  Property | Description | Type | Req'd | Dflt
75  type | Type name: interfaceHeight | word | yes | -
76  libs | Library name: fieldFunctionObjects | word | yes | -
77  locations | Locations to report the height at | vectorList | yes | -
78  alpha | Name of alpha field | word | no | alpha
79  liquid | Flag if the alpha field that of the liquid | bool | no | true
80  direction | Direction of interface | vector | no | g
81  interpolationScheme | Interpolation scheme | word | no | cellPoint
82  \endtable
83 
84  The inherited entries are elaborated in:
85  - \link functionObject.H \endlink
86  - \link writeFile.H \endlink
87 
88  Usage by the \c postProcess utility is not available.
89 
90 See also
91  - Foam::functionObject
92  - Foam::functionObjects::fvMeshFunctionObject
93  - Foam::functionObjects::writeFile
94  - Foam::functionObjects::logFile
95  - ExtendedCodeGuide::functionObjects::field::interfaceHeight
96 
97 SourceFiles
98  interfaceHeight.C
99 
100 \*---------------------------------------------------------------------------*/
101 
102 #ifndef interfaceHeight_H
103 #define interfaceHeight_H
104 
105 #include "fvMeshFunctionObject.H"
106 #include "logFiles.H"
107 #include "point.H"
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 namespace Foam
112 {
113 namespace functionObjects
114 {
115 
116 /*---------------------------------------------------------------------------*\
117  Class interfaceHeight Declaration
118 \*---------------------------------------------------------------------------*/
119 
120 class interfaceHeight
121 :
122  public fvMeshFunctionObject,
123  public logFiles
124 {
125  // Private Data
126 
127  //- Is the alpha field that of the liquid under the wave?
128  bool liquid_;
129 
130  //- Name of the alpha field
131  word alphaName_;
132 
133  //- Interpolation scheme
134  word interpolationScheme_;
135 
136  //- Direction of interface motion
137  vector direction_;
138 
139  //- List of locations to report the height at
140  List<point> locations_;
141 
142 
143  // Private Member Functions
144 
145  //- Output positions
146  void writePositions();
147 
148 
149  // Private Enumerations
150 
151  //- File enumeration
152  enum class fileID
153  {
154  heightFile = 0,
155  positionFile = 1
156  };
157 
158 
159 protected:
160 
161  // Protected Member Functions
162 
163  //- Output file header information
164  virtual void writeFileHeader(const fileID fid);
165 
166 
167 public:
168 
169  //- Runtime type information
170  TypeName("interfaceHeight");
171 
172 
173  // Constructors
174 
175  //- Construct from Time and dictionary
177  (
178  const word& name,
179  const Time& runTime,
180  const dictionary& dict
181  );
182 
183  //- No copy construct
184  interfaceHeight(const interfaceHeight&) = delete;
185 
186  //- No copy assignment
187  void operator=(const interfaceHeight&) = delete;
188 
189 
190  //- Destructor
191  virtual ~interfaceHeight() = default;
192 
193 
194  // Member Functions
195 
196  //- Inherit logFiles methods
197  using logFiles::files;
198 
199  //- Return file corresponding to enumeration
200  OFstream& files(const fileID fid)
201  {
202  return logFiles::files(label(fid));
203  }
204 
205 
206  //- Read
207  virtual bool read(const dictionary&);
208 
209  //- Execute
210  virtual bool execute();
211 
212  //- Execute at the final time-loop
213  virtual bool end();
214 
215  //- Write
216  virtual bool write();
217 };
218 
219 
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 
222 } // End namespace functionObjects
223 } // End namespace Foam
224 
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 #endif
228 
229 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
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:62
fvMeshFunctionObject.H
Foam::functionObjects::interfaceHeight::write
virtual bool write()
Write.
Definition: interfaceHeight.C:274
Foam::functionObjects::interfaceHeight::read
virtual bool read(const dictionary &)
Read.
Definition: interfaceHeight.C:250
point.H
Foam::functionObjects::interfaceHeight::execute
virtual bool execute()
Execute.
Definition: interfaceHeight.C:262
Foam::functionObjects::logFiles::files
PtrList< OFstream > & files()
Return access to the files.
Definition: logFiles.C:116
Foam::functionObjects::interfaceHeight::operator=
void operator=(const interfaceHeight &)=delete
No copy assignment.
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::functionObjects::interfaceHeight::files
OFstream & files(const fileID fid)
Return file corresponding to enumeration.
Definition: interfaceHeight.H:267
Foam::functionObjects::interfaceHeight::end
virtual bool end()
Execute at the final time-loop.
Definition: interfaceHeight.C:268
Foam::functionObjects::interfaceHeight
This function object reports the height of the interface above a set of locations.
Definition: interfaceHeight.H:187
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:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::functionObjects::logFiles
functionObject base class for creating, maintaining and writing log files e.g. integrated or averaged...
Definition: logFiles.H:59
logFiles.H
Foam::OFstream
Output to file stream, using an OSstream.
Definition: OFstream.H:53
Foam::functionObject::name
const word & name() const
Return the name of this functionObject.
Definition: functionObject.C:131
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::functionObjects::interfaceHeight::TypeName
TypeName("interfaceHeight")
Runtime type information.
Foam::functionObjects::interfaceHeight::~interfaceHeight
virtual ~interfaceHeight()=default
Destructor.
Foam::functionObjects::interfaceHeight::interfaceHeight
interfaceHeight(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: interfaceHeight.C:229
Foam::functionObjects::interfaceHeight::writeFileHeader
virtual void writeFileHeader(const fileID fid)
Output file header information.
Definition: interfaceHeight.C:155