CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (http://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   Parabolic velocity profile Booundary condition (http://www.cfd-online.com/Forums/openfoam-pre-processing/116299-parabolic-velocity-profile-booundary-condition.html)

Guenda April 16, 2013 17:30

Parabolic velocity profile Booundary condition
 
Hi!

I'd like to impose parabolic profile of velocity at inlet of my 3D Y-pipes shape because I'm simulating poiseuille flow.
As the flow is driven by velocity I leave 'free' P at inlet, outlet and wall (zeroGradient). the internalField is uniform (0).

I write the following 0/U file:
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ** * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
inlet
{
type codedFixedValue;
value $internalField;
redirectType ramp;
code
#{
scalar U_0=(0 0 0.049954); //mean U.This isn't the max velocity of the profile.
scalar r=0.02; //mean Radius. in the 3 pipes radius are different.
fixedValueFvPatchVectorField myPatch(*this);
forAll(this->patch().Cf(),i)
{
myPatch[i]=vector(2*U_0*(1-Foam:Pow(this->patch().Cf()[i].x(),2)/pow(r,2)),0,0);
}
operator==(myPatch);
#};
}
outlet
{
type zeroGradient;

}
Walls
{
type fixedValue;
value uniform (0 0 0);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ** * * //

There should be something wrong because I have and error runing icoFoam...
Can you help me?????:confused:

thank you so much.

Akshay April 17, 2013 02:02

Hey Elisa
Could you post the error message?

Akshay

Guenda April 17, 2013 10:14

This is the error I have:

--> FOAM FATAL IO ERROR:
Loading a shared library using case-supplied code is not enabled by default
because of security issues. If you trust the code you can enable this
facility be adding to the InfoSwitches setting in the system controlDict:

allowSystemOperations 1

The system controlDict is either

~/.OpenFOAM/$WM_PROJECT_VERSION/controlDict

or

$WM_PROJECT_DIR/etc/controlDict



file: /home/cosine/OpenFOAM/cosine-2.2.0/run/config1/0/U.boundaryField.inlet from line 35 to line 39.

From function codedBase::updateLibrary()
in file db/dynamicLibrary/dynamicCode/dynamicCode.C at line 81.

FOAM exiting

Any suggestion?

Akshay April 17, 2013 10:19

Hey Elisa
You need to enable the 'allowSystemOperations' switch if you want to use codestream. You should find this in the /etc/controlDict file as the error log suggests. It'll be in the InfoSwitches block. Just make it '1'.
Try this and let me know if it's working.
Cheers!
Akshay

Guenda April 17, 2013 11:38

Yes, it seems working!
But I still have the problem in 0/U.boundaryField.inlet folder. Do you know the meaning of it?
The error is the following:

--> FOAM FATAL IO ERROR:
Failed wmake "dynamicCode/ramp/platforms/linux64GccDPOpt/lib/libramp_4339e3a808a66e5078fd653aa8a6180bb899c643.s o"


file: /home/cosine/OpenFOAM/cosine-2.2.0/run/config1/0/U.boundaryField.inlet from line 35 to line 39.

From function codedBase::createLibrary(..)
in file db/dynamicLibrary/codedBase/codedBase.C at line 202.

FOAM exiting

Thank you!!!

Akshay April 17, 2013 11:49

............

Guenda April 17, 2013 14:58

:eek: Does it mean that you don't have any idea?

Akshay April 17, 2013 23:29

Hey
Just a few small changes here. Works for me.

#{
scalar U_0=0.049954; //mean U.This isn't the max velocity of the profile.
scalar r=0.02; //mean Radius. in the 3 pipes radius are different.
fixedValueFvPatchVectorField myPatch(*this);
forAll(this->patch().Cf(),i)
{
myPatch[i]=vector(2*U_0*(1-Foam : : pow(this->patch().Cf()[i].x(),2)/Foam : : pow(r,2)),0,0);
}
operator==(myPatch);
#};

I've intentionally given spaces between the Foam : : pow otherwise the smiley appears :p

Cheers!
Ak

Guenda April 23, 2013 10:52

Thank you so much!

Actually I'm really confused: now I have this kind of error: :mad:

--> FOAM FATAL ERROR:
Unknown functionEntry '' in "C:/Users/Administrator/Desktop/OpenFOAM/USRNAME-1.
.0/Y/0/U" near line 48

Valid functionEntries are :

4
(
include
includeIfPresent
inputMode
remove
)


From function functionEntry::execute(const word& functionName, dictionary&
arentDict, Istream&)
in file db/dictionary/functionEntries/functionEntry/functionEntry.C at line
83.

FOAM exiting

what is the meaning of this error?? how can I try to fix it? :confused:
Sorry for all my questions!!!! :(

Guenda April 23, 2013 12:26

I forgot to write that as soon as the simulation starts this warning appears:

--> FOAM Warning :
From function IOstream::compressionEnum(const word&)
in file db/IOstreams/IOstreams/IOstream.C at line 74
bad compression specifier 'off', using 'uncompressed'
Create mesh for time = 0

Akshay April 24, 2013 10:03

well well well...i'll need to look at your U file. send it across..and also your controlDict.

Guenda April 24, 2013 11:50

I should have fixed the 'warning' changing in controlDict 'writeCompression off;' in 'uncompressed;'. I don't have that warning but I still have the error.

My 0/U file is:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 1 -1 0 0 0 0];

internalField uniform (0 0 0);

boundaryField
{
inlet
{
//type zeroGradient; //for simpleFOAM

//type freestream;
//freestreamValue uniform (0 0 0 4.94745);

//uniche condizioni x cui si ha qlc:
//type fixedValue; //pressureInletVelocity;
//value uniform (0 0 0.049954); //codice matlab 1/3

//Profilo parabolico
type codedFixedValue;
value $internalField;
redirectType ramp;
code
#{
scalar U_0=0.049954; //Umean
scalar r=11.75; //radius
fixedValueFvPatchVectorField myPatch(*this);
forAll (this->patch().Cf(),i)
{
myPatch[i]=vector(2*U_0*(1-Foam:: pow(this->patch(),Cf()[i].x(),2)/Foam:: pow(r,2)),0,0);
}
operator==(myPatch);
#};
}

outlet
{
type zeroGradient; //freestream;

//freestreamValue uniform (0 0 1.44048);

//type fixedValue;
//value uniform (0 0 0.0716);
}

wall
{
//type zeroGradient;

type fixedValue;
value uniform (0 0 0);
}

//defaultFaces
//{
// type zeroGradient;
// }
}

// ************************************************** *********************** //

and controlDict:

application icoFoam;

startFrom startTime;

startTime 0;

stopAt endTime;

endTime 0.5;

deltaT 0.067909;

writeControl timeStep;

writeInterval 1;

purgeWrite 0;

writeFormat ascii;

writePrecision 6;

writeCompression uncompressed;

timeFormat general;

timePrecision 6;

thank you! :)

Guenda May 14, 2013 06:11

Now I am thinking: could my error come from the old version of OpenFOAM that I'm using? I mean, is it possibile to create a parbolic profile in the openFOAM 1.7.0 version?? :confused:

Thank you!!!

openfoam_user May 15, 2013 03:02

Hi Guenda,

I think it is easier if you use swak4foam capability.

Have a look at the following link (4.2.2 Swirl on inlet)
http://openfoamwiki.net/index.php/Contrib_groovyBC

Add following lines in your 0/U file:

INLET
{
type groovyBCFixedValue;
variables (
"velIn=0.05;" //velIn is the normal mean inlet velocity
"c=sum(pos()*mag(Sf()))/sum(mag(Sf()));" //c is the centre of the patch
"n=sum(normal())/mag(sum(normal()));" //n is the averaged patch normal
"pp=pos()-c;"
"r=mag(pp)+1.0e-10;"
"R=max(r);"
);
valueExpression "-velIn*normal()*(1-pow(r/R,2))";
value uniform (0.05 0 0);
}

And add following lines in your system/controlDict file:

libs (
"libOpenFOAM.so"
"libgroovyBC.so"
"libgroovyStandardBCs.so"
"libsimpleFunctionObjects.so"
"libsimpleSwakFunctionObjects.so"
"libswakFunctionObjects.so"
) ;

Regards,
Stephane.

sandy13 October 30, 2013 07:14

Dear openfoam_user,
I had a look at your post no #14 in this thread. Because I need a 3D B.C parabolic for my inlet velocity, so I used your code for my solver interFoam with OF2.1.1. It works very well but I have a question about it. When I visualize the velicity profile with paraFoam, i do not get the parabolic profile for the time step 0, but once I start the simulation I get it directly for the first time step(after 0). Is this correct? should not we get it from the 0 time step we we visualize?
Thank you so much in advance..
Sandy13,

gschaider October 30, 2013 07:21

Quote:

Originally Posted by sandy13 (Post 459847)
Dear openfoam_user,
I had a look at your post no #14 in this thread. Because I need a 3D B.C parabolic for my inlet velocity, so I used your code for my solver interFoam with OF2.1.1. It works very well but I have a question about it. When I visualize the velicity profile with paraFoam, i do not get the parabolic profile for the time step 0, but once I start the simulation I get it directly for the first time step(after 0). Is this correct? should not we get it from the 0 time step we we visualize?
Thank you so much in advance..
Sandy13,

The problem is that the paraview reader does not "understand" complicated boundary conditions. It needs the value-field to be set. If it is fixed in time you can work around by copying it over from a later time-step with a text editor (just the value-entry)

openfoam_user October 30, 2013 07:54

Dear Sandy13,

I have checked one of my computations. You are right. At time step 0 sec you don't have the parabolic profile yet. Only the following velocity values are imposed (from my above example): value uniform (0.05 0 0).

Best regards,
Stephane.


All times are GMT -4. The time now is 18:19.