Skip to content

Commit 2f60dbb

Browse files
committed
describe a strategy that should work
1 parent c63c69a commit 2f60dbb

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

SU2_CFD/include/numerics/turbulent/turb_sources_new.hpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,35 @@ class ft2_nonzero : public Base {
304304
}
305305
};
306306

307+
/* The above causes a cyclic dependency between the turbulence base and the ft2 and co. classes.
308+
* To break that you need to template the get method instead of the class, for example: */
309+
struct ft2_nonzero {
310+
template <class Base>
311+
static void get(const Base& base, su2double& ft2, su2double& d_ft2) {
312+
const su2double xsi2 = pow(base.xsi, 2);
313+
ft2 = base.ct3 * exp(-base.ct4 * xsi2);
314+
d_ft2 = -2.0 * base.ct4 * base.xsi * ft2 * base.d_xsi;
315+
}
316+
};
317+
/* Now you pass the numerics class itself to "get" to access the member variables,
318+
* which you'll have to make public, for example in ComputeResidual:
319+
* ft2_class::get(*this, ft2, d_ft2);
320+
*
321+
* This is not a perfect solution because for performance we should cut down on "aux" class variables.
322+
* An alternative is to put such variables in a struct, which can then be a local variable in ComputeResidual. */
323+
struct CommonVariables {
324+
su2double ft2, d_ft2, r, d_r, g, d_g, g_6, glim, fw, Ji, Ji_2, Ji_3, d_Ji, S, Omega, Shat, d_Shat, inv_Shat, fv1, fv2;
325+
};
326+
/*
327+
* ResidualType<> ComputeResidual(const CConfig* config) final {
328+
* CommonVariables data;
329+
* ...
330+
* data.Ji = ...
331+
* ...
332+
* ft2_class::get(data, ft2, d_ft2);
333+
*/
334+
/* This way you can also dispense with templating "get". */
335+
307336
/*------------------------------------------------------------------------------
308337
| Compute the modified vorticity (\tilde{S}) and its derivative
309338
| * \param[in] S - vorticity (Omega)

0 commit comments

Comments
 (0)