13template <MInt nDim, MInt nDist,
class SysEqn>
17 this->dgSolver().forceTimeStep(m_conversionLb2Dg.time * 1.0);
24template <MInt nDim, MInt nDist,
class SysEqn>
32 constexpr MFloat dgGamma = 1.4;
33 MFloat maSq = this->a_Ma() * this->a_Ma();
36 const MBool hasLbSolver = this->lbSolver().isActive();
38 (hasLbSolver) ? this->a_cellLengthAtLevel(donorSolver().maxLevel()) : std::numeric_limits<MFloat>::max();
44 this->dgSolver().grid().raw().mpiComm(),
49 m_conversionLb2Dg.length = dxLb;
50 m_conversionLb2Dg.density = pow(1.0 + 0.5 * (dgGamma - 1.0) * maSq, 1.0 / (1.0 - dgGamma));
51 m_conversionLb2Dg.time = dxLb * LBCS * sqrt(1.0 + 0.5 * (dgGamma - 1.0) * maSq);
53 m_conversionLb2Dg.velocity = m_conversionLb2Dg.length / m_conversionLb2Dg.time;
54 m_conversionLb2Dg.vorticity = 1.0 / m_conversionLb2Dg.time;
55 m_conversionLb2Dg.lamb = m_conversionLb2Dg.vorticity * m_conversionLb2Dg.velocity;
69template <MInt nDim, MInt nDist,
class SysEqn>
74 if(this->m_hasDonorCartesianSolver) {
76 for(
auto donorId : donorCellIds) {
77 const MFloat* cellVars =
nullptr;
78 this->donorSolver().getSampleVariables(donorId, cellVars);
79 for(
MInt dirId = 0; dirId < this->noVelocities(); dirId++) {
80 p_velocity(donorId, dirId) = cellVars[this->donorSolver().PV->VV[dirId]] * m_conversionLb2Dg.velocity;
84 for(
auto donorId : donorCellIds) {
85 MFloat velocityGradient[nDim][nDim];
86 this->donorSolver().calculateVelocityDerivative(donorId, velocityGradient);
87 if constexpr(nDim == 2) {
88 p_vorticity(donorId, 0) = (velocityGradient[1][0] - velocityGradient[0][1]) * m_conversionLb2Dg.vorticity;
89 }
else if(nDim == 3) {
90 p_vorticity(donorId, 0) = (velocityGradient[2][1] - velocityGradient[1][2]) * m_conversionLb2Dg.vorticity;
91 p_vorticity(donorId, 1) = (velocityGradient[0][2] - velocityGradient[2][0]) * m_conversionLb2Dg.vorticity;
92 p_vorticity(donorId, 2) = (velocityGradient[1][0] - velocityGradient[0][1]) * m_conversionLb2Dg.vorticity;
104template <MInt nDim, MInt nDist,
class SysEqn>
111 std::map<MString, MFloat> conversionMap;
112 conversionMap[
"wxv_x"] = m_conversionLb2Dg.lamb;
113 conversionMap[
"wxv_y"] = m_conversionLb2Dg.lamb;
114 conversionMap[
"wxv_z"] = m_conversionLb2Dg.lamb;
115 conversionMap[
"um"] = m_conversionLb2Dg.velocity;
116 conversionMap[
"vm"] = m_conversionLb2Dg.velocity;
117 conversionMap[
"wm"] = m_conversionLb2Dg.velocity;
118 conversionMap[
"rhom"] = m_conversionLb2Dg.density;
119 conversionMap[
"c0"] = m_conversionLb2Dg.velocity;
120 conversionMap[
"dc0_dx"] = m_conversionLb2Dg.vorticity;
121 conversionMap[
"dc0_dy"] = m_conversionLb2Dg.vorticity;
122 conversionMap[
"dc0_dz"] = m_conversionLb2Dg.vorticity;
123 conversionMap[
"vort_x"] = m_conversionLb2Dg.vorticity;
124 conversionMap[
"vort_y"] = m_conversionLb2Dg.vorticity;
125 conversionMap[
"vort_z"] = m_conversionLb2Dg.vorticity;
127 auto search = conversionMap.find(name);
128 if(search == conversionMap.end()) {
129 std::stringstream ss;
130 ss <<
"ERROR: No unit type found for " << name <<
" ." << std::endl;
133 const MFloat conversionFactor = conversionMap[name];
134 for(
MInt i = 0; i < count; i++) {
135 const MInt j = i * stride;
136 data[j] *= conversionFactor;
140template <MInt nDim, MInt nDist,
class SysEqn>
142 const MFloat*
const vorticity,
143 MFloat*
const sourceTerms) {
145 RECORD_TIMER_START(this->m_timers[BaseDg::Timers::CalcSourceLamb]);
147 const MInt lambIndex = this->m_meanVarsIndex[BaseDg::MV::LAMB0[0]];
150 for(
MInt donorIndex = 0; donorIndex < this->m_noActiveDonorCells; donorIndex++) {
151 const MInt donorId = this->m_calcSourceDonorCells[donorIndex];
153 const MFloat*
const meanVars = &this->m_meanVars[donorIndex * this->noMeanVars()];
154 const MFloat*
const velo = &velocity[donorId * this->noVelocities()];
155 const MFloat*
const vort = &vorticity[donorId * this->noVorticities()];
159 lambVector[0] = -vort[0] * velo[1];
160 lambVector[1] = vort[0] * velo[0];
162 lambVector[0] = vort[1] * velo[2] - vort[2] * velo[1];
163 lambVector[1] = vort[2] * velo[0] - vort[0] * velo[2];
164 lambVector[2] = vort[0] * velo[1] - vort[1] * velo[0];
168 const MInt offset = donorId * SysEqnDg::noVars() + BaseDg::CV::UU[0];
169 for(
MInt dim = 0; dim < nDim; dim++) {
170 sourceTerms[offset + dim] += -(lambVector[dim] - meanVars[lambIndex + dim]);
173 RECORD_TIMER_STOP(this->m_timers[BaseDg::Timers::CalcSourceLamb]);
virtual void performUnitConversion(const MString &, const MInt, const MInt, MFloat *) override
Transform data from donor solver unit system into DG unit system.
void getDonorVelocityAndVorticity(const std::vector< MInt > &donorCellIds, MFloatScratchSpace &p_velocity, MFloatScratchSpace &p_vorticity) override
Get velocity and vorticity of donor solver.
void calcSourceLambNonlinear(const MFloat *const velocity, const MFloat *const vorticity, MFloat *const sourceTerms) override
void finalizeCouplerInit() override
void initConversionFactors()
This class is a ScratchSpace.
std::basic_string< char > MString
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