Page 1 of 2

how to setup periodic temperature for an LES of a cuboid

Posted: Tue Dec 02, 2014 4:22 pm
by mkendrick
Hello there,

I'm attempting to model, using code_saturne 3.0.5, a cuboid which is periodic in the x (streamwise) and z directions. Heat is applied on walls in the y direction. (this is the same as the Kawamura DNS if you are familiar with the paper).

In this case to achieve a steady state a source (or sink) has to be included in the momentum and scalar transport equations to ensure, in the case of momentum, that the flow does not come to a halt, and, in the case of a scalar, that the addition of this scalar (i.e. heat through the walls in the case of temperature) does not cause an increase to infinity.

For the momentum equation I used a momentum balance to approximate the wall shear stress and then included that value as a momentum source (such that the two would cancel each other out at steady state). I did this through cs_user_source_terms.f90 with the following:

Code: Select all

if (.false.) return
! ----------------------------------------------
ckp  = 0
qdm  = <insert momentum source value here>
Now I am trying to address the scalar.
I've noted four options of how I might achieve this and my question is really which of these is the best to proceed with? or is there an easier way I've missed?
1. Use and the relation to find the value of
2. Intepret directly by taking an average temperature at the inlet and the outlet

Once I've been able to calculate I have two options of how I could apply it to the code
3. Simply subtract from the outlet and write this to the inlet
4. Provide a sink to the transport equation similar to how I applied a momentum source for the momentum equation

It seems to me that for calculating option 1. is the easiest.

Option 4. looks like something that could be achieved with cs_user_boundary_conditions.f90 unless there is some reason to do option 3.?
That being said I'm not very familiar with all of the subroutines offered so I may be missing a much easier way of doing this.

Thanks,
Martyn

Re: how to setup periodic temperature for an LES of a cuboid

Posted: Tue Dec 02, 2014 5:12 pm
by Yvan Fournier
Hello,

As an example, I attach a cs_user_source_terms.f90 (for 4.0 beta) for Kawamura LES from our own test suite (unfortunately, we cannot publish the whole test suite, as some cases are confidential, and others may use data which we cannot redistribute). ustsnv si used for the velocity source term, ustssc for the scalar (thermal scalar in this case).

Regards,

Yvan

Re: how to setup periodic temperature for an LES of a cuboid

Posted: Thu Dec 18, 2014 12:40 pm
by mkendrick
Thanks for that Yvan!

The source term now works as expected.

Re: how to setup periodic temperature for an LES of a cuboid

Posted: Thu Feb 12, 2015 4:20 pm
by mkendrick
Yvan,

I've been looking at the source terms you sent me for the Kawamura case.
Some of the functions used are not described in any of the guides (user, theory etc) although I am looking in the CS 3.0.5 guides. Where might I find an explanation of the calls to field_get_etc(...) or the function parsom(...)

Furthermore, I now understand that your source file is for the transport of the non-dimensionalized transformed temperature. I'd like to approach solving the Kawamura in the same way.

The equation solved in Kawamura is:


Would you be able to include any other files for the Kawamura test case? (if possible from CS 3.0.5, if not possible what other subroutines must be completed to ensure I calculate for a transformed temperature rather than temperature?)
Is there any reason you can think of that this could not be achieved in CS 3.0.5?


Kind regards,
Martyn

Re: how to setup periodic temperature for an LES of a cuboid

Posted: Fri Feb 13, 2015 1:59 am
by Yvan Fournier
Hello,

As some of the user documentation is migrating to Doxygen, 3.0 is in an "intermediate" stage.

For the documentation of field_..., I suggest the html (Doxygen) documentation of version 4.0 beta (the field_* functions have not changed much between versions 3 and 4).

parsom has been renamed in V4, so the Doxygen doc won'h help you much (unless you look at the "parall" series), but user examples (cs_user_extra_operations-parallel.f90) should help.

As for your other questions, you seem to know the Kawamura test case better than I do. I'll check with colleagues who are more familiar with that case. But if I am not mistaken, we have source terms both for the temperature and the velocity (as the case is handled as a periodic domain, it has no inlet or outlet; just wall friction compensated by a source term). So the term for velocity should also be in the example I sent you (in another subroutine of cs_user_source_terms).

Regards,

Yvan

Re: how to setup periodic temperature for an LES of a cuboid

Posted: Fri Feb 13, 2015 11:55 am
by mkendrick
Yvan,
You're right about the source terms for both temperature and velocity and the periodic boundaries.
The part that is concerning me is the diffusion coefficient, how can I ensure this is equal to ?

Re: how to setup periodic temperature for an LES of a cuboid

Posted: Mon Feb 16, 2015 6:07 pm
by mkendrick
I've done a bit more deriving and have found that:


can be re-arranged to give:


Thus the transported scalar is .
This would seem to agree with the source term file you attached. Could I just confirm this is indeed how the problem was tackled?

(full derivation attached)

Cheers,
Martyn

Re: how to setup periodic temperature for an LES of a cuboid

Posted: Thu Feb 19, 2015 12:32 pm
by mkendrick
I've nearly got this running now. However I'm experiencing the following error at runtime:
Field "velocity" has keyword 0 ("label")
of type "s" and not "i".
I had initially thought this was due to the

Code: Select all

call field_get_label
but I commented this out/changed it to

Code: Select all

call field_get_name
with no noticeable effect.

The code fails at the first time step. I have attached my SRC files incase I have made a mistake/not filled out something important.

Cheers,
Martyn

Re: how to setup periodic temperature for an LES of a cuboid

Posted: Thu Feb 19, 2015 6:47 pm
by Yvan Fournier
Hello,

I showed your derivation to colleagues, and at first glance, it seemed OK (it seems at least as detailed as the one we have).

As for your bug, It is a bit surprising, but could you also print the value of "ivar" (in a separate print statement) before the querying the value ? It may help check which variable causes the crash (though ustsnv should be called only for the velocity, so ivar should be equal to iu, which is always 2 in version 3.0).

Also, could you run the code under Valgrind (on a small mesh) to make sure (or almost) that you have no memory overwrite elsewhere ?

Regards,

Yvan

Re: how to setup periodic temperature for an LES of a cuboid

Posted: Fri Feb 20, 2015 1:51 pm
by mkendrick
The ivar values are as follows:

Code: Select all

 ivar for ustsnv
           2
 ivar for ustssc
           5
I've not used Valgrind before but will have a go at it and post up the results once I've figured it out.