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 -------------------------------------------------------------------------------
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::Curle
28 
29 Group
30  grpFieldFunctionObjects
31 
32 Description
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 
63 Note
64  Only the normal-pressure force is included in the force calculation.
65 
66 Usage
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 points or surface
79 
80  input points;
81  observerPositions ((0 0 0)(1 0 0));
82 
83  //input surface;
84  //surface "inputSurface.obj"
85 
86 
87  // Output - either points or surface
88  output points;
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 
116 See also
117  - Foam::functionObject
118  - Foam::functionObjects::fvMeshFunctionObject
119  - Foam::functionObjects::writeFile
120  - ExtendedCodeGuide::functionObjects::field::Curle
121 
122 SourceFiles
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 
138 namespace Foam
139 {
140 namespace functionObjects
141 {
142 
143 /*---------------------------------------------------------------------------*\
144  Class Curle Declaration
145 \*---------------------------------------------------------------------------*/
146 
147 class 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 
185 public:
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 // ************************************************************************* //
Foam::functionObjects::Curle::write
virtual bool write()
Called at each ++ or += of the time-loop.
Definition: Curle.C:264
runTime
engineTime & runTime
Definition: createEngineTime.H:13
writeFile.H
Foam::Enum< modeType >
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::Curle::~Curle
virtual ~Curle()=default
Destructor.
surfaceWriter.H
Foam::HashSet< label, Hash< label > >
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::functionObjects::Curle::execute
virtual bool execute()
Called at each ++ or += of the time-loop.
Definition: Curle.C:191
Foam::functionObjects::Curle::Curle
Curle(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: Curle.C:57
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:62
Foam::functionObjects::Curle::operator=
void operator=(const Curle &)=delete
No copy assignment.
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::functionObjects::Curle::read
virtual bool read(const dictionary &)
Read the Curle data.
Definition: Curle.C:79
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
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
Return the name of this functionObject.
Definition: functionObject.C:131
Foam::Vector< scalar >
Foam::functionObjects::Curle::TypeName
TypeName("Curle")
Runtime type information.
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::writeFile
Base class for writing single files from the function objects.
Definition: writeFile.H:119
Foam::point
vector point
Point is a vector.
Definition: point.H:43
Foam::labelHashSet
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys and label hasher.
Definition: HashSet.H:409
Foam::MeshedSurface< face >
Foam::functionObjects::Curle
Computes the acoustic pressure based on Curle's analogy.
Definition: Curle.H:248
MeshedSurface.H
Enum.H