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

ACA post processing class for absoulte pressure calculation. More...

#include <acapostprocessing.hpp>

Inheritance diagram for AcaPostProcessingPABS< nDim >:
[legend]
Collaboration diagram for AcaPostProcessingPABS< 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
 
std::vector< MFloatm_pabs
 

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 AcaPostProcessingPABS< nDim >

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

Implements AcaPostProcessing.

Definition at line 87 of file acapostprocessing.hpp.

88 {
89 const MInt offset = observerId * m_noSamples;
90 for(MInt t = 1; t < m_noSamples; t++) { // Skip frequency 0
91 const MFloat real = dataComplex[t * 2 + 0];
92 const MFloat imag = dataComplex[t * 2 + 1];
93 // product of p * p_complex_conjugate = p_re_sq + p_im_sq = [abs(p)]^2
94 const MFloat p_magnSq = POW2(real) + POW2(imag);
95 // Absolute pressure
96 m_pabs[offset + t] = 2 * sqrt(p_magnSq);
97 }
98}
MInt m_noSamples
std::vector< MFloat > m_pabs
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 AcaPostProcessingPABS< nDim >::finish
overridevirtual

Implements AcaPostProcessing.

Definition at line 101 of file acapostprocessing.hpp.

101 {
102 using namespace maia::parallel_io;
103 ParallelIo file(m_fileNameIoParallel, PIO_REPLACE, m_mpiComm);
104 ParallelIo::size_type dimSizesCoordinates[] = {m_noGlobalObservers, nDim};
105 ParallelIo::size_type dimSizes[] = {m_noGlobalObservers, m_noSamples};
106 file.defineArray(PIO_FLOAT, "coordinates", 2, &dimSizesCoordinates[0]);
107 file.defineArray(PIO_FLOAT, "pressABS", 2, &dimSizes[0]);
108
109 const MBool isRoot = (m_rank == 0);
110 file.setOffset((isRoot) ? m_noGlobalObservers : 0, 0, 2);
111 file.writeArray(m_coords, "coordinates");
112 ScratchSpace<MFloat> pressABS(m_noObservers, m_noSamples, AT_, "pressABS");
113 file.setOffset(m_noObservers, m_offsetObserver, 2);
114 for(MInt obs = 0; obs < m_noObservers; obs++) {
115 const MInt offset = obs * m_noSamples;
116 for(MInt t = 0; t < m_noSamples; t++) {
117 pressABS(obs, t) = m_pabs[offset + t];
118 }
119 }
120 file.writeArray(pressABS.data(), "pressABS");
121}
MInt m_noGlobalObservers
MInt m_offsetObserver
const MFloat * m_coords
MInt m_noObservers
MString m_fileNameIoParallel
This class is a ScratchSpace.
Definition: scratch.h:758
bool MBool
Definition: maiatypes.h:58
PARALLELIO_DEFAULT_BACKEND ParallelIo
Definition: parallelio.h:292

◆ init_()

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

Implements AcaPostProcessing.

Definition at line 81 of file acapostprocessing.hpp.

81 {
82 m_fileNameIoParallel = m_outPath + "pressABS" + ParallelIo::fileExt();
83 m_pabs.resize(m_noObservers * m_noSamples, 0.0);
84}
MString m_outPath

Member Data Documentation

◆ m_fileNameIoParallel

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

Definition at line 70 of file acapostprocessing.hpp.

◆ m_pabs

template<MInt nDim>
std::vector<MFloat> AcaPostProcessingPABS< nDim >::m_pabs
private

Definition at line 71 of file acapostprocessing.hpp.


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