19 void init_()
override;
20 void calc(
const MInt observerId,
const MFloat*
const data,
const MFloat*
const dataComplex =
nullptr)
override;
26 m_fileNameIoParallel = m_outPath +
"OASPL" + ParallelIo::fileExt();
27 m_oaspl.resize(m_noObservers, 0.0);
29 constexpr MFloat pRefDim = 2e-5;
31 pInftyDim = Context::getBasicProperty<MFloat>(
"pInftyDimensional", AT_, &pInftyDim);
32 m_pRefSq =
POW2(pRefDim / (m_gamma * pInftyDim));
41 for(
MInt t = 0; t < m_noSamples; t++) {
42 p_rms +=
POW2(data[t]);
44 p_rms = p_rms / m_noSamples;
46 m_oaspl[observerId] = 10.0 * log10(p_rms / m_pRefSq);
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);
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");
75 void init_()
override;
76 void calc(
const MInt observerId,
const MFloat*
const data,
const MFloat*
const dataComplex =
nullptr)
override;
82 m_fileNameIoParallel = m_outPath +
"pressABS" + ParallelIo::fileExt();
83 m_pabs.resize(m_noObservers * m_noSamples, 0.0);
88 const MFloat*
const dataComplex) {
89 const MInt offset = observerId * m_noSamples;
90 for(
MInt t = 1; t < m_noSamples; t++) {
91 const MFloat real = dataComplex[t * 2 + 0];
92 const MFloat imag = dataComplex[t * 2 + 1];
96 m_pabs[offset + t] = 2 * sqrt(p_magnSq);
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]);
109 const MBool isRoot = (m_rank == 0);
110 file.setOffset((isRoot) ? m_noGlobalObservers : 0, 0, 2);
111 file.writeArray(m_coords,
"coordinates");
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];
120 file.writeArray(pressABS.
data(),
"pressABS");
135 void init_()
override;
136 void calc(
const MInt observerId,
const MFloat*
const data,
const MFloat*
const dataComplex =
nullptr)
override;
142 m_fileNameIoParallel = m_outPath +
"RMSpressure" + ParallelIo::fileExt();
143 m_fileNameIoDat = m_outPath +
"RMS.dat";
144 m_prms.resize(m_noGlobalObservers, 0.0);
151 m_prms[m_offsetObserver + observerId] = 0;
152 for(
MInt t = 0; t < m_noSamples; t++) {
153 m_prms[m_offsetObserver + observerId] +=
POW2(data[t]);
155 m_prms[m_offsetObserver + observerId] = sqrt(m_prms[m_offsetObserver + observerId] / m_noSamples);
160 constexpr MInt rootId = 0;
162 ParallelIo file(m_fileNameIoParallel, PIO_REPLACE, m_mpiComm);
163 ParallelIo::size_type dimSizesCoordinates[] = {m_noGlobalObservers, nDim};
164 file.defineArray(PIO_FLOAT,
"coordinates", 2, &dimSizesCoordinates[0]);
165 file.defineArray(PIO_FLOAT,
"rms_pressure", m_noGlobalObservers);
167 const MBool isRoot = (m_rank == rootId);
168 file.setOffset((isRoot) ? m_noGlobalObservers : 0, 0, 2);
169 file.writeArray(m_coords,
"coordinates");
172 m_mpiComm, AT_,
"MPI_IN_PLACE",
"m_prms");
174 std::ofstream outfile;
175 outfile.open(m_fileNameIoDat);
176 if constexpr(nDim == 2) {
177 outfile <<
"# obs:1 x:2 y:3 theta:4 p_rms:5" << std::endl;
178 for(
MInt obs = 0; obs < m_noGlobalObservers; obs++) {
179 const MFloat*
const obsCoord = &m_coords[nDim * obs];
180 const MFloat theta = atan2(obsCoord[1], obsCoord[0]);
181 outfile << obs <<
" " << obsCoord[0] <<
" " << obsCoord[1] <<
" " << theta <<
" " << m_prms[obs] << std::endl;
183 }
else if constexpr(nDim == 3) {
184 outfile <<
"# obs:1 x:2 y:3 z:4 theta:5 alpha:6 p_rms:7" << std::endl;
185 for(
MInt obs = 0; obs < m_noGlobalObservers; obs++) {
186 const MFloat*
const obsCoord = &m_coords[nDim * obs];
188 const MFloat theta = atan2(obsCoord[2], obsCoord[0]);
189 const MFloat alpha = asin(obsCoord[1] /
dist);
190 outfile << obs <<
" " << obsCoord[0] <<
" " << obsCoord[1] <<
" " << obsCoord[2] <<
" " << theta <<
" " << alpha
191 <<
" " << m_prms[obs] << std::endl;
195 file.setOffset(m_noGlobalObservers, 0);
198 m_mpiComm, AT_,
"MPI_IN_PLACE",
"m_prms");
199 file.setOffset(0, 0);
201 file.writeArray(m_prms.data(),
"rms_pressure");
217 void init_()
override;
218 void calc(
const MInt observerId,
const MFloat*
const data,
const MFloat*
const dataComplex =
nullptr)
override;
224 m_fileNameIoParallel = m_outPath +
"SPL" + ParallelIo::fileExt();
237 constexpr MFloat pRefDim = 2e-5;
238 MFloat pInftyDim = 101325;
239 pInftyDim = Context::getBasicProperty<MFloat>(
"pInftyDimensional", AT_, &pInftyDim);
240 m_pRefSq =
POW2(pRefDim / (m_gamma * pInftyDim));
242 m_spl.resize(m_noObservers * m_noSamples, 0.0);
247 const MFloat*
const dataComplex) {
249 const MInt offset = observerId * m_noSamples;
250 for(
MInt t = 1; t < m_noSamples; t++) {
251 const MFloat real = dataComplex[t * 2 + 0];
252 const MFloat imag = dataComplex[t * 2 + 1];
259 m_spl[offset + t] = 10 * log10(2 * pSq / m_pRefSq);
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]);
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");
Abstract class for ACA post processing.
AcaPostProcessing(const MPI_Comm comm)
ACA post processing class for overall sound pressure calculation.
std::vector< MFloat > m_oaspl
isentropic exponent
MString m_fileNameIoParallel
void calc(const MInt observerId, const MFloat *const data, const MFloat *const dataComplex=nullptr) override
ACA post processing class for absoulte pressure calculation.
std::vector< MFloat > m_pabs
void calc(const MInt observerId, const MFloat *const data, const MFloat *const dataComplex=nullptr) override
MString m_fileNameIoParallel
ACA post processing class for calculation of root mean square pressure.
void calc(const MInt observerId, const MFloat *const data, const MFloat *const dataComplex=nullptr) override
MString m_fileNameIoParallel
std::vector< MFloat > m_prms
ACA post processing class for sound pressure level calculation.
MString m_fileNameIoParallel
std::vector< MFloat > m_spl
isentropic exponent
void calc(const MInt observerId, const MFloat *const data, const MFloat *const dataComplex=nullptr) override
This class is a ScratchSpace.
constexpr Real POW2(const Real x)
std::basic_string< char > MString
int MPI_Reduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm, const MString &name, const MString &sndvarname, const MString &rcvvarname)
same as MPI_Reduce
PARALLELIO_DEFAULT_BACKEND ParallelIo
MFloat dist(const Point< DIM > &p, const Point< DIM > &q)