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

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

#include <acapostprocessing.hpp>

Inheritance diagram for AcaPostProcessingOASPL< nDim >:
[legend]
Collaboration diagram for AcaPostProcessingOASPL< 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_oaspl
 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 AcaPostProcessingOASPL< nDim >

Definition at line 10 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 AcaPostProcessingOASPL< nDim >::calc ( const MInt  observerId,
const MFloat *const  data,
const MFloat *const  dataComplex = nullptr 
)
overridevirtual

Implements AcaPostProcessing.

Definition at line 36 of file acapostprocessing.hpp.

37 {
38 // Calculation of overall sound pressure level using p_rms (could also be computed by the sum of
39 // spl over all frequencies)
40 MFloat p_rms = 0.0;
41 for(MInt t = 0; t < m_noSamples; t++) {
42 p_rms += POW2(data[t]);
43 }
44 p_rms = p_rms / m_noSamples;
45 // Calculate overall sound pressure level for this observer
46 m_oaspl[observerId] = 10.0 * log10(p_rms / m_pRefSq);
47}
MInt m_noSamples
MFloat m_pRefSq
std::vector< MFloat > m_oaspl
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 AcaPostProcessingOASPL< nDim >::finish
overridevirtual

Implements AcaPostProcessing.

Definition at line 50 of file acapostprocessing.hpp.

50 {
51 using namespace maia::parallel_io;
52 ParallelIo file(m_fileNameIoParallel, PIO_REPLACE, m_mpiComm);
53 ParallelIo::size_type dimSizesCoordinates[] = {m_noGlobalObservers, nDim};
54 file.defineArray(PIO_FLOAT, "coordinates", 2, &dimSizesCoordinates[0]);
55 file.defineArray(PIO_FLOAT, "OASPL", m_noGlobalObservers);
56
57 const MBool isRoot = (m_rank == 0);
58 file.setOffset((isRoot) ? m_noGlobalObservers : 0, 0, 2);
59 file.writeArray(m_coords, "coordinates");
60 file.setOffset(m_noObservers, m_offsetObserver);
61 file.writeArray(m_oaspl.data(), "OASPL");
62}
MInt m_noGlobalObservers
MInt m_offsetObserver
const MFloat * m_coords
MInt m_noObservers
MString m_fileNameIoParallel
bool MBool
Definition: maiatypes.h:58
PARALLELIO_DEFAULT_BACKEND ParallelIo
Definition: parallelio.h:292

◆ init_()

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

Implements AcaPostProcessing.

Definition at line 25 of file acapostprocessing.hpp.

25 {
26 m_fileNameIoParallel = m_outPath + "OASPL" + ParallelIo::fileExt();
27 m_oaspl.resize(m_noObservers, 0.0);
28
29 constexpr MFloat pRefDim = 2e-5; // [Pa]
30 MFloat pInftyDim = 101325; // [Pa] = (rho_infty * a_infty^2 ) / gamma
31 pInftyDim = Context::getBasicProperty<MFloat>("pInftyDimensional", AT_, &pInftyDim);
32 m_pRefSq = POW2(pRefDim / (m_gamma * pInftyDim)); // [-]
33}
MString m_outPath
const MFloat m_gamma

Member Data Documentation

◆ m_fileNameIoParallel

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

Definition at line 12 of file acapostprocessing.hpp.

◆ m_gamma

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

Definition at line 14 of file acapostprocessing.hpp.

◆ m_oaspl

template<MInt nDim>
std::vector<MFloat> AcaPostProcessingOASPL< nDim >::m_oaspl
private

Definition at line 15 of file acapostprocessing.hpp.

◆ m_pRefSq

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

Definition at line 13 of file acapostprocessing.hpp.


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