MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
fvstructuredsolver3d.h
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#ifndef FVSTRUCTUREDSOLVER3D_H
8#define FVSTRUCTUREDSOLVER3D_H
9
10#include "GRID/structuredgrid.h"
12#include "fvstructuredsolver.h"
14// fftw is needed for the channel flow
15#include <complex>
16#include <fftw3.h>
17
18extern MInt globalTimeStep;
20
25};
26
27class ParallelIoHdf5;
28
33 template <MBool isRans>
36
37 public:
38 FvStructuredSolver3D(MInt, StructuredGrid<3>*, MBool*, const MPI_Comm comm);
40
43
44 void initSolutionStep(MInt mode);
45 void initialCondition() override;
46 void assignBndryCells();
47 void nonReflectingBC();
48 void applyBoundaryCondition() override;
50 void initBndryCnds();
52 void applySandpaperTrip();
54 void initSandpaperTrip();
57 void computeDomainWidth() override;
58
60 void zonalExchange() override;
63 void zonalGather();
64 void zonalSend();
65 void zonalReceive();
66 void zonalCheck();
68 void zonalScatter();
69 std::vector<std::unique_ptr<StructuredZonalBC>> m_zonalBC;
70 void spanwiseAvgZonal(std::vector<MFloat*>&) override;
71
73 void computeTimeStep() override;
74 void computeVorticity() override;
75 void computeLambda2Criterion() override;
79 void initFluxMethod();
80 void computePrimitiveVariables() override;
81 template <MFloat (FvStructuredSolver::*)(MInt) const = &FvStructuredSolver::dummy>
84 inline MFloat getPSI(MInt, MInt);
85
86 void Ausm();
87 inline void AusmLES(MFloat* QLeft, MFloat* QRight, const MInt dim, const MInt cellId);
88 inline void AusmLES_PTHRC(MFloat* QLeft, MFloat* QRight, MInt dim, MInt cellId);
89 inline void AusmDV(MFloat* QLeft, MFloat* QRight, MInt dim, MInt cellId);
90
92 template <MInt noVars>
93 void Muscl_AusmLES();
94 template <MInt noVars>
96 template <MInt noVars>
97 void Muscl_AusmDV();
98 template <fluxmethod ausm, MInt noVars>
99 void MusclStretched_();
100
101 void Muscl(MInt timerId = -1) override;
102 void MusclRANS();
104 // different Muscl schemes:
106 void MusclAlbada();
107 void MusclMinModLimiter();
108 void computeCellLength();
109
111
112 // limiter functions for MusclVenkatakrishnan3D()
113 void VENKATAKRISHNAN_MOD_FCT(MFloat effNghbrDelta, MFloat srfcDelta, MFloat dxEpsSqr, MInt cellPos, MInt var,
114 MFloatScratchSpace& minPhi);
115 void VENKATAKRISHNAN_FCT(MFloat effNghbrDelta, MFloat srfcDelta, MFloat dxEpsSqr, MInt cellPos, MInt var,
116 MFloatScratchSpace& minPhi);
117 void BARTH_JESPERSON_FCT(MFloat effNghbrDelta, MFloat srfcDelta, MFloat dxEpsSqr, MInt cellPos, MInt var,
118 MFloatScratchSpace& minPhi);
120
123 void updateSpongeLayer();
124 void addDisturbance();
125 void viscousFlux();
126 void viscousFluxRANS();
127 template <MBool twoEqRans = false>
128 void viscousFluxLES();
130 void moveGrid(const MBool isRestart, const MBool zeroPos) override;
131 void applyBodyForce(const MBool isRestart, const MBool zeroPos) override;
132 void initMovingGrid() override;
133 void initBodyForce() override;
134 // for the treatment of boundary condition
137 // save the skin-friction etc ...
138 virtual void computeFrictionPressureCoef(MBool computePower) override {
139 m_structuredBndryCnd->computeFrictionPressureCoef(computePower);
140 }
141
142 // fftw is needed for the channel flow:
143 void initFFTW(fftw_complex* uPhysField, fftw_complex* vPhysField, fftw_complex* wPhysField, MInt lx, MInt ly, MInt lz,
144 MInt noPeakModes);
145 void getFourierCoefficients(MFloat* k, MFloat k0, std::complex<MFloat>* fourierCoefficient);
146 MFloat randnormal(MFloat mu, MFloat sigma);
147 void loadRestartBC2600();
148 void loadRestartBC2601();
149 void loadRestartSTG(MBool);
150
151 void gather(const MBool, std::vector<std::unique_ptr<StructuredComm<3>>>&) override;
152 void scatter(const MBool, std::vector<std::unique_ptr<StructuredComm<3>>>&) override;
153
154 // for traveling wave averaging
155 void waveGather();
156 void waveScatter();
157 void waveSend(std::vector<MPI_Request>&);
158 void waveReceive(std::vector<MPI_Request>&);
159 void waveExchange() override;
160 void spanwiseWaveReorder() override;
161
162 // for exchange of postprocessing field
163 void gcFillGhostCells(std::vector<MFloat*>&);
164 void gcExtrapolate(std::vector<MFloat*>&);
165
167
168 // For time averaging of flow variables
169 void computeCumulativeAverage(MBool forceReset) override;
170
171 // Line and plane interpolation
173 void saveInterpolatedPoints() override;
174 void saveNodalBoxes() override;
175 void savePointsToAsciiFile(MBool) override;
176 void initPointsToAsciiFile() override;
177
178 // Porous
179 virtual void computePorousRHS(MBool /*isRans*/) override;
180 void exchange6002();
181
182 protected:
183 std::unique_ptr<StructuredBndryCnd<3>> m_structuredBndryCnd;
184
185 // index variables
186 static constexpr MInt xsd = 0;
187 static constexpr MInt ysd = 1;
188 static constexpr MInt zsd = 2;
189
191
192 inline void crossProduct(MFloat*, const MFloat*, const MFloat*);
193 inline MInt cellIndex(const MInt, const MInt, const MInt);
194 inline MInt pointIndex(const MInt, const MInt, const MInt);
195 inline MFloat dist(MFloat* a, MFloat* b);
196 // routine to determine point ID from given cell ( point (0,0,0) for unit cube )
197 inline MInt getPointIdFromCell(const MInt, const MInt, const MInt);
198 // routine to determine point ID from given point
199 inline MInt getPointIdfromPoint(const MInt, const MInt, const MInt, const MInt);
200 inline MInt getCellIdfromCell(const MInt, const MInt, const MInt, const MInt);
201 inline MInt surfId(MInt point, MInt isd, MInt dim);
202
203 std::unique_ptr<FvStructuredSolver3DRans> m_ransSolver;
204
205
206 // interpolation
207 std::unique_ptr<StructuredInterpolation<3>> m_structuredInterpolation;
208 std::unique_ptr<StructuredInterpolation<3>> m_pointInterpolation;
211
212 // postprocessing helper functions
213 void loadSampleFile(MString) override;
214 void getSampleVariables(MInt, MFloat*) override;
216 void loadAverageRestartFile(const MChar*, MFloat**, MFloat**, MFloat**, MFloat**) override;
217 void loadAveragedVariables(const MChar*) override;
220
221 MFloat dvardxyz(MInt, MInt, MFloat*) override;
222 MFloat dvardx(MInt, MFloat*) override;
223
224 MFloat getCellLengthY(MInt, MInt, MInt) override;
226
227 static constexpr const MInt nDim = 3;
228};
229
230
231#endif
3D structured solver class
void computeLambda2Criterion() override
Function to compute the lambda_2 criterion.
static constexpr MInt xsd
void initInterpolatedPoints()
Compute all the interpolation coefficients necessary for the interpolation output.
MFloat getCellLengthY(MInt, MInt, MInt) override
void AusmLES_PTHRC(MFloat *QLeft, MFloat *QRight, MInt dim, MInt cellId)
AUSM PTHRC.
MBool maxResidual()
Computation of the maximum residual.
void loadSampleFile(MString) override
Loads primitive variables from an HDF5 file.
void initializeNeighbourCellIds()
void scatter(const MBool, std::vector< std::unique_ptr< StructuredComm< 3 > > > &) override
void spanwiseWaveReorder() override
void computePrimitiveVariables() override
void spanwiseAvgZonal(std::vector< MFloat * > &) override
void manualInterpolationCorrection()
Manually correct errors made by the restart interpolation.
void applyBoundaryCondition() override
MInt surfId(MInt point, MInt isd, MInt dim)
void MusclVenkatakrishnan3D()
MUSCL with Venkatakrishan limiter.
void shiftAverageCellValues()
Shifts the averaged variables.
MFloat dvardxyz(MInt, MInt, MFloat *) override
void tripForceCoefficients(MFloat *, MFloat *, MFloat *, MInt, MInt)
MFloat dist(MFloat *a, MFloat *b)
void BARTH_JESPERSON_FCT(MFloat effNghbrDelta, MFloat srfcDelta, MFloat dxEpsSqr, MInt cellPos, MInt var, MFloatScratchSpace &minPhi)
Barth-Jesperson Limiter.
void gather(const MBool, std::vector< std::unique_ptr< StructuredComm< 3 > > > &) override
static constexpr MInt zsd
void(FvStructuredSolver3D::* reconstructSurfaceData)()
void(FvStructuredSolver3D::* Venkatakrishnan_function)(MFloat, MFloat, MFloat, MInt, MInt, MFloatScratchSpace &)
MInt getCellIdfromCell(const MInt, const MInt, const MInt, const MInt)
void(FvStructuredSolver3D::* viscFluxMethod)()
MFloat getSampleVorticity(MInt, MInt) override
static constexpr MInt ysd
void interpolateFromDonor()
Interpolates the flow field from a given donor file.
std::vector< std::unique_ptr< StructuredZonalBC > > m_zonalBC
void getFourierCoefficients(MFloat *k, MFloat k0, std::complex< MFloat > *fourierCoefficient)
Generates a single complex coefficient of Fourier series.
void savePointsToAsciiFile(MBool) override
Saves variables of given cells to ASCII file.
void initPointsToAsciiFile() override
void waveSend(std::vector< MPI_Request > &)
void gcExtrapolate(std::vector< MFloat * > &)
void initialCondition() override
Computation of infinity values for the conservative and primitive variables.
MInt getPointIdFromCell(const MInt, const MInt, const MInt)
void getSampleVariables(MInt, MFloat *) override
void VENKATAKRISHNAN_MOD_FCT(MFloat effNghbrDelta, MFloat srfcDelta, MFloat dxEpsSqr, MInt cellPos, MInt var, MFloatScratchSpace &minPhi)
Venkatakrishnan limiter, modified for better results.
MInt cellIndex(const MInt, const MInt, const MInt)
void initSolutionStep(MInt mode)
void tripFourierCoefficients(MFloat *, MInt, MFloat, MFloat)
MFloat randnormal(MFloat mu, MFloat sigma)
Returns a normal distributed random-number with mu=mean and sigma=standard deviation.
MFloat dvardx(MInt, MFloat *) override
void addGhostPointCoordinateValues()
Extrapolates and exchanges ghost point coordinates.
void gcFillGhostCells(std::vector< MFloat * > &)
void loadAverageRestartFile(const MChar *, MFloat **, MFloat **, MFloat **, MFloat **) override
Loads the postprocessing restart file to continue the postprocessing.
void viscousFluxLES()
Viscous flux computation.
void Muscl(MInt timerId=-1) override
MInt getPointIdfromPoint(const MInt, const MInt, const MInt, const MInt)
MInt pointIndex(const MInt, const MInt, const MInt)
void computeCumulativeAverage(MBool forceReset) override
void loadAveragedVariables(const MChar *) override
Loads the averaged variables again to do further postprocessing.
void saveInterpolatedPoints() override
void AusmDV(MFloat *QLeft, MFloat *QRight, MInt dim, MInt cellId)
void waveReceive(std::vector< MPI_Request > &)
std::unique_ptr< StructuredInterpolation< 3 > > m_structuredInterpolation
void(FvStructuredSolver3D::* fluxmethod)(MFloat *, MFloat *, MInt, MInt)
virtual void computePorousRHS(MBool) override
virtual void computeFrictionPressureCoef(MBool computePower) override
static constexpr const MInt nDim
void applyBodyForce(const MBool isRestart, const MBool zeroPos) override
std::unique_ptr< FvStructuredSolver3DRans > m_ransSolver
std::unique_ptr< StructuredBndryCnd< 3 > > m_structuredBndryCnd
void moveGrid(const MBool isRestart, const MBool zeroPos) override
void initFFTW(fftw_complex *uPhysField, fftw_complex *vPhysField, fftw_complex *wPhysField, MInt lx, MInt ly, MInt lz, MInt noPeakModes)
void VENKATAKRISHNAN_FCT(MFloat effNghbrDelta, MFloat srfcDelta, MFloat dxEpsSqr, MInt cellPos, MInt var, MFloatScratchSpace &minPhi)
Standard Venkatakrishnan limiter.
void crossProduct(MFloat *, const MFloat *, const MFloat *)
std::unique_ptr< StructuredInterpolation< 3 > > m_pointInterpolation
void computeDomainWidth() override
MFloat getCellCoordinate(MInt, MInt) override
void AusmLES(MFloat *QLeft, MFloat *QRight, const MInt dim, const MInt cellId)
AUSM central.
Base class of the structured solver.
This class is a ScratchSpace.
Definition: scratch.h:758
Class for the 3D stuctured boundary conditions.
Structured grid class.
@ AUSM_LES
@ AUSM_LES_PTHRC
MInt globalTimeStep
int32_t MInt
Definition: maiatypes.h:62
std::basic_string< char > MString
Definition: maiatypes.h:55
double MFloat
Definition: maiatypes.h:52
bool MBool
Definition: maiatypes.h:58
char MChar
Definition: maiatypes.h:56
Definition: contexttypes.h:19