70 "ProcessCompressibleFields requires a session file.");
73 m_f->m_session->LoadSolverInfo(
"EquationOfState", eosType,
"IdealGas");
75 "ProcessCompressibleFields only supports the IdealGas equation "
78 int nfields =
m_f->m_variables.size();
79 int spacedim =
m_f->m_graph->GetMeshDimension() +
m_f->m_numHomogeneousDir;
83 auto findField = [&](
const std::string &name) {
85 std::find(
m_f->m_variables.begin(),
m_f->m_variables.end(), name);
87 "ProcessCompressibleFields requires the field '" + name +
88 "' (conservative variables of a compressible flow).");
89 return static_cast<int>(it -
m_f->m_variables.begin());
92 const std::string momNames[3] = {
"rhou",
"rhov",
"rhow"};
93 const std::string velNames[3] = {
"u",
"v",
"w"};
95 int rhoId = findField(
"rho");
96 int EId = findField(
"E");
97 std::vector<int> momId(spacedim);
98 for (
int i = 0; i < spacedim; ++i)
100 momId[i] = findField(momNames[i]);
104 std::vector<std::string> newNames(velNames, velNames + spacedim);
105 newNames.insert(newNames.end(), {
"p",
"T",
"s",
"a",
"Mach"});
106 int addfields = newNames.size();
108 for (
auto &name : newNames)
110 ASSERTL0(std::find(
m_f->m_variables.begin(),
m_f->m_variables.end(),
111 name) ==
m_f->m_variables.end(),
113 "' already exists (e.g. the file was written with "
114 "OutputExtraFields); remove it first with the "
115 "removefield module.");
119 m_f->m_variables.insert(
m_f->m_variables.end(), newNames.begin(),
123 if (
m_f->m_exp[0]->GetNumElmts() == 0)
129 m_f->m_session->LoadParameter(
"Strip_Z", nstrips, 1);
132 for (
int s = 0; s < nstrips; ++s)
134 for (
int i = 0; i < addfields; ++i)
137 m_f->AppendExpList(
m_f->m_numHomogeneousDir);
138 m_f->m_exp.insert(
m_f->m_exp.begin() + s * (nfields + addfields) +
145 m_f->m_session->LoadParameter(
"Gamma", gamma, 1.4);
146 m_f->m_session->LoadParameter(
"GasConstant", gasConstant, 287.058);
147 NekDouble cv = gasConstant / (gamma - 1.0);
149 int npoints =
m_f->m_exp[0]->GetNpoints();
150 bool waveSpace =
m_f->m_exp[0]->GetWaveSpace();
155 for (
int i = 0; i < addfields; ++i)
170 m_f->m_exp[fid]->HomogeneousBwdTrans(
171 npoints,
m_f->m_exp[fid]->GetPhys(), out);
179 for (
int s = 0; s < nstrips; ++s)
181 int offset = s * (nfields + addfields);
183 getPhys(offset + rhoId, rho);
187 for (
int i = 0; i < spacedim; ++i)
189 getPhys(offset + momId[i], outfield[i]);
190 Vmath::Vdiv(npoints, outfield[i], 1, rho, 1, outfield[i], 1);
191 Vmath::Vvtvp(npoints, outfield[i], 1, outfield[i], 1, vel2, 1, vel2,
196 getPhys(offset + EId, e);
202 Vmath::Smul(npoints, gamma - 1.0, pressure, 1, pressure, 1);
205 Vmath::Smul(npoints, 1.0 / cv, e, 1, temperature, 1);
211 Vmath::Svtvp(npoints, -gasConstant, tmp, 1, entropy, 1, entropy, 1);
214 Vmath::Smul(npoints, gamma * gasConstant, temperature, 1, soundspeed,
220 Vmath::Vdiv(npoints, mach, 1, soundspeed, 1, mach, 1);
222 for (
int i = 0; i < addfields; ++i)
224 int fid = offset + nfields + i;
227 m_f->m_exp[fid]->HomogeneousFwdTrans(npoints, outfield[i],
232 m_f->m_exp[fid]->FwdTransLocalElmt(outfield[i],
233 m_f->m_exp[fid]->UpdateCoeffs());