CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [swak4Foam] parabolic velocity profile with fluctuations (groovyBC?) (https://www.cfd-online.com/Forums/openfoam-community-contributions/119431-parabolic-velocity-profile-fluctuations-groovybc.html)

newOFuser June 17, 2013 10:53

parabolic velocity profile with fluctuations (groovyBC?)
 
I would like to implement a parabolic inlet velocity profile, with fluctuation scale specified (like in turbulentInlet).

I tried using groovyBC as below (since I think turbulentInlet allows flat profile only), but am not sure how to specify the fluctuation scale (if possible?):

type groovyBC;
variables "yp=pts().y;minY=min(yp);maxY=max(yp);para=-(maxY-pos().y)*(pos().y-minY)/(0.25*pow(maxY-minY,2))*normal();";
valueExpression "15*para";
value uniform (15 0 0);

Has any one encountered a similar problem or has suggestions on how to proceed? I tried searching the forum but am not sure if including fluctuation scale in groovyBC has been discussed (though there were some posts on parabolic profile).

If not groovyBC, is there another way to implement this? I use OF 1.7.1

Many thanks,
amit


PS. This implementation is required as we are trying to match the experimental conditions which show a parabolic inlet profile and high fluctuations as well...

gschaider June 18, 2013 12:05

Quote:

Originally Posted by newOFuser (Post 434468)
I would like to implement a parabolic inlet velocity profile, with fluctuation scale specified (like in turbulentInlet).

I tried using groovyBC as below (since I think turbulentInlet allows flat profile only), but am not sure how to specify the fluctuation scale (if possible?):

type groovyBC;
variables "yp=pts().y;minY=min(yp);maxY=max(yp);para=-(maxY-pos().y)*(pos().y-minY)/(0.25*pow(maxY-minY,2))*normal();";
valueExpression "15*para";
value uniform (15 0 0);

Has any one encountered a similar problem or has suggestions on how to proceed? I tried searching the forum but am not sure if including fluctuation scale in groovyBC has been discussed (though there were some posts on parabolic profile).

If not groovyBC, is there another way to implement this? I use OF 1.7.1

Many thanks,
amit


PS. This implementation is required as we are trying to match the experimental conditions which show a parabolic inlet profile and high fluctuations as well...

You mean you want to add a random value to the profile? See the Reference-documentation that comes with the sources for the 4 random-number functions available with swak and pick the one that suits you. Then there is only the question whether you want to apply it absolute or relative, but that is something you must judge from your data

newOFuser June 19, 2013 11:54

Thanks so much, I'll look into the swak4Foam implementation.

amit

newOFuser June 20, 2013 14:28

Hello,

I am trying to install swak4Foam in OF 1.7.1 and get this error (tried both, the svn link file, and the tar file):

make: *** [Make/linux64GccDPOpt/FieldValueExpressionParser.o] Error 1
Parser library did not compile OK. No sense continuing as everything else depends on it
Requirements for Library not satisfied. I see no sense in going on


Configuration:

No 'swakConfiguration'. Python etc won't work
Checking swak4Foam-version and generating file
Bison is version 2.4.1
Flex is version 2.5.35 (Minor version: 35)
OpenFOAM-version: Major 1 Minor 7 Patch 1
No change to swak4FoamParsers/foamVersion4swak.H

Any suggestions?

gschaider June 20, 2013 20:18

Quote:

Originally Posted by newOFuser (Post 435098)
Hello,

I am trying to install swak4Foam in OF 1.7.1 and get this error (tried both, the svn link file, and the tar file):

make: *** [Make/linux64GccDPOpt/FieldValueExpressionParser.o] Error 1
Parser library did not compile OK. No sense continuing as everything else depends on it
Requirements for Library not satisfied. I see no sense in going on


Configuration:

No 'swakConfiguration'. Python etc won't work
Checking swak4Foam-version and generating file
Bison is version 2.4.1
Flex is version 2.5.35 (Minor version: 35)
OpenFOAM-version: Major 1 Minor 7 Patch 1
No change to swak4FoamParsers/foamVersion4swak.H

Any suggestions?

The Python-message is not a problem.

As for the error message: you've got to give me a bit more information to work with

newOFuser June 20, 2013 20:35

1 Attachment(s)
Thanks for the prompt reply!

Enclosed is the log file.

gschaider June 20, 2013 21:02

Quote:

Originally Posted by newOFuser (Post 435164)
Thanks for the prompt reply!

Enclosed is the log file.

I'm travelling and can't look into details. Seems there is a problem wit pointFields of vectors. Try the following: for all lines like
Code:

../FieldValueExpressionParser.yy:4777
go to the file FieldValueExpressionParser.yy and comment out line 4777. Most likely you're not going to need them anyway.

If you want a permanent fix write a report on the Mantis at openfoam-extend

newOFuser June 20, 2013 21:11

Thanks again! I'll look into this.

Pleasant travels! :)

newOFuser June 21, 2013 10:22

It compiled!

All those lines were this statement:
$$ = new Foam::pointSymmTensorField(*$1 - *$3);

Now, to see how the inlet velocity specification works out...

Thanks again,
amit

newOFuser June 21, 2013 14:32

Another quick question:

Here is what I am trying, based on
http://www.cfd-online.com/Forums/ope...b-mesh-10.html

inlet
{
type groovyBC;
variables "yp=pts().y;minY=min(yp);maxY=max(yp);para=-(maxY-pos().y)*(pos().y-minY)/(0.25*pow(maxY-minY,2))*normal();para_rms=1-0.5*para;";
valueExpression "15*para + 0.15*15*randNormal()*para_rms";
value uniform (15 0 0);
}

Since rms profile shown above is a reverse parabola, I am trying 1 - 0.5*para as the parabolic equation that gives a parabola with x=1 at Ymax and Ymin and x=1/2 at Ymiddle. (Later multiplied by random number and magnitude).

But this gives an error:
--> FOAM FATAL ERROR:
Parser Error for driver PatchValueExpressionDriver at "1.11-10" :"syntax error, unexpected $end"
"1-0.5*para"

Probably because the 1 in "1 - 0.5*para" should to be defined at each y (?)

How should this 'unity value at each point' be implemented in the valueExpression term?

Sorry if the question is vague or silly!

Thanks.

gschaider June 23, 2013 05:37

Quote:

Originally Posted by newOFuser (Post 435307)
It compiled!

All those lines were this statement:
$$ = new Foam::pointSymmTensorField(*$1 - *$3);

Now, to see how the inlet velocity specification works out...

Thanks again,
amit

Had a look: it seems that this is in theory already taken care of by the FOAM_INCOMPLETE_OPERATORS-define. The thing is that this is no longer needed in 1.7.x (but obviously in 1.7.1 and 1.7). So the alternative would have been a
Code:

#define FOAM_INCOMPLETE_OPERATORS

gschaider June 23, 2013 05:40

Quote:

Originally Posted by newOFuser (Post 435337)
Another quick question:

Here is what I am trying, based on
http://www.cfd-online.com/Forums/ope...b-mesh-10.html

inlet
{
type groovyBC;
variables "yp=pts().y;minY=min(yp);maxY=max(yp);para=-(maxY-pos().y)*(pos().y-minY)/(0.25*pow(maxY-minY,2))*normal();para_rms=1-0.5*para;";
valueExpression "15*para + 0.15*15*randNormal()*para_rms";
value uniform (15 0 0);
}

Since rms profile shown above is a reverse parabola, I am trying 1 - 0.5*para as the parabolic equation that gives a parabola with x=1 at Ymax and Ymin and x=1/2 at Ymiddle. (Later multiplied by random number and magnitude).

But this gives an error:
--> FOAM FATAL ERROR:
Parser Error for driver PatchValueExpressionDriver at "1.11-10" :"syntax error, unexpected $end"
"1-0.5*para"

Probably because the 1 in "1 - 0.5*para" should to be defined at each y (?)

How should this 'unity value at each point' be implemented in the valueExpression term?

Sorry if the question is vague or silly!

Thanks.

para is a vector. 1 is a scalar. Would be thankful for a description how to do this mathematically correctly ;)

Evariste June 25, 2013 18:49

Hi guys

I am a very new user of OpenFoam and I am interested in a similar problem as GK. I would like to implement some random fluctuations to a parabolic profile. I have already implemented a parabolic profile as an extra utility based on another thread. (http://openfoamwiki.net/index.php/Tu....28OF-1.4.1.29)

For this I provide at the input file 0/U)


type parabolicVelocity;
n (1 0 0);
y (0 1 0);
maxValue 1;
value (0 0 0); // Dummy for paraFoam, which will NOT show a correct profile at time 0.


I know that Open foam has implemented already an utility called turbulent Inlet so I guess that a first quick fix would be some how try to combine these two.

I need one extra line at the inlet that will give the level of fluctuations something like

fluctuationScale ( 0.1 0.001 0.001 );

and change my code file so for every value of the parabolic profile I add an extra term such as 0.1*Umax*random_number which I guess is already calculated in the turbulent inlet utility.

I was wondering if anyone has already done something like this. My C++ knowledge is not great (I come from a fortran background) so if anyone has any advice would be very useful. Which parts of the turbulent inlet utility I need to add to my parabolic profile utility?

Thanks

gschaider June 26, 2013 03:57

Quote:

Originally Posted by Evariste (Post 435961)
Hi guys

I am a very new user of OpenFoam and I am interested in a similar problem as GK. I would like to implement some random fluctuations to a parabolic profile. I have already implemented a parabolic profile as an extra utility based on another thread. (http://openfoamwiki.net/index.php/Tu....28OF-1.4.1.29)

For this I provide at the input file 0/U)


type parabolicVelocity;
n (1 0 0);
y (0 1 0);
maxValue 1;
value (0 0 0); // Dummy for paraFoam, which will NOT show a correct profile at time 0.


I know that Open foam has implemented already an utility called turbulent Inlet so I guess that a first quick fix would be some how try to combine these two.

I need one extra line at the inlet that will give the level of fluctuations something like

fluctuationScale ( 0.1 0.001 0.001 );

and change my code file so for every value of the parabolic profile I add an extra term such as 0.1*Umax*random_number which I guess is already calculated in the turbulent inlet utility.

I was wondering if anyone has already done something like this. My C++ knowledge is not great (I come from a fortran background) so if anyone has any advice would be very useful. Which parts of the turbulent inlet utility I need to add to my parabolic profile utility?

I think you're in the wrong thread: the point of groovyBC/swak4Foam is to avoid programming C++ for boundary-conditions etc especially if they are very specific for one case

Evariste June 26, 2013 16:11

Hi Bernhard

Thanks for your reply. Sorry if I am in the wrong thread but what I want to do is to use a parabolic profile with fluctuations which is the title of the thread. However you are right I do not want to use groovy because to be honest I see this task a bit as good opportunity to get some programming practice in C++ . Any suggestions are welcome.

newOFuser July 15, 2013 14:38

I was able to implement the velocity profile as desired, using swak4Foam.

I have a minor query:
The value expression is defined as:
valueExpression "15*para + 0.15*15*randNormal()*para_rms";

Is there a way by which I can specify valueExpression as "15*para" for time < 0.1s, and "15*para + 0.15*15*randNormal()*para_rms" for time > 0.1s ?

thanks so much!
amit


Quote:

Originally Posted by gschaider (Post 435420)
para is a vector. 1 is a scalar. Would be thankful for a description how to do this mathematically correctly ;)


gschaider July 15, 2013 17:15

Quote:

Originally Posted by newOFuser (Post 439859)
I was able to implement the velocity profile as desired, using swak4Foam.

I have a minor query:
The value expression is defined as:
valueExpression "15*para + 0.15*15*randNormal()*para_rms";

Is there a way by which I can specify valueExpression as "15*para" for time < 0.1s, and "15*para + 0.15*15*randNormal()*para_rms" for time > 0.1s ?

thanks so much!
amit

Yep. There is: the ?:-operator (the semantics of this operator have been explained for approximately 1243 times)
Code:

"15*para + time()<0.1 ? vector(0,0,0) : 0.15*15*randNormal()*para_rms"
or (a bit more elegant) with a variable
Code:

variables (
... other variables
"factor=time()<0.1 ? 0 : 0.15*15*randNormal();"
);
valueExpression "15*para+para_rms*factor";


newOFuser July 15, 2013 17:27

thanks^1243


All times are GMT -4. The time now is 16:20.