flux reconstruction

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
xiaoxue123
Posts: 29
Joined: Fri Mar 02, 2018 11:50 am

flux reconstruction

Post by xiaoxue123 »

Dear expert team,

I am running a LES in a T-junction. Synthetic turbulence is applied at the inlets through the subroutine. The fluid is liquid metal which has a high thermal diffusivity. The LES was restarted from a RANS result.
The simulation diverges as shown in the temperature contours below.
Temp2.png
Temp1.png
But if I deactivate the flux reconstruction option, it seems running OK. Is flux reconstruction compulsory? The setup log and run_solver log are attached.

Best regards,
Xiaoxue
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: flux reconstruction

Post by Yvan Fournier »

Hello,

You seem to have forgotten the attachments.

When you deactivate flux reconstruction, If I am correct, the scheme becomes non-consistent (or at least lower order) for meshes with non-orthogonalities.

Using this, computations tend to be more robust relative to mesh quality issues, but with degraded quality.
So I strongly recommend not deactivating reconstruction for an LES (it seems OK in RANS for variables such as k or epsilon, but not for velocity). Instead, you may increase the number of sweeps, or add a small percentage of upwind (2%).

The attachments may help for further recommendations.

Regards,

Yvan
Antech
Posts: 197
Joined: Wed Jun 10, 2015 10:02 am

Re: flux reconstruction

Post by Antech »

Hello.
I found that partial SOLU scheme (with blencv=0.7...0.8), deactivating flux reconstruction or tweaking some other numerics is not so strong as pressure/velocity limiting and relaxation. I mentioned it in other posts but I think it's relevant here too, it's important for many users. Here are means to archive more stability:
1. Use Least Squares gradient reconstruction + Non-ortho faces threshold option. If you need more stability switch to Full (all vertex adjacent) option but it's very slow.
2. In static cases use Local time step + target CFL=0.5...5. Check that real CFL is not too large (in solver log tables) due to divergence or too big Minimal time step factor. For most cases reference time step is 0.0001...0.001 s, minimal factor range is numerically the same.
3. Start with Upwind for all variables, then switch to SOLU for velocity with blending 1.0 (blencv=1.0), reduce blencv to 0.6...0.8 if you can't stabilize (it will also reduce precision but better than nothing). Other variables... Turbulence model is usually rough itself, so Upwind should be OK. Temperature and user scalars / species may be more sensitive so you may compare results with Upwind and SOLU for them if solution doesn't diverge with SOLU (or reduce blencv to 0.6...0.8). With Upwind/SOLU you always balance between precision and stability. Simplest cases are insensitive to this, complex cases like highly swirled flow may be much more sensible.
4. Use variable limiting. It's mandatory for velocity, pressure and species / user scalars. Also good for temperature. Not needed for turbulence (from my experience). How to do it. Some variables are accessible in Equation parameters => Clipping in GUI. For other variables create cs_user_extra_operations function (copy from examples to SRC dir) or open if you have it in your case. Then introduce something like this, example is for pressure, process other variables this way:

Code: Select all

cs_real_t  prsMinRq=-5000; /* Minimum allowable pressure [Pa] */
cs_real_t prsMaxRq=5000; /* Maximum allowable pressure [Pa] */
cs_field_t *prsField=cs_field_by_name_try("pressure"); /* Pointer to pressure field */
if (prsField!=NULL) /* Pressure field present */
{
 for (cs_lnum_t iCell=0;iCell<nCell;iCell++) /* Cell loop */
 {
   prsField->val[iCell]=fmin(fmax(prsField->val[iCell],prsMinRq),prsMaxRq);
 };
};
Sorry, didn't check so needs debug.
5. Use variable relaxation. Relaxation factor is 0.05...0.3 for velocity and pressure, 0.5...0.8 for temperature / enthalpy and turbulence, 0.3 for species / user scalars. How to do it. Open your cs_user_parameters function or create from examples. Here is an example for epsilon, extrapolate on other variables:

Code: Select all

cs_field_t* field;
cs_equation_param_t* eqnPar;
field=CS_F_(eps); /* Field structure */
if (field!=NULL) /* Field present */
{
 eqnPar=cs_field_get_equation_param(field); /* Field options structure */
 eqnPar->relaxv=0.8; /* Relaxation factor */
 eqnPar->ircflu=0; /* Flux reconstruction flag */
};
For different options with RSM you will also need rij, r11, r22, r33, r12, r23, r13 fields (if there is no such field code will just skip it so don't test on turbulence model selected). For temperature scalar field is not TempC but h. For user scalars you need cs_field_by_name_try("ScalarName") instead of CS_F_(...). You can check that it works in setup.log, search for relaxv lines for each field (these lines look like relaxv 0.05).
Disabling flux reconstruction for RANS turbulence (k+epsilon) was found somewhere in examples. I think it's usually not practical to disable it for other variables and I'm not sure it will not reduce precision with RSM. If you implement all things described, the solution should be stable even with RSM and rapid density changes like in combustion simulations.

Also, I want to say that what I see on the pictures looks like checkerboard effect but not divergence. There was a discussion about such problem, the result, as I remember, was: with small timesteps we have checkerboarding, with large timesteps - divergence. I think that increasing timesteps (I described how to archive stability) or tetra mesh may help.
Last edited by Antech on Fri Dec 09, 2022 10:19 am, edited 1 time in total.
xiaoxue123
Posts: 29
Joined: Fri Mar 02, 2018 11:50 am

Re: flux reconstruction

Post by xiaoxue123 »

Hello,

These are the setup and run_solver log which I forgot to attach in my original post.

Xiaoxue
Attachments
run_solver.log
(97.07 KiB) Downloaded 55 times
setup.log
(28.96 KiB) Downloaded 50 times
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: flux reconstruction

Post by Yvan Fournier »

Hello,

The crash is in postprocessing, and seems like a bug, so if you have user-defined functions, you may need to check them and remove them to see if this solves the issue.

The suggestions from Antech may work for a steady-case computation, but a local time step make no sense in LES, and upwind options lead to loss of energy conservation, which can degrade LES results, so you can only use those for initialization.

For the pressure at least, using iterative or hybrid gradient reconstruction is recommended (you can use different options for different variables in v7.0, but I am not sure for v6.0).

The number of sweeps you use is the default for LES, and seems OK.

The first step is to see why you have memory corruption.

Best regards,

Yvan
Antech
Posts: 197
Joined: Wed Jun 10, 2015 10:02 am

Re: flux reconstruction

Post by Antech »

Thanks for your recommendations for LES. My method is for static (steady state) simulations only and for widely-used turbulence models (k-epsilon and SST, maybe for RSM). I noticed that most effective things are relaxation and limitation. Relaxation cannot be used in dynamics while small time step doesn't help in all cases (in steady state mode).
Post Reply