|
30 | 30 | #include "CFVMOutput.hpp" |
31 | 31 | #include "../variables/CVariable.hpp" |
32 | 32 |
|
| 33 | +/*--- Forward declare to avoid including here. ---*/ |
| 34 | +template <class> |
| 35 | +struct CPrimitiveIndices; |
| 36 | + |
33 | 37 | class CFlowOutput : public CFVMOutput{ |
34 | 38 | protected: |
35 | 39 | unsigned long lastInnerIter; |
@@ -211,71 +215,7 @@ class CFlowOutput : public CFVMOutput{ |
211 | 215 | * \brief Helper for custom outputs, converts variable names to indices and pointers which are then used |
212 | 216 | * to evaluate the custom expressions. |
213 | 217 | */ |
214 | | - template <class FlowIndices> |
215 | | - void ConvertVariableSymbolsToIndices(const FlowIndices& idx, CustomOutput& output) const { |
216 | | - |
217 | | - static const auto knownVariables = |
218 | | - "TEMPERATURE, TEMPERATURE_VE, VELOCITY_X, VELOCITY_Y, VELOCITY_Z, PRESSURE,\n" |
219 | | - "DENSITY, ENTHALPY, SOUND_SPEED, LAMINAR_VISCOSITY, EDDY_VISCOSITY, THERMAL_CONDUCTIVITY\n" |
220 | | - "TURB[0,1,...], RAD[0,1,...], SPECIES[0,1,...]"; |
221 | | - |
222 | | - auto IndexOfVariable = [&](const FlowIndices& idx, const std::string& var) { |
223 | | - /*--- Primitives of the flow solver. ---*/ |
224 | | - const auto flow_offset = FLOW_SOL * CustomOutput::MAX_VARS_PER_SOLVER; |
225 | | - |
226 | | - if ("TEMPERATURE" == var) return flow_offset + idx.Temperature(); |
227 | | - if ("TEMPERATURE_VE" == var) return flow_offset + idx.Temperature_ve(); |
228 | | - if ("VELOCITY_X" == var) return flow_offset + idx.Velocity(); |
229 | | - if ("VELOCITY_Y" == var) return flow_offset + idx.Velocity() + 1; |
230 | | - if ("VELOCITY_Z" == var) return flow_offset + idx.Velocity() + 2; |
231 | | - if ("PRESSURE" == var) return flow_offset + idx.Pressure(); |
232 | | - if ("DENSITY" == var) return flow_offset + idx.Density(); |
233 | | - if ("ENTHALPY" == var) return flow_offset + idx.Enthalpy(); |
234 | | - if ("SOUND_SPEED" == var) return flow_offset + idx.SoundSpeed(); |
235 | | - if ("LAMINAR_VISCOSITY" == var) return flow_offset + idx.LaminarViscosity(); |
236 | | - if ("EDDY_VISCOSITY" == var) return flow_offset + idx.EddyViscosity(); |
237 | | - if ("THERMAL_CONDUCTIVITY" == var) return flow_offset + idx.ThermalConductivity(); |
238 | | - |
239 | | - /*--- Index-based (no name) access to variables of other solvers. ---*/ |
240 | | - auto GetIndex = [](const std::string& s, int nameLen) { |
241 | | - /*--- Extract an int from "name[int]", nameLen is the length of "name". ---*/ |
242 | | - return std::stoi(std::string(s.begin() + nameLen + 1, s.end() - 1)); |
243 | | - }; |
244 | | - if (var.rfind("SPECIES", 0) == 0) return SPECIES_SOL * CustomOutput::MAX_VARS_PER_SOLVER + GetIndex(var, 7); |
245 | | - if (var.rfind("TURB", 0) == 0) return TURB_SOL * CustomOutput::MAX_VARS_PER_SOLVER + GetIndex(var, 4); |
246 | | - if (var.rfind("RAD", 0) == 0) return RAD_SOL * CustomOutput::MAX_VARS_PER_SOLVER + GetIndex(var, 3); |
247 | | - |
248 | | - return CustomOutput::NOT_A_VARIABLE; |
249 | | - }; |
250 | | - |
251 | | - output.otherOutputs.clear(); |
252 | | - output.varIndices.clear(); |
253 | | - output.varIndices.reserve(output.varSymbols.size()); |
254 | | - |
255 | | - for (const auto& var : output.varSymbols) { |
256 | | - output.varIndices.push_back(IndexOfVariable(idx, var)); |
257 | | - |
258 | | - if (output.type == OperationType::FUNCTION && output.varIndices.back() != CustomOutput::NOT_A_VARIABLE) { |
259 | | - SU2_MPI::Error("Custom outputs of type 'Function' cannot reference solver variables.", CURRENT_FUNCTION); |
260 | | - } |
261 | | - /*--- Symbol is a valid solver variable. ---*/ |
262 | | - if (output.varIndices.back() < CustomOutput::NOT_A_VARIABLE) continue; |
263 | | - |
264 | | - /*--- An index above NOT_A_VARIABLE is not valid with current solver settings. ---*/ |
265 | | - if (output.varIndices.back() > CustomOutput::NOT_A_VARIABLE) { |
266 | | - SU2_MPI::Error("Inactive solver variable (" + var + ") used in function " + output.name + "\n" |
267 | | - "E.g. this may only be a variable of the compressible solver.", CURRENT_FUNCTION); |
268 | | - } |
269 | | - |
270 | | - /*--- An index equal to NOT_A_VARIABLE may refer to a history output. ---*/ |
271 | | - output.varIndices.back() += output.otherOutputs.size(); |
272 | | - output.otherOutputs.push_back(GetPtrToHistoryOutput(var)); |
273 | | - if (output.otherOutputs.back() == nullptr) { |
274 | | - SU2_MPI::Error("Invalid history output or solver variable (" + var + ") used in function " + output.name + |
275 | | - "\nValid solvers variables: " + knownVariables, CURRENT_FUNCTION); |
276 | | - } |
277 | | - } |
278 | | - } |
| 218 | + void ConvertVariableSymbolsToIndices(const CPrimitiveIndices<unsigned long>& idx, CustomOutput& output) const; |
279 | 219 |
|
280 | 220 | /*! |
281 | 221 | * \brief Compute value of the Q criteration for vortex idenfitication |
|
0 commit comments