Page 1 of 1

Cannot use TVD schemes

Posted: Sat May 11, 2024 10:10 pm
by finzeo
Hello everyone.

I'm trying to use TVD (Total Variation Diminishing) schemes as advective schemes by setting them in cs_user_parameters.c. However, I always encounter this error message as soon as the run starts.
../../../code_saturne/src/alge/cs_convection_diffusion.c:4786: Fatal error.

invalid value of ischcv


Call stack:
1: 0x7fd1a053e8ed <cs_convection_diffusion_vector+0x1d1d> (libsaturne-8.0.so)
2: 0x7fd1a04f565a <cs_balance_vector+0x2aa> (libsaturne-8.0.so)
3: 0x7fd1a0190401 <cs_equation_iterative_solve_vector+0x501> (libsaturne-8.0.so)
4: 0x7fd1a02c7fb2 <predvv_+0x7ee8> (libsaturne-8.0.so)
5: 0x7fd1a02b2208 <navstv_+0x1235> (libsaturne-8.0.so)
6: 0x7fd1a02d1f1f <tridim_+0x30d8> (libsaturne-8.0.so)
7: 0x7fd1a010b391 <caltri_+0x17c2> (libsaturne-8.0.so)
8: 0x7fd1a15ce360 <main+0x760> (libcs_solver-8.0.so)
9: 0x7fd19e69fd85 <__libc_start_main+0xe5> (libc.so.6)
10: 0x4039be <_start+0x2e> (cs_solver)
End of stack
Upon investigating the source code within /src/alge/cs_convection_diffusion.c, I don't see a way to use ischcv=4 (TVD scheme) without it throwing an error (this seems to be incompatible with any value of isstpc; I have already tried all values in the range [0;2] for isstpc). I'm using version 8.0.

Is there any way to avoid this error when attempting to use these schemes?

This is a part of the cs_user_parameters.c code:

Code: Select all

...
cs_field_t *vel_conv = cs_field_by_name("velocity");
cs_equation_param_t *eqp_vel = cs_field_get_equation_param(vel_conv);
eqp_vel->ischcv = 4;
eqp_vel->isstpc = 1;
int key_lim_id = cs_field_key_id("limiter_choice");
cs_field_set_key_int(vel_conv, key_lim_id, CS_NVD_SMART);
...
Thank you in advance.

Re: Cannot use TVD schemes

Posted: Sun May 12, 2024 8:29 pm
by Yvan Fournier
Hello,

Yes, Getting the right combination is a bit tricky, and compatibilty tests are done too late (it would be much simpler if the combination was tested after the setup stage, and options such as slope test possibly adjuster automatically).

In v8.1, I added the possibility of choosing NVD schemes using the GUI, which makes this easier. But I had to go through the same checks in the cs_convection_diffusion source code, and even then, there ar still some combinations which seem to fail for vector variables (I need to check which).

So yes, there are some combinations which work. You probably need to disable the slope test (set isstpc to 0).

Best regards,

Yvan

Re: Cannot use TVD schemes

Posted: Mon May 13, 2024 1:42 am
by finzeo
Hello Yvan, thank you for the response.

I tried setting isstpc to 0, 1, and 2 (i.e., all possible values) for velocity, but in all cases, I get the same error message: "invalid value of ischcv". I'm interested in using it for velocity, but now I see that if I try the same for the omega variable, it works (with no slope test). Why doesn't it work for velocity but it does for omega?

Initially, I would avoid installing version 8.1 since I'm not working with an installation from my personal computer.
I've attached the setup.log from a run where I attempted to use the SMART scheme for velocity, along with the corresponding cs_user_parameters.c file.

Thank you in advance.

Re: Cannot use TVD schemes

Posted: Mon May 13, 2024 8:45 pm
by Yvan Fournier
Hello,

The issue is probably that not all schemes implemented on scalars were implemented for velocity. The implementation goes back to a few years, but was not really used since it was not available in the GUI and poorly documented. Since these schemes were only strongly tested on a 1D verification case (for a scalar), this "unfinished implementation" was only noticed recently.

We'll try to complete this in the future, but for v8.0, it seems the feature is incomplete.

Best regards,

Yvan

Re: Cannot use TVD schemes

Posted: Tue May 14, 2024 12:55 am
by finzeo
Thank you, Yvan.

I'd like to ask: if I use ischcv=1 and isstpc=3, would I be emulating the TVD Bounded CD scheme? (Using CD whenever boundedness is ensured, and otherwise resorting to upwind 1st order). In essence, my goal, rather than being able to use ischcv=4, is to use a high-order scheme that ensures boundedness (lowering the order if necessary in that case).

Re: Cannot use TVD schemes

Posted: Wed May 15, 2024 9:45 pm
by Yvan Fournier
Hello,

I am not sure about this. I checked the code today, and I seeat least some schemes require defining a min/max value which is easy to define for scalarsbet less so for vectors (I.e. do we limit the norm or the components, or a combination thereof ?).

And as far as I know, the other options allow some balance between precision and robustness, but I am not sure about boundedness.

Best regards,

Yvan

Re: Cannot use TVD schemes

Posted: Fri May 17, 2024 2:42 am
by finzeo
Yvan Fournier wrote: Wed May 15, 2024 9:45 pm Hello,

I am not sure about this. I checked the code today, and I seeat least some schemes require defining a min/max value which is easy to define for scalarsbet less so for vectors (I.e. do we limit the norm or the components, or a combination thereof ?).

And as far as I know, the other options allow some balance between precision and robustness, but I am not sure about boundedness.

Best regards,

Yvan
Thank you, Yvan. I understand that the theory of TVD schemes ensures boundedness rigorously for 1D problems without calculating local extrema. I assume that using local extrema helps to ensure boundedness in more dimensions, is that correct?
Regardless, when implementing TVD schemes for velocity, isn't it possible to work directly with the equations for each velocity component separately? (I understand that other software like OpenFOAM does this). In that case, one would limit the value of the corresponding component in each scalar equation.

Re: Cannot use TVD schemes

Posted: Fri May 17, 2024 12:51 pm
by Yvan Fournier
Hello,

I'm not sure what would be best here. I'm not fond of working on a component by component basis for vectors, which should be invariant wrt the frame of reference.

I'll need to discuss this with colleagues who participated in the implementation of the scalar schemes.

Obviously, since the code is open source, anybody with the time and knowledge to experiment with changes to the code to implement TVD/NVD for vectors is also welcome.... :-)

Best regards,

Yvan

Re: Cannot use TVD schemes

Posted: Fri May 17, 2024 4:42 pm
by finzeo
Thank you, Yvan. I am open to contributing in any way I can, considering this is something that applies not only to my particular case.

Re: Cannot use TVD schemes

Posted: Sat May 18, 2024 12:32 am
by Yvan Fournier
Hello,

Yes, I would have been interested in testing this for some cases to improve robustness, but was stuck at this point, and am already too busy with other parts of the code to realistically expect to work on this in the near future. But helping others do it might add a bit of leverage.

Best regards

Yvan