MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
postprocessinglb.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 The m-AIA AUTHORS
2//
3// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4//
5// SPDX-License-Identifier: LGPL-3.0-only
6
7#include "postprocessinglb.h"
8//#include "postprocessing.h"
9#include "postdata.h"
10#include "postprocessing.cpp"
11
12using namespace std;
13
14template <MInt nDim>
16 : PostProcessingInterface(postprocessingId_), PostProcessing<nDim, PostProcessingLb<nDim>>(postprocessingId_, data) {
17 m_ppSolver = ppSolver_;
18}
19
20template <MInt nDim>
22
23template <MInt nDim>
25 TRACE();
26
27 m_pointData.reset(new PointData<nDim, SolverType>{*m_ppSolver});
28 m_pointData->setInputOutputProperties();
29 m_pointData->init();
30}
31
32template <MInt nDim>
34 m_pointData->save(m_finalTimeStep);
35}
36
37template <MInt nDim>
39 TRACE();
40 m_surfaceData.reset(new SurfaceData<nDim, SolverType>{*m_ppSolver});
41 m_surfaceData->setInputOutputProperties();
42 m_surfaceData->init();
43}
44
45template <MInt nDim>
47 m_surfaceData->save(m_finalTimeStep);
48}
49
50template <MInt nDim>
52 TRACE();
53 m_volumeData.reset(new VolumeData<nDim, SolverType>{*m_ppSolver});
54 m_volumeData->setInputOutputProperties();
55 m_volumeData->init();
56}
57
58template <MInt nDim>
60 m_volumeData->save(m_finalTimeStep);
61}
62
67template <MInt nDim>
69 TRACE();
70
71 if(solver().domainId() == 0) {
72 std::ofstream ofl;
73 ofl.open("IsoTurbulenceStatistics.log", ios::app);
74 ofl << std::setw(5) << "t"
75 << "\t" << std::setw(8) << "ReLambda"
76 << "\t" << std::setw(8) << "lambda"
77 << "\t" << std::setw(8) << "Eta"
78 << "\t" << std::setw(8) << "tau_eta"
79 << "\t" << std::setw(8) << "skewness" << endl;
80 ofl.close();
81 }
82}
83
96template <MInt nDim>
98 TRACE();
99
100 if((solver().m_fftInterval > 0 && globalTimeStep % solver().m_fftInterval == 0) || m_finalTimeStep) {
101 const MInt fftLevel = solver().grid().maxUniformRefinementLevel();
102 const MFloat DX = solver().c_cellLengthAtLevel(fftLevel);
103
104 MFloat urms[6] = {F0, F0, F0, F0, F0, F0};
105 MFloat dudx[3] = {F0, F0, F0};
106 MFloat skew[4] = {F0, F0, F0, F0};
107 MFloat lambda[3] = {F0, F0, F0};
108 MFloat cnt = F0;
109
110 MFloat lambdaAvg = F0;
111 MFloat ReLambda = F0;
112 MFloat skewness = F0;
113 MFloat eta = F0;
114
115 for(MInt cellId = 0; cellId < solver().a_noCells(); cellId++) {
116 if(solver().a_isHalo(cellId)) continue;
117 if(solver().a_isBndryGhostCell(cellId)) continue;
118 if(solver().a_level(cellId) != fftLevel) continue;
119 MFloat u = solver().a_variable(cellId, solver().PV->U);
120 MFloat v = solver().a_variable(cellId, solver().PV->V);
121 MFloat w = solver().a_variable(cellId, solver().PV->W);
122 for(MInt i = 0; i < nDim; i++) {
123 MInt n0 = (solver().a_hasNeighbor(cellId, 2 * i) > 0) ? solver().c_neighborId(cellId, 2 * i) : cellId;
124 MInt n1 = (solver().a_hasNeighbor(cellId, 2 * i + 1) > 0) ? solver().c_neighborId(cellId, 2 * i + 1) : cellId;
125 if(n0 == n1) continue;
126 dudx[i] += POW2((solver().a_variable(n1, solver().PV->VV[i]) - solver().a_variable(n0, solver().PV->VV[i]))
127 / ((solver().a_coordinate(n1, i) - solver().a_coordinate(n0, i)) / DX));
128 skew[i] += POW3((solver().a_variable(n1, solver().PV->VV[i]) - solver().a_variable(n0, solver().PV->VV[i]))
129 / ((solver().a_coordinate(n1, i) - solver().a_coordinate(n0, i)) / DX));
130 }
131 urms[0] += POW2(u);
132 urms[1] += POW2(v);
133 urms[2] += POW2(w);
134 urms[3] += u * v;
135 urms[4] += u * w;
136 urms[5] += v * w;
137 cnt++;
138 }
139
140 MPI_Allreduce(MPI_IN_PLACE, &cnt, 1, MPI_DOUBLE, MPI_SUM, solver().mpiComm(), AT_, "MPI_IN_PLACE", "cnt");
141 MPI_Allreduce(MPI_IN_PLACE, &urms[0], 6, MPI_DOUBLE, MPI_SUM, solver().mpiComm(), AT_, "MPI_IN_PLACE", "urms[0]");
142 MPI_Allreduce(MPI_IN_PLACE, &dudx[0], 3, MPI_DOUBLE, MPI_SUM, solver().mpiComm(), AT_, "MPI_IN_PLACE", "dudx[0]");
143 MPI_Allreduce(MPI_IN_PLACE, &skew[0], 3, MPI_DOUBLE, MPI_SUM, solver().mpiComm(), AT_, "MPI_IN_PLACE", "skew[0]");
144 skew[3] = ((skew[0] + skew[1] + skew[2]) / (F3 * cnt)) / pow((dudx[0] + dudx[1] + dudx[2]) / (F3 * cnt), 1.5);
145 for(MInt i = 0; i < 3; i++)
146 skew[i] = (skew[i] / cnt) / pow(dudx[i] / cnt, 1.5);
147 for(MInt i = 0; i < 6; i++)
148 urms[i] = sqrt(fabs(urms[i]) / cnt);
149 for(MInt i = 0; i < 3; i++)
150 dudx[i] /= cnt;
151 for(MInt i = 0; i < 3; i++)
152 lambda[i] = urms[i] / sqrt(dudx[i]); // Eq. 6.56 Turbulent Flows Pope two-point correlation
153
154 lambdaAvg = F1B3 * (lambda[0] + lambda[1] + lambda[2]);
155 ReLambda = F1B3 * (urms[0] + urms[1] + urms[2]) * lambdaAvg / solver().m_nu;
156 skewness = skew[3];
157
158 MFloat eps[3];
159 for(MInt i = 0; i < 3; i++) {
160 eps[i] = 15.0 * solver().m_nu * POW2(urms[i] / lambda[i]); // Eq. 6.58 Turbulent Flows Pope two-point correlation
161 }
162 eta = pow(solver().m_nu, 0.75)
163 / pow(F1B3 * (eps[0] + eps[1] + eps[2]), 0.25); // Eq. 6.1 Turbulent Flows Pope two-point correlation
164 m_tau_eta = pow(solver().m_nu / (F1B3 * (eps[0] + eps[1] + eps[2])), 0.5);
165
166 if(solver().domainId() == 0) {
167 std::ofstream ofl;
168 ofl.open("IsoTurbulenceStatistics.log", ios::app);
169 ofl << std::setw(5) << globalTimeStep << "\t" << std::setw(8) << ReLambda << "\t" << std::setw(8) << lambdaAvg
170 << "\t" << std::setw(8) << eta << "\t" << std::setw(8) << m_tau_eta << "\t" << std::setw(8) << skewness
171 << endl;
172 ofl.close();
173 }
174 }
175}
176
177template class PostProcessingLb<2>;
178template class PostProcessingLb<3>;
This class is responsible for the point data feature. It records the state of all sampling variables ...
Definition: samplingdata.h:164
Definition: postdata.h:23
void initPointSamplingData() override
SolverType * m_ppSolver
void computeIsoTurbulenceStatistics() override
write data for isotropic Turbulence (single phase and particle-laden)
void savePointSamplingData() override
void initVolumeSamplingData() override
void initSurfaceSamplingData() override
void initIsoTurbulenceStatistics() override
init function for Isotropic Turbulence Statistics
PostProcessingLb(MInt postprocessingId_, PostData< nDim > *data, SolverType *ppSolver_)
virtual ~PostProcessingLb()
void saveSurfaceSamplingData() override
void saveVolumeSamplingData() override
Surface data sampling class. Records all sampling variables on all surface elements and outputs addit...
Definition: samplingdata.h:190
Class to handle sampling of volume data.
Definition: samplingdata.h:220
constexpr Real POW3(const Real x)
Definition: functions.h:123
constexpr Real POW2(const Real x)
Definition: functions.h:119
MInt globalTimeStep
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52
int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, const MString &name, const MString &sndvarname, const MString &rcvvarname)
same as MPI_Allreduce