Curle.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-2020 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::functionObjects::Curle
28
29Group
30 grpFieldFunctionObjects
31
32Description
33 Computes the acoustic pressure based on Curle's analogy.
34
35 Curle's analogy is implemented as:
36
37 \f[
38 p' = \frac{1}{4 \pi}
39 \frac{\vec{r}}{| \vec{r} | ^2} \cdot
40 \left(
41 \frac{\vec{F}}{| \vec{r} |}
42 + \frac{1}{c_0}\frac{d(\vec{F})}{d(t)}
43 \right)
44 \f]
45
46 where
47 \vartable
48 p' | Curle's acoustic pressure [Pa] or [Pa (m3/kg)]
49 c_0 | Reference speed of sound [m/s]
50 \vec{r} | Distance vector to observer locations [m]
51 \vec{F} | Force [N] or [N (m3/kg)]
52 t | time [s]
53 \endvartable
54
55 Operands:
56 \table
57 Operand | Type | Location
58 input | volScalarField | $FOAM_CASE/<time>/<inpField>
59 output file | - | -
60 output field | volScalarField | $FOAM_CASE/<time>/<outField>
61 \endtable
62
63Note
64 Only the normal-pressure force is included in the force calculation.
65
66Usage
67 Minimal example by using \c system/controlDict.functions:
68 \verbatim
69 Curle1
70 {
71 type Curle;
72 libs ("libfieldFunctionObjects.so");
73 ...
74 patches (surface1 surface2);
75 c0 330;
76
77
78 // Input - either point or surface
79
80 input point;
81 observerPositions ((0 0 0)(1 0 0));
82
83 //input surface;
84 //surface "inputSurface.obj"
85
86
87 // Output - either point or surface
88 output point;
89
90 //output surface;
91 //surfaceType ensight;
92 }
93 \endverbatim
94
95 where the entries mean:
96 \table
97 Property | Description | Type | Req'd | Dflt
98 type | Type name: Curle | word | yes | -
99 libs | Library name: fieldFunctionObjects | word | yes | -
100 p | Pressure field name | word | no | p
101 patches | Sound generation patch names | wordList | yes | -
102 c0 | Reference speed of sound | scalar | yes | -
103 input | Input type | word | yes | -
104 observerPositions | List of observer positions (x y z) | pointList | no |-
105 surface | Input surface file name | word | no | -
106 output | Output type | word | yes | -
107 surfaceType | Output surface type | word | no | -
108 \endtable
109
110 The inherited entries are elaborated in:
111 - \link functionObject.H \endlink
112 - \link fieldExpression.H \endlink
113
114 Usage by the \c postProcess utility is not available.
115
116See also
117 - Foam::functionObject
118 - Foam::functionObjects::fvMeshFunctionObject
119 - Foam::functionObjects::writeFile
120 - ExtendedCodeGuide::functionObjects::field::Curle
121
122SourceFiles
123 Curle.C
124
125\*---------------------------------------------------------------------------*/
126
127#ifndef functionObjects_Curle_H
128#define functionObjects_Curle_H
129
130#include "fvMeshFunctionObject.H"
131#include "writeFile.H"
132#include "Enum.H"
133#include "MeshedSurface.H"
134#include "surfaceWriter.H"
135
136// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137
138namespace Foam
139{
140namespace functionObjects
141{
142
143/*---------------------------------------------------------------------------*\
144 Class Curle Declaration
145\*---------------------------------------------------------------------------*/
146
147class Curle
148:
149 public fvMeshFunctionObject,
150 public writeFile
151{
152 enum class modeType
153 {
154 point,
155 surface
156 };
157
158 static const Enum<modeType> modeTypeNames_;
159
160
161 // Private Data
162
163 //- Name of pressure field; default = p
164 word pName_;
165
166 //- Patches to integrate forces over
167 labelHashSet patchSet_;
168
169 //- Observer positions
170 List<point> observerPositions_;
171
172 //- Reference speed of sound
173 scalar c0_;
174
175 //- Output files when sampling points
176 PtrList<OFstream> rawFilePtrs_;
177
178 //- Input surface when sampling a surface
179 MeshedSurface<face> inputSurface_;
180
181 //- Ouput surface when sampling a surface
182 autoPtr<surfaceWriter> surfaceWriterPtr_;
183
184
185public:
186
187 //- Runtime type information
188 TypeName("Curle");
189
190
191 // Constructors
192
193 //- Construct from Time and dictionary
194 Curle
195 (
196 const word& name,
197 const Time& runTime,
198 const dictionary& dict
199 );
200
201 //- No copy construct
202 Curle(const Curle&) = delete;
203
204 //- No copy assignment
205 void operator=(const Curle&) = delete;
206
207
208 //- Destructor
209 virtual ~Curle() = default;
210
211
212 // Member Functions
213
214 //- Read the Curle data
215 virtual bool read(const dictionary&);
216
217 virtual bool execute();
218
219 virtual bool write();
220};
221
222
223// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224
225} // End namespace functionObjects
226} // End namespace Foam
227
228// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229
230#endif
231
232// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Definition: MeshedSurface.H:99
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const word & name() const noexcept
Return the name of this functionObject.
Computes the acoustic pressure based on Curle's analogy.
Definition: Curle.H:252
void operator=(const Curle &)=delete
No copy assignment.
TypeName("Curle")
Runtime type information.
Curle(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: Curle.C:57
virtual ~Curle()=default
Destructor.
Curle(const Curle &)=delete
No copy construct.
virtual bool execute()
Called at each ++ or += of the time-loop.
Definition: Curle.C:191
virtual bool write()
Called at each ++ or += of the time-loop.
Definition: Curle.C:266
virtual bool read(const dictionary &)
Read the Curle data.
Definition: Curle.C:79
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Base class for writing single files from the function objects.
Definition: writeFile.H:120
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
const wordList surface
Standard surface field types (scalar, vector, tensor, etc)
Namespace for OpenFOAM.
vector point
Point is a vector.
Definition: point.H:43
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Definition: HashSet.H:85
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73