CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

codedFixedValue boundary condition

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree7Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 20, 2012, 12:41
Default
  #21
Senior Member
 
Goutam Saha
Join Date: Dec 2011
Location: UK
Posts: 131
Rep Power: 14
Goutam is on a distinguished road
[CODE]

inlet
{
type codedFixedValue;
value $internalField;
redirectType ramp;
code
#{
scalar U_0 = 0.003,
scalar r = 0.025;
fixedValueFvPatchField<vector> myPatch(
this->Cf().size());
forAll(this->Cf(), i)
{
myPatch[i] = vector( 2*U_0*(1 - Foam:ow(this->Cf()[i].x(), 2) / r / r )),0,0);
}
(*this)== myPatch;
#};
}

I got the following error:

Using dynamicCode for patch inlet on field U at line 25 in "/home/thermo/gsaha/OpenFOAM/gsaha-2.1.0/run/tutorials/incompressible/simpleFoam/parabolicflow/0/U::boundaryField::inlet"
Creating new library in "dynamicCode/ramp/platforms/linux64GccDPOpt/lib/libramp_33868748d21fc6c5f633c2f3604861e34d0d7dc7.s o"
Invoking "wmake -s libso /home/thermo/gsaha/OpenFOAM/gsaha-2.1.0/run/tutorials/incompressible/simpleFoam/parabolicflow/dynamicCode/ramp"
wmakeLnInclude: linking include files to ./lnInclude
Making dependency list for source file fixedValueFvPatchFieldTemplate.C
/home/thermo/gsaha/OpenFOAM/gsaha-2.1.0/run/tutorials/incompressible/simpleFoam/parabolicflow/0/U::boundaryField::inlet: In member function ‘virtual void Foam::rampFixedValueFvPatchVectorField::updateCoef fs()’:
/home/thermo/gsaha/OpenFOAM/gsaha-2.1.0/run/tutorials/incompressible/simpleFoam/parabolicflow/0/U::boundaryField::inlet:32: error: ‘class Foam::rampFixedValueFvPatchVectorField’ has no member named ‘Cf’
/home/thermo/gsaha/OpenFOAM/gsaha-2.1.0/run/tutorials/incompressible/simpleFoam/parabolicflow/0/U::boundaryField::inlet:32: error: expected primary-expression before ‘)’ token
/home/thermo/gsaha/OpenFOAM/gsaha-2.1.0/run/tutorials/incompressible/simpleFoam/parabolicflow/0/U::boundaryField::inlet:32: error: expected ‘;’ before ‘)’ token
/home/thermo/gsaha/OpenFOAM/gsaha-2.1.0/run/tutorials/incompressible/simpleFoam/parabolicflow/0/U::boundaryField::inlet:33: error: ‘class Foam::rampFixedValueFvPatchVectorField’ has no member named ‘Cf’
/home/thermo/gsaha/OpenFOAM/gsaha-2.1.0/run/tutorials/incompressible/simpleFoam/parabolicflow/0/U::boundaryField::inlet:33: error: ‘class Foam::rampFixedValueFvPatchVectorField’ has no member named ‘Cf’
/home/thermo/gsaha/OpenFOAM/gsaha-2.1.0/run/tutorials/incompressible/simpleFoam/parabolicflow/0/U::boundaryField::inlet:33: error: expected ‘;’ before ‘)’ token
make: *** [Make/linux64GccDPOpt/fixedValueFvPatchFieldTemplate.o] Error 1


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


file: /home/thermo/gsaha/OpenFOAM/gsaha-2.1.0/run/tutorials/incompressible/simpleFoam/parabolicflow/0/U::boundaryField::inlet from line 25 to line 30.

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

FOAM exiting
Goutam is offline   Reply With Quote

Old   March 20, 2012, 17:40
Default
  #22
Senior Member
 
Wouter van der Meer
Join Date: May 2009
Location: Elahuizen, Netherlands
Posts: 203
Rep Power: 17
wouter is on a distinguished road
hello,

there is a , instead of ;
scalar U_0 = 0.003,

But you probably found that already.

all the best,
Wouter
wouter is offline   Reply With Quote

Old   March 21, 2012, 04:28
Default Error code: has no member named ‘Cf’
  #23
Senior Member
 
Goutam Saha
Join Date: Dec 2011
Location: UK
Posts: 131
Rep Power: 14
Goutam is on a distinguished road
[CODE]

inlet
{
type codedFixedValue;
value $internalField;
redirectType ramp;
code
#{
scalar U_0 = 0.003;
scalar r = 0.025;
fixedValueFvPatchField<vector> myPatch(
this->Cf().size());
forAll(this->Cf(), i)
{ myPatch[i] = vector( 2*U_0*(1 - Foamow(this->Cf()[i].x(), 2) / pow(r,2)),0,0); }
(*this)== myPatch;
#};
}

I got the following error:

/home/thermo/gsaha/OpenFOAM/gsaha-2.1.0/run/tutorials/incompressible/simpleFoam/parabolicflow/0/U::boundaryField::inlet:32: error: ‘class Foam::rampFixedValueFvPatchVectorField’ has no member named ‘Cf’
/home/thermo/gsaha/OpenFOAM/gsaha-2.1.0/run/tutorials/incompressible/simpleFoam/parabolicflow/0/U::boundaryField::inlet:33: error: ‘class Foam::rampFixedValueFvPatchVectorField’ has no member named ‘Cf’
/home/thermo/gsaha/OpenFOAM/gsaha-2.1.0/run/tutorials/incompressible/simpleFoam/parabolicflow/0/U::boundaryField::inlet:33: error: ‘class Foam::rampFixedValueFvPatchVectorField’ has no member named ‘Cf’
make: *** [Make/linux64GccDPOpt/fixedValueFvPatchFieldTemplate.o] Error 1

Thanks All
Goutam is offline   Reply With Quote

Old   March 22, 2012, 02:15
Default
  #24
New Member
 
Join Date: Mar 2012
Posts: 12
Rep Power: 14
November is on a distinguished road
Greetings guys...
I want to apply a codedFixedValue to a 0/p for the inlet of an oscillatory flow... according to NS equation that p value should have something like p=-2*pi*f*U_m*cos(2*pi*f*t)x, so at left boundary x=-20 therefore this equation becomes p=-2*pi*f*U_m*cos(2*pi*f*t)*(-20).

I want to realize that p BC by codedFixedValue as following:
inlet
{
type codedFixedValue;
value uniform 0;
redirectType rampedFixedValue;
code
#{

operator==40*3.141*1*cos(3.141*0.5*this->db().time().value());

#};
}

However I keep getting the following error msg:

Quote:
--> 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/kyang/OpenFOAM/OpenFOAM-2.1.0/icoFoam-t/3DCylinder/0/p::boundaryField::inlet from line 35 to line 39.

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

FOAM exiting
I wonder if in order to use the codedFixedValue, one has to do something like in the msg: "adding to the InfoSwitches setting in the system controlDict: allowSystemOperations 1"?? But I'm not sure how exactly to do that?? What is the InfoSwitches setting in controlDict?? I copied "allowSystemOperations 1" to controlDict and it didnt work....
November is offline   Reply With Quote

Old   March 22, 2012, 15:45
Default
  #25
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings November,

Quote:
Originally Posted by November View Post
I wonder if in order to use the codedFixedValue, one has to do something like in the msg: "adding to the InfoSwitches setting in the system controlDict: allowSystemOperations 1"?? But I'm not sure how exactly to do that?? What is the InfoSwitches setting in controlDict?? I copied "allowSystemOperations 1" to controlDict and it didnt work....
I've written about this some time ago... read this section: 2.1 Additional tuning

Best regards,
Bruno
__________________

Last edited by wyldckat; April 11, 2012 at 16:36. Reason: typo
wyldckat is offline   Reply With Quote

Old   March 23, 2012, 00:16
Default
  #26
New Member
 
Join Date: Mar 2012
Posts: 12
Rep Power: 14
November is on a distinguished road
Quote:
Originally Posted by wyldckat View Post
Greetings November,


I written about this some time ago... read this section: 2.1 Additional tuning

Best regards,
Bruno
Thanks a lot Bruno!!! I can apply the coded BC now however...

I am trying to simulate a very easy problem - oscillatory flow around a circular cylinder (3D), however I got stuck for the inlet and outlet boundary conditions here... and have been searching the web for solutions but without luck..
so, I want a inlet velocity at u_x=U_m*sin(2*pi*f*t), U_m=1m/s, u_y=0, u_z=0. Therefore I have specified for the inlet and outlet BC in 0/u as followings:

code:
Quote:
inlet
{
type oscillatingFixedValue;
refValue uniform (0 0 0);
//offset (0 -1 0);
amplitude constant 1;
frequency constant 0.5;
value uniform (0 0 0);//dummy OF

outlet
{
type zeroGradient;
}
and for the 0/p, I first tried to put for inlet the "fixedValue=0" but the results are not good. So I guessed according to NS, dp/dx=-du/dt at inlet, therefore dp/dx can bu calculated according to u_x, and do an intergral one gets the p=-2*pi*f*U_m*cos(2*pi*f*t)*x....So I decided to use the codedFixedValue for that p:

Quote:
inlet
{
type codedFixedValue;
value uniform 0;
redirectType rampedFixedValue; // what does this mean??
code
#{

(*this)==40*3.141*1*cos(3.141*0.5*this->db().time().value()); // 40 because x=-20 at inlet

#};
}
outlet
{
type fixedValue;
value 0;
}
But the results gets non-convergent after sometime...

Specifying the BC of inlet and outlet for an oscillatory flow around a circular cylinder... It looks easy however I couldnt find an example as how people did it... I am really confused now...Could you give me some hints??? Thanks in advance!!
November is offline   Reply With Quote

Old   April 11, 2012, 11:18
Default
  #27
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Quote:
Originally Posted by Goutam View Post
[CODE]

I got the following error:

/home/thermo/gsaha/OpenFOAM/gsaha-2.1.0/run/tutorials/incompressible/simpleFoam/parabolicflow/0/U::boundaryField::inlet:32: error: ‘class Foam::rampFixedValueFvPatchVectorField’ has no member named ‘Cf’
/home/thermo/gsaha/OpenFOAM/gsaha-2.1.0/run/tutorials/incompressible/simpleFoam/parabolicflow/0/U::boundaryField::inlet:33: error: ‘class Foam::rampFixedValueFvPatchVectorField’ has no member named ‘Cf’
/home/thermo/gsaha/OpenFOAM/gsaha-2.1.0/run/tutorials/incompressible/simpleFoam/parabolicflow/0/U::boundaryField::inlet:33: error: ‘class Foam::rampFixedValueFvPatchVectorField’ has no member named ‘Cf’
make: *** [Make/linux64GccDPOpt/fixedValueFvPatchFieldTemplate.o] Error 1

Thanks All
Hi Goutam,

Had you any luck applying your BC????

Anyways, this works with me:
Code:
this->patch().Cf()
Best regards,
Hisham

Last edited by Hisham; April 11, 2012 at 13:51.
Hisham is offline   Reply With Quote

Old   April 12, 2012, 05:22
Default
  #28
Senior Member
 
Goutam Saha
Join Date: Dec 2011
Location: UK
Posts: 131
Rep Power: 14
Goutam is on a distinguished road
I wrote the following code and now its working:

inlet
{
type codedFixedValue;
value $internalField;
redirectType ramp;

code
#{
scalar U_0=0.001934;
scalar r=0.02595;
fixedValueFvPatchVectorField myPatch(*this);
forAll(this->patch().Cf(),i)
{
myPatch[i]=vector(2*U_0*(1-Foam:ow(this->patch().Cf()[i].x(),2)/r/r),0,0);
}
operator==(myPatch);
#};
}

Last edited by Goutam; April 13, 2012 at 06:45.
Goutam is offline   Reply With Quote

Old   September 6, 2012, 08:12
Default
  #29
New Member
 
Ali Abbasi
Join Date: Apr 2012
Location: Delft, The Netherlands
Posts: 12
Rep Power: 13
aabbasi59 is on a distinguished road
Send a message via Skype™ to aabbasi59
Hi Friends,
I want to use codedFixedValue boundaryfield for boundary condition in Inlet for U. If I used constant value for equation it works but when I want to put values from another file it doesn't work. How can I force this patch-type for reading a constant from another file(e.g., include/initials)??
My code is:
inlet
{
type codedFixedValue;
redirectType velocity_inlet;
code
#{
scalar Ustar=$Ustar;;
scalar k=0.42;
scalar z0=2.25e-4;
fixedValueFvPatchVectorField myPatch(*this);
forAll(this->patch().Cf(),i)
{
myPatch[i]=vector(Ustar/k*(Foam::log((this->patch().Cf()[i].y()+z0)/z0)),0,0);
}
operator==(myPatch);
#};

value $internalField;
}


and I get the error below:
‘Ustar’ was not declared in this scope

Thanks a lot in advance.
Ali
aabbasi59 is offline   Reply With Quote

Old   September 14, 2012, 09:28
Default
  #30
New Member
 
ae-lab VUB
Join Date: Oct 2011
Posts: 17
Rep Power: 14
aevub is on a distinguished road
Hi
I am trying to make a ramped BC as mentioned above (Tomasso Lucchini's rampedFixedValue BC).

It compiles, but when using it in the cavitycase I get this error:


Foam::error:rintStack(Foam::Ostream&) in "/home/mvdtempe/OpenFOAM/OpenFOAM-2.1.x/platforms/linuxGccDPOpt/lib/libOpenFOAM.so"
Foam::sigSegv::sigHandler(int) in "/home/mvdtempe/OpenFOAM/OpenFOAM-2.1.x/platforms/linuxGccDPOpt/lib/libOpenFOAM.so"
Uninterpreted:
void Foam::dot<Foam::Vector<double>, Foam::Vector<double>, Foam::fvsPatchField, Foam::surfaceMesh>(Foam::GeometricField<Foam::inne rProduct<Foam::Vector<double>, Foam::Vector<double> >::type, Foam::fvsPatchField, Foam::surfaceMesh>&, Foam::GeometricField<Foam::Vector<double>, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvsPatchField, Foam::surfaceMesh> const&) in "/home/mvdtempe/OpenFOAM/OpenFOAM-2.1.x/platforms/linuxGccDPOpt/bin/icoFoam"

at icoFoam.C:0

in "/home/mvdtempe/OpenFOAM/OpenFOAM-2.1.x/platforms/linuxGccDPOpt/bin/icoFoam"
__libc_start_main in "/lib/i386-linux-gnu/libc.so.6"
in "/home/mvdtempe/OpenFOAM/OpenFOAM-2.1.x/platforms/linuxGccDPOpt/bin/icoFoam"
Segmentation fault (core dumped)


...?
I use 2.1.x
aevub is offline   Reply With Quote

Old   December 12, 2014, 05:43
Default
  #31
New Member
 
hello
Join Date: Nov 2014
Posts: 3
Rep Power: 11
hesong is on a distinguished road
I am trying to define a boundary condition, T(Temperature) will change with a Z(coordinates). But I don’t know ,which boundary should I user ,movingwall or front,etc;
I NEED HELP

myPatch
{
type codedFixedValue;
value uniform 0;
redirectType myFixedValue; // name of generated BC

code
#{
forAll(*this, i)
{
scalar z = patch().Cf()[i][2];
if (z > 0 && z < 32)
(*this)[i] = 0.0075 * z -1.58;
else if (...)
...;
else
...;
}
#};

codeInclude
#{
#include "fvCFD.H"
#};

codeOptions
#{
-I$(LIB_SRC)/finiteVolume/lnInclude
#};
hesong is offline   Reply With Quote

Old   December 12, 2014, 05:49
Default
  #32
New Member
 
Ali Abbasi
Join Date: Apr 2012
Location: Delft, The Netherlands
Posts: 12
Rep Power: 13
aabbasi59 is on a distinguished road
Send a message via Skype™ to aabbasi59
@hesong
Why don't you use groovyBC!? For your B.C the groovyBC could be the best choice.
aabbasi59 is offline   Reply With Quote

Old   December 12, 2014, 06:00
Default
  #33
New Member
 
hello
Join Date: Nov 2014
Posts: 3
Rep Power: 11
hesong is on a distinguished road
Quote:
Originally Posted by aabbasi59 View Post
@hesong
Why don't you use groovyBC!? For your B.C the groovyBC could be the best choice.
thank you !
could you provide some detailed information
I just learn this software for several months.
hesong is offline   Reply With Quote

Old   December 12, 2014, 06:08
Default
  #34
New Member
 
Ali Abbasi
Join Date: Apr 2012
Location: Delft, The Netherlands
Posts: 12
Rep Power: 13
aabbasi59 is on a distinguished road
Send a message via Skype™ to aabbasi59
Using groovyBC for complex BCs is straightforward. You can search it in the forum and find a lot of resources on working with groovyBC and swak4FOAM:
https://openfoamwiki.net/index.php/Contrib/groovyBC
https://openfoamwiki.net/index.php/Contrib/swak4Foam
http://www.cfd-online.com/Forums/tags/groovybc.html
http://www.cfd-online.com/Forums/ope...locity-bc.html
I hope you can find your solution.
aabbasi59 is offline   Reply With Quote

Old   April 23, 2015, 11:50
Default
  #35
Member
 
Mehtab
Join Date: Jan 2015
Posts: 41
Rep Power: 11
mehtab is on a distinguished road
Hi Foamers,

I want to implement a boundary condition at inlet.

𝑇_𝑠=𝑇_0+1/𝐶_𝑝 [𝑄_𝑓/(𝑚*̇ " )*̇ −𝐻_𝑣𝑎𝑝 ]


In this equation Q_f and 𝑚*̇ " need to be taken from inlet at previous time step.

Is it possible to do it using grovyBC or codedFixedValue in Openfoam? Which one be easier to implement?

Thanks in advance.....
mehtab is offline   Reply With Quote

Old   April 14, 2016, 02:51
Default
  #36
Senior Member
 
Join Date: Sep 2015
Location: Singapore
Posts: 102
Rep Power: 10
usv001 is on a distinguished road
Hello everybody,

I am experimenting with #codestream and codedFixedValue boundary conditions. I was able to implement #codeStream successfully for the internalField. But I am having a lot of trouble with codedFixedValue. I can't even get the example code given in the documentation to work. The code is compiling without mistakes but when I view it in Paraview it is applying the value (uniform 0) that is specified for 'value'. Any idea why codedFixedValue does not work for me?

By the way, I am using OF 2.1.1. Thank you very much.
usv001 is offline   Reply With Quote

Old   April 14, 2016, 06:08
Default
  #37
Senior Member
 
Join Date: Sep 2015
Location: Singapore
Posts: 102
Rep Power: 10
usv001 is on a distinguished road
I want to try something advanced but I am not sure of OF syntax and such.I just want to clarify if this code is supposed to work. It is just setting some fixed value.

Code:
NOZZLE_INLET
    {
        type 		codedFixedValue;
	value 		uniform 400000;
	redirectType	random;

    code
    #{
        operator == (200000);
    #};


    codeInclude
    #{
        #include "fvCFD.H"
    #};

    codeOptions
    #{
        -I$(LIB_SRC)/finiteVolume/lnInclude
    #};

    }
I know this doesn't require codedFixedValue but just wondering if it should work. Like I said in my previous post, the codedFixedValue does not show any errors when I run Paraview but it shows 400000 for the patch instead of 200000.

Once again, thanks everyone.
usv001 is offline   Reply With Quote

Old   April 15, 2016, 18:10
Default
  #38
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quote:
Originally Posted by usv001 View Post
Like I said in my previous post, the codedFixedValue does not show any errors when I run Paraview but it shows 400000 for the patch instead of 200000.
Quick answer: Given how you coded it, the value is only updated in the first time step of the solver or at least when you run decomposePar.
__________________
wyldckat is offline   Reply With Quote

Old   April 16, 2016, 08:53
Default
  #39
Senior Member
 
Join Date: Sep 2015
Location: Singapore
Posts: 102
Rep Power: 10
usv001 is on a distinguished road
Hi Bruno,

Thank you very much for replying me. Really appreciate you taking your time to help others.

I used decomposePar and then reconstructPar to see if the changes take effect but there seems to be no change at all. The #code section is still being ignored.
usv001 is offline   Reply With Quote

Old   April 16, 2016, 16:27
Default
  #40
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi usv001,

Something very strange is going on here... at least in my machine. I would have to rebuild OpenFOAM 2.1.1 from source code to fix the problem on my side and I don't feel like it right now.

There are two things I need to you test/check:
  1. Run the tutorial case "incompressible/simpleFoam/pipeCyclic". To run it:
    Code:
    ./Allrun
    Then inspect the contents of the file "log.simpleFoam". I ask this because this tutorial should work as intended.
  2. The code you're using has a flaw... this:
    Code:
    operator == (200000);
    should be at least like this:
    Code:
    operator==(200000);
Because I suspect that the boundary condition isn't even being built in your case, because you should see a pretty glaring error message when trying to use decomposePar.


In addition to this, which Linux Distribution and version are you using?

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Domain Imbalance HMR CFX 5 October 10, 2016 05:57
Can anyone give me some hint on how to make traction free boundary condition? poplar OpenFOAM 3 January 14, 2015 02:37
Boundary Conditions Thomas P. Abraham Main CFD Forum 20 July 7, 2013 05:05
Setting outlet Pressure boundary condition using CAFFA code Mukund Pondkule Main CFD Forum 0 March 16, 2011 03:23
How to set boundary condition in Fluent for the fo Peiyong FLUENT 1 November 10, 2006 11:44


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