surfaceNoise.C
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) 2015-2019 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 \*---------------------------------------------------------------------------*/
27 
28 #include "surfaceNoise.H"
29 #include "surfaceReader.H"
30 #include "surfaceWriter.H"
31 #include "noiseFFT.H"
32 #include "argList.H"
33 #include "graph.H"
35 
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40 namespace noiseModels
41 {
42 
43 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
44 
45 defineTypeNameAndDebug(surfaceNoise, 0);
46 addToRunTimeSelectionTable(noiseModel, surfaceNoise, dictionary);
47 
48 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
49 
51 {
52  Info<< "Reading data file " << fName << endl;
53 
54  label nAvailableTimes = 0;
55 
56  // All reading performed on the master processor only
57  if (Pstream::master())
58  {
59  // Create the surface reader
61 
62  // Find the index of the pressure data
63  const List<word> fieldNames(readerPtr_->fieldNames(0));
64  pIndex_ = fieldNames.find(pName_);
65  if (pIndex_ == -1)
66  {
68  << "Unable to find pressure field name " << pName_
69  << " in list of available fields: " << fieldNames
70  << exit(FatalError);
71  }
72 
73  // Create the surface writer
74  // - Could be done later, but since this utility can process a lot of
75  // data we can ensure that the user-input is correct prior to doing
76  // the heavy lifting
77 
78  // Set the time range
79  const instantList allTimes = readerPtr_->times();
81 
82  // Determine the windowing
83  nAvailableTimes = allTimes.size() - startTimeIndex_;
84  }
85 
88  Pstream::scatter(nAvailableTimes);
89 
90 
91  // Note: all processors should call the windowing validate function
92  label nRequiredTimes = windowModelPtr_->validate(nAvailableTimes);
93 
94  if (Pstream::master())
95  {
96  // Restrict times
97  const instantList allTimes = readerPtr_->times();
98 
99  times_.setSize(nRequiredTimes);
100  forAll(times_, timeI)
101  {
102  times_[timeI] = allTimes[timeI + startTimeIndex_].value();
103  }
105 
106  // Read the surface geometry
107  const meshedSurface& surf = readerPtr_->geometry();
108  nFace_ = surf.size();
109  }
110 
114 }
115 
116 
118 (
119  const labelList& procFaceOffset,
120  List<scalarField>& pData
121 )
122 {
123  // Data is stored as pressure on surface at a given time. Now we need to
124  // pivot the data so that we have the complete pressure time history per
125  // surface face. In serial mode, this results in all pressure data being
126  // loaded into memory (!)
127 
128  Info << "Reading pressure data" << endl;
129 
130  if (Pstream::parRun())
131  {
133 
134  // Procedure:
135  // 1. Master processor reads pressure data for all faces for all times
136  // 2. Master sends each processor a subset of faces
137  // 3. Local processor reconstructs the full time history for the subset
138  // of faces
139  // Note: reading all data on master to avoid potential NFS problems...
140 
141  const label myProcI = Pstream::myProcNo();
142  const label nLocalFace =
143  procFaceOffset[myProcI + 1] - procFaceOffset[myProcI];
144 
145  // Complete pressure time history data for subset of faces
146  pData.setSize(nLocalFace);
147  const label nTimes = times_.size();
148  for (scalarField& pf : pData)
149  {
150  pf.setSize(nTimes);
151  }
152 
153  // Read and send data
154  forAll(times_, i)
155  {
156  pBufs.clear();
157 
158  if (Pstream::master())
159  {
160  label timeI = i + startTimeIndex_;
161 
162  Info<< " time: " << times_[i] << endl;
163 
164  // Read pressure at all faces for time timeI
165  scalarField p(readerPtr_->field(timeI, pIndex_, scalar(0)));
166 
167  // Apply conversions
168  p *= rhoRef_;
169 
170  // Send subset of faces to each processor
171  for (label procI = 0; procI < Pstream::nProcs(); ++procI)
172  {
173  label face0 = procFaceOffset[procI];
174  label nLocalFace =
175  procFaceOffset[procI + 1] - procFaceOffset[procI];
176 
177  UOPstream toProc(procI, pBufs);
178  toProc << SubList<scalar>(p, nLocalFace, face0);
179  }
180  }
181 
182  pBufs.finishedSends();
183 
184  // Receive data from the master
185  UIPstream fromProc(0, pBufs);
186 
187  scalarList pSlice(fromProc);
188 
189  forAll(pSlice, faceI)
190  {
191  pData[faceI][i] = pSlice[faceI];
192  }
193  }
194  }
195  else
196  {
197  const label nLocalFace = procFaceOffset[0];
198 
199  pData.setSize(nLocalFace);
200  for (scalarField& pf : pData)
201  {
202  pf.setSize(times_.size());
203  }
204 
205  forAll(times_, i)
206  {
207  label timeI = i + startTimeIndex_;
208 
209  Info<< " time: " << times_[i] << endl;
210  const scalarField p(readerPtr_->field(timeI, pIndex_, scalar(0)));
211 
212  forAll(p, faceI)
213  {
214  pData[faceI][i] = p[faceI]*rhoRef_;
215  }
216  }
217  }
218 
219  Info<< "Read "
220  << returnReduce(pData.size(), sumOp<label>())
221  << " pressure traces with "
222  << times_.size()
223  << " time values" << nl << endl;
224 }
225 
226 
228 (
229  const fileName& outDirBase,
230  const word& fName,
231  const word& title,
232  const scalar freq,
233  const scalarField& data,
234  const labelList& procFaceOffset,
235  const bool writeSurface
236 ) const
237 {
238  Info<< " processing " << title << " for frequency " << freq << endl;
239 
240  const instant freqInst(freq, Foam::name(freq));
241 
242  if (Pstream::parRun())
243  {
244  // Collect the surface data so that we can output the surfaces
245 
247 
248  if (!Pstream::master())
249  {
250  UOPstream toProc(0, pBufs);
251  toProc << data;
252  }
253 
254  pBufs.finishedSends();
255 
256  scalar areaAverage = 0;
257  if (Pstream::master())
258  {
259  const meshedSurface& surf = readerPtr_->geometry();
260 
261  scalarField allData(surf.size());
262 
263  forAll(data, faceI)
264  {
265  // Master procFaceOffset is zero...
266  allData[faceI] = data[faceI];
267  }
268 
269  for (label procI = 1; procI < Pstream::nProcs(); ++procI)
270  {
271  UIPstream fromProc(procI, pBufs);
272  scalarList dataSlice(fromProc);
273  forAll(dataSlice, i)
274  {
275  label faceI = procFaceOffset[procI] + i;
276  allData[faceI] = dataSlice[i];
277  }
278  }
279 
280  if (writeSurface)
281  {
282  // Time-aware, with time spliced into the output path
283  writerPtr_->beginTime(freqInst);
284 
285  writerPtr_->open
286  (
287  surf.points(),
288  surf.surfFaces(),
289  (outDirBase / fName),
290  false // serial - already merged
291  );
292 
293  writerPtr_->write(title, allData);
294 
295  writerPtr_->endTime();
296  writerPtr_->clear();
297  }
298 
299  // TO BE VERIFIED: area-averaged values
300  // areaAverage = sum(allData*surf.magSf())/sum(surf.magSf());
301  areaAverage = sum(allData)/allData.size();
302  }
303  Pstream::scatter(areaAverage);
304 
305  return areaAverage;
306  }
307  else
308  {
309  const meshedSurface& surf = readerPtr_->geometry();
310 
311  if (writeSurface)
312  {
313  // Time-aware, with time spliced into the output path
314  writerPtr_->beginTime(freqInst);
315 
316  writerPtr_->open
317  (
318  surf.points(),
319  surf.surfFaces(),
320  (outDirBase / fName),
321  false // serial - already merged
322  );
323 
324  writerPtr_->write(title, data);
325 
326  writerPtr_->endTime();
327  writerPtr_->clear();
328  }
329 
330  // TO BE VERIFIED: area-averaged values
331  // return sum(data*surf.magSf())/sum(surf.magSf());
332  return sum(data)/data.size();
333  }
334 }
335 
336 
337 Foam::scalar surfaceNoise::surfaceAverage
338 (
339  const scalarField& data,
340  const labelList& procFaceOffset
341 ) const
342 {
343  if (Pstream::parRun())
344  {
345  // Collect the surface data so that we can output the surfaces
346 
348 
349  if (!Pstream::master())
350  {
351  UOPstream toProc(0, pBufs);
352  toProc << data;
353  }
354 
355  pBufs.finishedSends();
356 
357  scalar areaAverage = 0;
358  if (Pstream::master())
359  {
360  const meshedSurface& surf = readerPtr_->geometry();
361 
362  scalarField allData(surf.size());
363 
364  forAll(data, faceI)
365  {
366  // Master procFaceOffset is zero...
367  allData[faceI] = data[faceI];
368  }
369 
370  for (label procI = 1; procI < Pstream::nProcs(); procI++)
371  {
372  UIPstream fromProc(procI, pBufs);
373  scalarList dataSlice(fromProc);
374  forAll(dataSlice, i)
375  {
376  label faceI = procFaceOffset[procI] + i;
377  allData[faceI] = dataSlice[i];
378  }
379  }
380 
381  // TO BE VERIFIED: area-averaged values
382  // areaAverage = sum(allData*surf.magSf())/sum(surf.magSf());
383  areaAverage = sum(allData)/allData.size();
384  }
385  Pstream::scatter(areaAverage);
386 
387  return areaAverage;
388  }
389  else
390  {
391 
392  // TO BE VERIFIED: area-averaged values
393  // const meshedSurface& surf = readerPtr_->geometry();
394  // return sum(data*surf.magSf())/sum(surf.magSf());
395  return sum(data)/data.size();
396  }
397 }
398 
399 
400 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
401 
403 :
404  noiseModel(dict, false),
405  inputFileNames_(),
406  pName_("p"),
407  pIndex_(0),
408  times_(),
409  deltaT_(0),
410  startTimeIndex_(0),
411  nFace_(0),
412  fftWriteInterval_(1),
413  readerType_(word::null),
414  readerPtr_(nullptr),
415  writerPtr_(nullptr)
416 {
417  if (readFields)
418  {
419  read(dict);
420  }
421 }
422 
423 
424 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
425 
427 {}
428 
429 
430 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
431 
433 {
434  if (noiseModel::read(dict))
435  {
436  if (!dict.readIfPresent("files", inputFileNames_))
437  {
439  dict.readEntry("file", inputFileNames_.first());
440  }
441 
442  dict.readIfPresent("fftWriteInterval", fftWriteInterval_);
443  dict.readIfPresent("p", pName_);
444 
445  readerType_ = dict.get<word>("reader");
446 
447  const word writerType(dict.get<word>("writer"));
448 
450  (
451  writerType,
452  dict.subOrEmptyDict("writeOptions").subOrEmptyDict(writerType)
453  );
454 
455  // Use outputDir/TIME/surface-name
456  writerPtr_->useTimeDir() = true;
457 
458  return true;
459  }
460 
461  return false;
462 }
463 
464 
466 {
467  forAll(inputFileNames_, filei)
468  {
469  fileName fName = inputFileNames_[filei];
470  fName.expand();
471 
472  if (!fName.isAbsolute())
473  {
474  fName = argList::envGlobalPath()/fName;
475  }
476 
477  initialise(fName);
478 
479  // Container for pressure time history data per face
480  List<scalarField> pData;
481 
482  // Processor procFaceOffsets
483  labelList procFaceOffset;
484  if (Pstream::parRun())
485  {
486  const label nProcs = Pstream::nProcs();
487  const label nFacePerProc = floor(nFace_/nProcs) + 1;
488 
489  procFaceOffset.setSize(nProcs + 1, 0);
490  for (label i = 1; i < procFaceOffset.size(); ++i)
491  {
492  procFaceOffset[i] = min(i*nFacePerProc, nFace_);
493  }
494  }
495  else
496  {
497  procFaceOffset.setSize(1, nFace_);
498  }
499 
500  // Read pressure data from file
501  readSurfaceData(procFaceOffset, pData);
502 
503  // Process the pressure data, and store results as surface values per
504  // frequency so that it can be output using the surface writer
505 
506  Info<< "Creating noise FFTs" << endl;
507 
509 
510  // Reset desired frequency range if outside actual frequency range
511  fLower_ = min(fLower_, max(freq1));
512  fUpper_ = min(fUpper_, max(freq1));
513 
514  // Storage for FFT data
515  const label nLocalFace = pData.size();
516  const label nFFT = ceil(freq1.size()/scalar(fftWriteInterval_));
517 
518  List<scalarField> surfPrmsf(nFFT);
519  List<scalarField> surfPSDf(nFFT);
520  forAll(surfPrmsf, freqI)
521  {
522  surfPrmsf[freqI].setSize(nLocalFace);
523  surfPSDf[freqI].setSize(nLocalFace);
524  }
525 
526  // Storage for 1/3 octave data
527  labelList octave13BandIDs;
528  scalarField octave13FreqCentre;
530  (
531  freq1,
532  fLower_,
533  fUpper_,
534  3,
535  octave13BandIDs,
536  octave13FreqCentre
537  );
538 
539  label bandSize = 0;
540  if (octave13BandIDs.empty())
541  {
543  << "Octave band calculation failed (zero sized). "
544  << "Please check your input data"
545  << endl;
546  }
547  else
548  {
549  bandSize = octave13BandIDs.size() - 1;
550  }
551 
552  List<scalarField> surfPrms13f(bandSize);
553  forAll(surfPrms13f, freqI)
554  {
555  surfPrms13f[freqI].setSize(nLocalFace);
556  }
557 
558  const windowModel& win = windowModelPtr_();
559 
560  {
561  noiseFFT nfft(deltaT_, win.nSamples());
562 
563  forAll(pData, faceI)
564  {
565  // Note: passes storage from pData to noiseFFT
566  nfft.setData(pData[faceI]);
567 
568  // Generate the FFT-based data
569  graph Prmsf(nfft.RMSmeanPf(win));
570  graph PSDf(nfft.PSDf(win));
571 
572  // Store the frequency results in slot for face of surface
573  forAll(surfPrmsf, i)
574  {
575  label freqI = i*fftWriteInterval_;
576  surfPrmsf[i][faceI] = Prmsf.y()[freqI];
577  surfPSDf[i][faceI] = PSDf.y()[freqI];
578  }
579 
580  // Integrated PSD = P(rms)^2 [Pa^2]
581  graph Prms13f(nfft.octaves(PSDf, octave13BandIDs));
582 
583  // Store the 1/3 octave results in slot for face of surface
584  forAll(surfPrms13f, freqI)
585  {
586  surfPrms13f[freqI][faceI] = Prms13f.y()[freqI];
587  }
588  }
589  }
590 
591  const word fNameBase = fName.nameLessExt();
592 
593  // Output directory for graphs
594  fileName outDirBase(baseFileDir(filei)/fNameBase);
595 
596  const scalar deltaf = 1.0/(deltaT_*win.nSamples());
597  Info<< "Writing fft surface data";
598  if (fftWriteInterval_ == 1)
599  {
600  Info<< endl;
601  }
602  else
603  {
604  Info<< " at every " << fftWriteInterval_ << " frequency points"
605  << endl;
606  }
607 
608  {
609  fileName outDir(outDirBase/"fft");
610 
611  // Determine frequency range of interest
612  // Note: frequencies have fixed interval, and are in the range
613  // 0 to fftWriteInterval_*(n-1)*deltaf
614  label f0 = ceil(fLower_/deltaf/scalar(fftWriteInterval_));
615  label f1 = floor(fUpper_/deltaf/scalar(fftWriteInterval_));
616  label nFreq = f1 - f0;
617 
618  scalarField PrmsfAve(nFreq, Zero);
619  scalarField PSDfAve(nFreq, Zero);
620  scalarField fOut(nFreq, Zero);
621 
622  if (nFreq == 0)
623  {
625  << "No surface data available using a fftWriteInterval of "
626  << fftWriteInterval_ << endl;
627  }
628  else
629  {
630  forAll(fOut, i)
631  {
632  label freqI = (i + f0)*fftWriteInterval_;
633  fOut[i] = freq1[freqI];
634 
635 
636  PrmsfAve[i] = writeSurfaceData
637  (
638  outDir,
639  fNameBase,
640  "Prmsf",
641  freq1[freqI],
642  surfPrmsf[i + f0],
643  procFaceOffset,
645  );
646 
647  PSDfAve[i] = writeSurfaceData
648  (
649  outDir,
650  fNameBase,
651  "PSDf",
652  freq1[freqI],
653  surfPSDf[i + f0],
654  procFaceOffset,
655  writePSDf_
656  );
658  (
659  outDir,
660  fNameBase,
661  "PSD",
662  freq1[freqI],
663  noiseFFT::PSD(surfPSDf[i + f0]),
664  procFaceOffset,
665  writePSD_
666  );
668  (
669  outDir,
670  fNameBase,
671  "SPL",
672  freq1[freqI],
673  noiseFFT::SPL(surfPSDf[i + f0]*deltaf),
674  procFaceOffset,
675  writeSPL_
676  );
677  }
678  }
679 
680  if (Pstream::master())
681  {
682  graph Prmsfg
683  (
684  "Average Prms(f)",
685  "f [Hz]",
686  "P(f) [Pa]",
687  fOut,
688  PrmsfAve
689  );
690  Prmsfg.write
691  (
692  outDir,
693  graph::wordify(Prmsfg.title()),
695  );
696 
697  graph PSDfg
698  (
699  "Average PSD_f(f)",
700  "f [Hz]",
701  "PSD(f) [PaPa_Hz]",
702  fOut,
703  PSDfAve
704  );
705  PSDfg.write
706  (
707  outDir,
708  graph::wordify(PSDfg.title()),
710  );
711 
712  graph PSDg
713  (
714  "Average PSD_dB_Hz(f)",
715  "f [Hz]",
716  "PSD(f) [dB_Hz]",
717  fOut,
718  noiseFFT::PSD(PSDfAve)
719  );
720  PSDg.write
721  (
722  outDir,
723  graph::wordify(PSDg.title()),
725  );
726 
727  graph SPLg
728  (
729  "Average SPL_dB(f)",
730  "f [Hz]",
731  "SPL(f) [dB]",
732  fOut,
733  noiseFFT::SPL(PSDfAve*deltaf)
734  );
735  SPLg.write
736  (
737  outDir,
738  graph::wordify(SPLg.title()),
740  );
741  }
742  }
743 
744 
745  Info<< "Writing one-third octave surface data" << endl;
746  {
747  fileName outDir(outDirBase/"oneThirdOctave");
748 
749  scalarField PSDfAve(surfPrms13f.size(), Zero);
750  scalarField Prms13fAve(surfPrms13f.size(), Zero);
751 
752  forAll(surfPrms13f, i)
753  {
755  (
756  outDir,
757  fNameBase,
758  "SPL13",
759  octave13FreqCentre[i],
760  noiseFFT::SPL(surfPrms13f[i]),
761  procFaceOffset,
763  );
764 
765  Prms13fAve[i] =
766  surfaceAverage(surfPrms13f[i], procFaceOffset);
767  }
768 
769  if (Pstream::master())
770  {
771  graph SPL13g
772  (
773  "Average SPL13_dB(fm)",
774  "fm [Hz]",
775  "SPL(fm) [dB]",
776  octave13FreqCentre,
777  noiseFFT::SPL(Prms13fAve)
778  );
779  SPL13g.write
780  (
781  outDir,
782  graph::wordify(SPL13g.title()),
784  );
785  }
786  }
787  }
788 }
789 
790 
791 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
792 
793 } // End namespace noiseModels
794 } // End namespace Foam
795 
796 // ************************************************************************* //
Foam::graph::title
const string & title() const
Definition: graph.H:152
Foam::noiseModel::checkUniformTimeStep
scalar checkUniformTimeStep(const scalarList &times) const
Check and return uniform time step.
Definition: noiseModel.C:66
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::UPstream::commsTypes::nonBlocking
Foam::noiseModel::read
virtual bool read(const dictionary &dict)
Read from dictionary.
Definition: noiseModel.C:189
Foam::noiseModels::surfaceNoise::nFace_
label nFace_
Number of surface faces.
Definition: surfaceNoise.H:154
Foam::graph
Class to create, store and output qgraph files.
Definition: graph.H:61
Foam::fileName::nameLessExt
static std::string nameLessExt(const std::string &str)
Return basename, without extension.
Definition: fileName.C:402
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::UOPstream
Output inter-processor communications stream operating on external buffer.
Definition: UOPstream.H:57
Foam::noiseFFT::octaveBandInfo
static void octaveBandInfo(const scalarField &f, const scalar fLower, const scalar fUpper, const scalar octave, labelList &fBandIDs, scalarField &fCentre)
Return a list of the frequency indices wrt f field that.
Definition: noiseFFT.C:75
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::noiseModel
Base class for noise models.
Definition: noiseModel.H:158
Foam::noiseFFT
Performs FFT of pressure field to generate noise data.
Definition: noiseFFT.H:69
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:94
Foam::argList::envGlobalPath
static fileName envGlobalPath()
Global case (directory) from environment variable.
Definition: argList.C:513
Foam::graph::wordify
static word wordify(const string &sname)
Helper function to convert string name into appropriate word.
Definition: graph.C:48
Foam::noiseModels::surfaceNoise::surfaceAverage
scalar surfaceAverage(const scalarField &data, const labelList &procFaceOffset) const
Calculate the area average value.
Definition: surfaceNoise.C:338
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
Foam::surfaceReader::New
static autoPtr< surfaceReader > New(const word &readType, const fileName &fName)
Return a reference to the selected surfaceReader.
Definition: surfaceReaderNew.C:33
Foam::noiseModel::fUpper_
scalar fUpper_
Upper frequency limit, default = 10kHz.
Definition: noiseModel.H:177
Foam::noiseModels::surfaceNoise::times_
scalarList times_
Sample times.
Definition: surfaceNoise.H:145
Foam::UPstream::nProcs
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Definition: UPstream.H:426
Foam::PstreamBuffers
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Definition: PstreamBuffers.H:88
Foam::noiseModels::surfaceNoise::pIndex_
label pIndex_
Index of pressure field in reader field list.
Definition: surfaceNoise.H:142
Foam::UPstream::parRun
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:414
noiseFFT.H
Foam::MeshedSurface::surfFaces
const List< Face > & surfFaces() const
Return const access to the faces.
Definition: MeshedSurface.H:362
Foam::Pstream::scatter
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
Definition: gatherScatter.C:150
Foam::noiseModels::defineTypeNameAndDebug
defineTypeNameAndDebug(pointNoise, 0)
Foam::noiseModels::surfaceNoise::calculate
virtual void calculate()
Calculate.
Definition: surfaceNoise.C:465
Foam::noiseModel::findStartTimeIndex
label findStartTimeIndex(const instantList &allTimes, const scalar startTime) const
Find and return start time index.
Definition: noiseModel.C:125
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::noiseModels::surfaceNoise::read
virtual bool read(const dictionary &dict)
Read from dictionary.
Definition: surfaceNoise.C:432
surfaceWriter.H
Foam::PstreamBuffers::clear
void clear()
Clear storage and reset.
Definition: PstreamBuffers.C:130
surfaceReader.H
Foam::noiseModel::fLower_
scalar fLower_
Lower frequency limit, default = 25Hz.
Definition: noiseModel.H:174
Foam::noiseModels::surfaceNoise::writeSurfaceData
scalar writeSurfaceData(const fileName &outDirBase, const word &fName, const word &title, const scalar freq, const scalarField &data, const labelList &procFaceOffset, const bool writeSurface) const
Write surface data to file.
Definition: surfaceNoise.C:228
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
Foam::noiseModels::surfaceNoise::pName_
word pName_
Name of pressure field.
Definition: surfaceNoise.H:139
Foam::noiseModels::surfaceNoise::surfaceNoise
surfaceNoise(const dictionary &dict, const bool readFields=true)
Constructor.
Definition: surfaceNoise.C:402
Foam::sumOp
Definition: ops.H:213
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::noiseFFT::PSD
static tmp< scalarField > PSD(const scalarField &PSDf)
Return the PSD [dB/Hz].
Definition: noiseFFT.C:62
Foam::noiseModels::surfaceNoise::~surfaceNoise
virtual ~surfaceNoise()
Destructor.
Definition: surfaceNoise.C:426
Foam::noiseModels::surfaceNoise::deltaT_
scalar deltaT_
Time step (constant)
Definition: surfaceNoise.H:148
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::Field< scalar >
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::noiseModel::windowModelPtr_
autoPtr< windowModel > windowModelPtr_
Window model.
Definition: noiseModel.H:186
Foam::noiseModel::writeOctaves_
bool writeOctaves_
Write writeOctaves; default = yes.
Definition: noiseModel.H:219
argList.H
Foam::noiseModel::startTime_
scalar startTime_
Start time, default = 0s.
Definition: noiseModel.H:183
Foam::noiseModel::writePSD_
bool writePSD_
Write PSD; default = yes.
Definition: noiseModel.H:213
Foam::noiseModels::surfaceNoise::startTimeIndex_
label startTimeIndex_
Start time index.
Definition: surfaceNoise.H:151
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::List::resize
void resize(const label newSize)
Adjust allocated size of list.
Definition: ListI.H:139
Foam::PstreamBuffers::finishedSends
void finishedSends(const bool block=true)
Mark all sends as having been done. This will start receives.
Definition: PstreamBuffers.C:80
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::graph::write
void write(Ostream &, const word &format) const
Write graph to stream in given format.
Definition: graph.C:267
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::noiseFFT::frequencies
static tmp< scalarField > frequencies(const label N, const scalar deltaT)
Return the FFT frequencies.
Definition: noiseFFT.C:44
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::noiseModel::writePSDf_
bool writePSDf_
Write PSDf; default = yes.
Definition: noiseModel.H:216
Foam::noiseModel::writePrmsf_
bool writePrmsf_
Write Prmsf; default = yes.
Definition: noiseModel.H:207
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::readFields
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
Definition: ReadFieldsTemplates.C:312
Foam::UPstream::myProcNo
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:444
Foam::UPstream::master
static bool master(const label communicator=0)
Am I the master process.
Definition: UPstream.H:438
Foam::noiseModels::surfaceNoise::fftWriteInterval_
label fftWriteInterval_
Frequency data output interval, default = 1.
Definition: surfaceNoise.H:159
Foam::noiseModels::surfaceNoise::readerPtr_
autoPtr< surfaceReader > readerPtr_
Pointer to the surface reader.
Definition: surfaceNoise.H:165
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
Foam::nl
constexpr char nl
Definition: Ostream.H:372
Foam::noiseModels::surfaceNoise::readerType_
word readerType_
Reader type.
Definition: surfaceNoise.H:162
Foam::surfaceWriter::New
static autoPtr< surfaceWriter > New(const word &writeType)
Return a reference to the selected surfaceWriter.
Definition: surfaceWriter.C:64
Foam::List< word >
Foam::noiseModel::baseFileDir
fileName baseFileDir(const label dataseti) const
Return the base output directory.
Definition: noiseModel.C:144
Foam::string::expand
string & expand(const bool allowEmpty=false)
Definition: string.C:159
Foam::List::clear
void clear()
Clear the list, i.e. set size to zero.
Definition: ListI.H:115
Foam::sum
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:327
graph.H
Foam::windowModel::nSamples
label nSamples() const
Return the number of samples in the window.
Definition: windowModel.C:56
Foam::instant
An instant of time. Contains the time value and name.
Definition: instant.H:52
surfaceNoise.H
Foam::noiseModels::surfaceNoise::readSurfaceData
void readSurfaceData(const labelList &procFaceOffset, List< scalarField > &pData)
Read surface data.
Definition: surfaceNoise.C:118
Foam::UIPstream
Input inter-processor communications stream operating on external buffer.
Definition: UIPstream.H:56
Foam::List::setSize
void setSize(const label newSize)
Alias for resize(const label)
Definition: ListI.H:146
Foam::noiseModel::graphFormat_
word graphFormat_
Graph format.
Definition: noiseModel.H:189
Foam::MeshedSurface< face >
Foam::noiseModels::surfaceNoise::initialise
void initialise(const fileName &fName)
Initialise.
Definition: surfaceNoise.C:50
Foam::windowModel
Base class for windowing models.
Definition: windowModel.H:52
Foam::MeshedSurface::size
label size() const
The surface size is the number of faces.
Definition: MeshedSurface.H:356
Foam::noiseModels::surfaceNoise::inputFileNames_
List< fileName > inputFileNames_
Input file names.
Definition: surfaceNoise.H:136
Foam::noiseModels::addToRunTimeSelectionTable
addToRunTimeSelectionTable(noiseModel, pointNoise, dictionary)
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:294
Foam::noiseModel::writeSPL_
bool writeSPL_
Write SPL; default = yes.
Definition: noiseModel.H:210
Foam::data
Database for solution data, solver performance and other reduced data.
Definition: data.H:54
Foam::fileName::isAbsolute
static bool isAbsolute(const std::string &str)
Return true if string starts with a '/'.
Definition: fileNameI.H:136
Foam::noiseModel::nSamples_
label nSamples_
Number of samples in sampling window, default = 2^16.
Definition: noiseModel.H:171
Foam::noiseFFT::SPL
static tmp< scalarField > SPL(const scalarField &Prms2)
Return the SPL [dB].
Definition: noiseFFT.C:68
Foam::noiseModels::surfaceNoise::writerPtr_
autoPtr< surfaceWriter > writerPtr_
Pointer to the surface writer.
Definition: surfaceNoise.H:168