CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (https://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   Time varying surfaceNormalFixedValue BC with codeStream (https://www.cfd-online.com/Forums/openfoam-pre-processing/115337-time-varying-surfacenormalfixedvalue-bc-codestream.html)

francois March 28, 2013 10:31

Time varying surfaceNormalFixedValue BC with codeStream
 
Dear Foamers,

I would like to change the value of the surfaceNormalFixedValue inlet velocity according to the current time step.

I want to build a simple ramped inlet condition using the surfaceNormalFixedValue BC
.

But I got stuck when I want to access the current time step using codeStream.

My code is as follows:

Code:

"Inlet"
    {
        type surfaceNormalFixedValue;
        uBegin  -0.0011968512;
        uEnd  -0.023937024;
        it0  50;
        iter #calc "runTime.time().value()";
        refValue uniform  #calc "max($uEnd,$uBegin + (($uEnd-$uBegin)/$it0)*$iter)";
    }

I got the following error message:

Code:

: In function ‘void Foam::codeStream_511e83c811264e2205bc04185da775a50640cef3(Foam::Ostream&, const Foam::dictionary&)’:
:0:8: error: ‘runTime’ was not declared in this scope
make: *** [Make/linux64GccDPOpt/codeStreamTemplate.o] Error 1

Any idea to obtain the current time step with #CodeStream ?

Thank you very much
Regards
Francois

francois March 29, 2013 03:55

I've tried with

Code:

this->db().time().value()
without more luck :D

gschaider April 5, 2013 14:19

Quote:

Originally Posted by francois (Post 417134)
I've tried with

Code:

this->db().time().value()
without more luck :D

"this" is a patchField. So my guess is that you have to get the patch first. Something like
Code:

this->patch().mesh().time().value()
but my memory is notoriously bad with that kind of things and I'll have to look it up in Doxygen anytime. That's why I wrote me groovyBC and write something like
Code:

type groovyBC;
variables (
        "uBegin=-0.0011968512;"
        "uEnd=-0.023937024;"
        "it0=50;"
);
valueExpression "normal()*max(uEnd,uBegin+((uEnd-uBegin)/it0)*time())";

(I like to keep my cases and my coding separate)

One note: getting the time seems like quite a common task to me. I'd suggest that you guys do a collection of this and similar snipplets (possibly on the Wiki) for the coded-way. This way I will stop bothering anyone with "come to the dark side, Luke"-postings


All times are GMT -4. The time now is 21:33.