MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
AcaPostProcessingSPL< nDim > Class Template Reference

ACA post processing class for sound pressure level calculation. More...

#include <acapostprocessing.hpp>

Inheritance diagram for AcaPostProcessingSPL< nDim >:
[legend]
Collaboration diagram for AcaPostProcessingSPL< nDim >:
[legend]

Public Member Functions

void init_ () override
 
void calc (const MInt observerId, const MFloat *const data, const MFloat *const dataComplex=nullptr) override
 
void finish () override
 
 AcaPostProcessing (const MPI_Comm comm)
 
- Public Member Functions inherited from AcaPostProcessing
 AcaPostProcessing (const MPI_Comm comm)
 
virtual ~AcaPostProcessing ()=default
 
virtual void init_ ()=0
 
void init (const MInt noObservers, const MInt noGlobalObservers, const MInt offsetObserver, const MInt noSamples, const MFloat *const coords, const MFloat *const frequencies, const MString outPath)
 
virtual void calc (const MInt observerId, const MFloat *const data, const MFloat *const dataComplex=nullptr)=0
 
virtual void finish ()=0
 

Private Attributes

MString m_fileNameIoParallel
 
MFloat m_pRefSq = -1.0
 
const MFloat m_gamma = 1.4
 
std::vector< MFloatm_spl
 isentropic exponent More...
 

Additional Inherited Members

- Protected Attributes inherited from AcaPostProcessing
MPI_Comm m_mpiComm
 
MInt m_rank
 
MInt m_noObservers = -1
 
MInt m_noGlobalObservers = -1
 
MInt m_offsetObserver = 0
 
MInt m_noSamples = -1
 
MString m_outPath
 
const MFloatm_coords = nullptr
 
const MFloatm_frequencies = nullptr
 

Detailed Description

template<MInt nDim>
class AcaPostProcessingSPL< nDim >

Definition at line 208 of file acapostprocessing.hpp.

Member Function Documentation

◆ AcaPostProcessing()

template<MInt nDim>
AcaPostProcessing::AcaPostProcessing ( const MPI_Comm  comm)
inline

Definition at line 25 of file acapostprocessing.h.

25: m_mpiComm(comm) { MPI_Comm_rank(m_mpiComm, &m_rank); }
MPI_Comm m_mpiComm
MInt m_rank

◆ calc()

template<MInt nDim>
void AcaPostProcessingSPL< nDim >::calc ( const MInt  observerId,
const MFloat *const  data,
const MFloat *const  dataComplex = nullptr 
)
overridevirtual

Implements AcaPostProcessing.

Definition at line 246 of file acapostprocessing.hpp.

247 {
248 // Calculation of sound pressure level (pressure at each frequency)
249 const MInt offset = observerId * m_noSamples;
250 for(MInt t = 1; t < m_noSamples; t++) { // Skip frequency 0
251 const MFloat real = dataComplex[t * 2 + 0];
252 const MFloat imag = dataComplex[t * 2 + 1];
253 // p times p complex conjugate = p_re_sq + p_imag_sq
254 const MFloat pSq = POW2(real) + POW2(imag);
255 // Sound pressure for each observer point for each frequency
256 // Ref.: Mendez et al. (2013): https://doi.org/10.1260%2F1475-472X.12.1-2.1
257 // or Beranek and Ver (1992); Delfs, Basics of Aeroacoustics (2016); ...
258 // Remind: 20 * log(a) = 10 * log(a^2), and pSq is only halved value because of FFT
259 m_spl[offset + t] = 10 * log10(2 * pSq / m_pRefSq);
260 }
261}
MInt m_noSamples
MFloat m_pRefSq
std::vector< MFloat > m_spl
isentropic exponent
constexpr Real POW2(const Real x)
Definition: functions.h:119
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52

◆ finish()

template<MInt nDim>
void AcaPostProcessingSPL< nDim >::finish
overridevirtual

Implements AcaPostProcessing.

Definition at line 264 of file acapostprocessing.hpp.

264 {
265 using namespace maia::parallel_io;
266 ParallelIo file(m_fileNameIoParallel, PIO_REPLACE, m_mpiComm);
267 ParallelIo::size_type dimSizesCoordinates[] = {m_noGlobalObservers, nDim};
268 ParallelIo::size_type dimSizesSpl[] = {m_noGlobalObservers, m_noSamples};
269 file.defineArray(PIO_FLOAT, "coordinates", 2, &dimSizesCoordinates[0]);
270 file.defineArray(PIO_FLOAT, "frequency", m_noSamples);
271 file.defineArray(PIO_FLOAT, "SPL", 2, &dimSizesSpl[0]);
272
273 const MBool isRoot = (m_rank == 0);
274 file.setOffset((isRoot) ? m_noGlobalObservers : 0, 0, 2);
275 file.writeArray(m_coords, "coordinates");
276 file.setOffset((isRoot) ? m_noSamples : 0, 0);
277 file.writeArray(m_frequencies, "frequency");
278 file.setOffset(m_noObservers, m_offsetObserver, 2);
279 file.writeArray(m_spl.data(), "SPL");
280}
MInt m_noGlobalObservers
MInt m_offsetObserver
const MFloat * m_coords
MInt m_noObservers
const MFloat * m_frequencies
MString m_fileNameIoParallel
bool MBool
Definition: maiatypes.h:58
PARALLELIO_DEFAULT_BACKEND ParallelIo
Definition: parallelio.h:292

◆ init_()

template<MInt nDim>
void AcaPostProcessingSPL< nDim >::init_
overridevirtual

Implements AcaPostProcessing.

Definition at line 226 of file acapostprocessing.hpp.

Member Data Documentation

◆ m_fileNameIoParallel

template<MInt nDim>
MString AcaPostProcessingSPL< nDim >::m_fileNameIoParallel
private

Definition at line 210 of file acapostprocessing.hpp.

◆ m_gamma

template<MInt nDim>
const MFloat AcaPostProcessingSPL< nDim >::m_gamma = 1.4
private

Definition at line 212 of file acapostprocessing.hpp.

◆ m_pRefSq

template<MInt nDim>
MFloat AcaPostProcessingSPL< nDim >::m_pRefSq = -1.0
private

Definition at line 211 of file acapostprocessing.hpp.

◆ m_spl

template<MInt nDim>
std::vector<MFloat> AcaPostProcessingSPL< nDim >::m_spl
private

Definition at line 213 of file acapostprocessing.hpp.


The documentation for this class was generated from the following file: