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

funkySetFields and funkySetBoundaryFields

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

Reply
 
LinkBack Thread Tools Display Modes
Old   February 24, 2012, 12:08
Default funkySetFields and funkySetBoundaryFields
  #1
Senior Member
 
Jian Zhong
Join Date: Feb 2012
Location: Birmingham
Posts: 108
Rep Power: 5
zxj160 is on a distinguished road
Hello everyone,

I am a beginning user of funkySetFields utility. I want to set the cyclic velocity BC from the inlet to outlet with pressure gradient. I have questions:

1. Can I define the patch type as cyclic or the general patch in the blockMeshDict?

2. If I want to set the U and P field using the funkySetFields utility, is it necessary to set these first in '0' directory. Then using funkySetFields.

3. What about funkySetBoundayFields?
http://openfoamwiki.net/index.php/Co...funkySetFields

4. Is there any tutorials about the funkySetFields or sample cases of it?
zxj160 is offline   Reply With Quote

Old   February 24, 2012, 17:11
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by zxj160 View Post
Hello everyone,

I am a beginning user of funkySetFields utility. I want to set the cyclic velocity BC from the inlet to outlet with pressure gradient. I have questions:

1. Can I define the patch type as cyclic or the general patch in the blockMeshDict?

2. If I want to set the U and P field using the funkySetFields utility, is it necessary to set these first in '0' directory. Then using funkySetFields.

3. What about funkySetBoundayFields?
http://openfoamwiki.net/index.php/Co...funkySetFields

4. Is there any tutorials about the funkySetFields or sample cases of it?
@1: Yes. cyclic is specified in the blockMeshDict. See the UserGuide

@2: Your question is "Do I have to create an U-file before setting the initial condition with FSF?", right? Answer: You don't have to (use the -create-option), but then you'll probably have to edit the resulting file to get decent boundary conditions

@3: that can be used to set arbitrary static boundary conditions (if you don't want to use groovyBC). There is an example file in the swak-Distro. Also see @4

@4: The only thing that resembles a tutorial is the presentation found at http://openfoamwiki.net/index.php/Co...er_information (also with a usage example of funkySetBoundaryFields if I remember it correctly)

Concerning your "cyclic U and jump in p": there is a boundary condition "fan" in OF that can be used for that, I think. Never had to use it yet, so you'll have to see yourself. There is also a similar BC called groovyBCJump in swak4Foam
gschaider is offline   Reply With Quote

Old   February 27, 2012, 16:18
Default
  #3
Senior Member
 
Jian Zhong
Join Date: Feb 2012
Location: Birmingham
Posts: 108
Rep Power: 5
zxj160 is on a distinguished road
Many thanks for your reply.

I have tried FSF to set the initial field. But I met a problem:

funkySetFields -create -field U -expression "vector(log((pos().y-10+0.0003)/0.0003),0,0)" -time 0 -condition "pos().x>0 && pos().x<30 && pos().y>10 && pos().y<20" -dimension "[0 1 -1 0 0 0 0]"

/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.1.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : 2.1.0-0bc225064152
Exec : funkySetFields -create -field U -expression vector((0.02/0.0003)*log((pos().y-10+0.0003)/0.0003),0,0) -time 0 -condition pos().x>0 && pos().x<30 && pos().y>10 && pos().y<20 -dimension [0 1 -1 0 0 0 0]
Date : Feb 27 2012
Time : 20:02:08
Host : "zxj160-laptop"
PID : 1818
Case : /home/zxj160/pisolestest
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Disallowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Time = 0
Using command-line options

Creating field U

Putting "vector((0.02/0.0003)*log((pos().y-10+0.0003)/0.0003),0,0)" into field U at t = "0" if condition "pos().x>0 && pos().x<30 && pos().y>10 && pos().y<20" is true

#0 Foam::error:rintStack(Foam::Ostream&) in "/opt/openfoam210/platforms/linuxGccDPOpt/lib/libOpenFOAM.so"
#1 Foam::sigFpe::sigHandler(int) in "/opt/openfoam210/platforms/linuxGccDPOpt/lib/libOpenFOAM.so"
#2 Uninterpreted:
#3 log in "/lib/tls/i686/cmov/libm.so.6"
#4 Foam::log(Foam::Field<double>&, Foam::UList<double> const&) in "/opt/openfoam210/platforms/linuxGccDPOpt/lib/libOpenFOAM.so"
#5 Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::log<Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) in "/home/zxj160/OpenFOAM/zxj160-2.1.0/platforms/linuxGccDPOpt/lib/libswak4FoamParsers.so"
#6 parserField::FieldValueExpressionParser:arse() at FieldValueExpressionParser.C:0
#7 Foam::FieldValueExpressionDriver:arse(std::strin g const&) in "/home/zxj160/OpenFOAM/zxj160-2.1.0/platforms/linuxGccDPOpt/lib/libswak4FoamParsers.so"
#8
in "/home/zxj160/OpenFOAM/zxj160-2.1.0/platforms/linuxGccDPOpt/bin/funkySetFields"
#9
in "/home/zxj160/OpenFOAM/zxj160-2.1.0/platforms/linuxGccDPOpt/bin/funkySetFields"
#10 __libc_start_main in "/lib/tls/i686/cmov/libc.so.6"
#11
in "/home/zxj160/OpenFOAM/zxj160-2.1.0/platforms/linuxGccDPOpt/bin/funkySetFields"
Floating point exception
zxj160@zxj160-laptop:~/pisolestest$ funkySetFields -create -field U -expression "vector(log((pos().y-10+0.0003)/0.0003),0,0)" -time 0 -condition "pos().x>0 && pos().x<30 && pos().y>10 && pos().y<20" -dimension "[0 1 -1 0 0 0 0]"

Create time

Create mesh for time = 0

Time = 0
Using command-line options

Creating field U

Putting "vector(log((pos().y-10+0.0003)/0.0003),0,0)" into field U at t = "0" if condition "pos().x>0 && pos().x<30 && pos().y>10 && pos().y<20" is true

#0 Foam::error:rintStack(Foam::Ostream&) in "/opt/openfoam210/platforms/linuxGccDPOpt/lib/libOpenFOAM.so"
#1 Foam::sigFpe::sigHandler(int) in "/opt/openfoam210/platforms/linuxGccDPOpt/lib/libOpenFOAM.so"
#2 Uninterpreted:
#3 log in "/lib/tls/i686/cmov/libm.so.6"
#4 Foam::log(Foam::Field<double>&, Foam::UList<double> const&) in "/opt/openfoam210/platforms/linuxGccDPOpt/lib/libOpenFOAM.so"
#5 Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::log<Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) in "/home/zxj160/OpenFOAM/zxj160-2.1.0/platforms/linuxGccDPOpt/lib/libswak4FoamParsers.so"
#6 parserField::FieldValueExpressionParser:arse() at FieldValueExpressionParser.C:0
#7 Foam::FieldValueExpressionDriver:arse(std::strin g const&) in "/home/zxj160/OpenFOAM/zxj160-2.1.0/platforms/linuxGccDPOpt/lib/libswak4FoamParsers.so"
#8
in "/home/zxj160/OpenFOAM/zxj160-2.1.0/platforms/linuxGccDPOpt/bin/funkySetFields"
#9
in "/home/zxj160/OpenFOAM/zxj160-2.1.0/platforms/linuxGccDPOpt/bin/funkySetFields"
#10 __libc_start_main in "/lib/tls/i686/cmov/libc.so.6"
#11
in "/home/zxj160/OpenFOAM/zxj160-2.1.0/platforms/linuxGccDPOpt/bin/funkySetFields"
Floating point exception


But when I run: funkySetFields -create -field U -expression "vector((pos().y-10+0.0003)/0.0003,0,0)" -time 0 -condition "pos().x>0 && pos().x<30 && pos().y>10 && pos().y<20" -dimension "[0 1 -1 0 0 0 0]" , it is OK.

I want to know the error of my previous expression: vector(log((pos().y-10+0.0003)/0.0003),0,0).
zxj160 is offline   Reply With Quote

Old   February 27, 2012, 17:41
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by zxj160 View Post
But when I run: funkySetFields -create -field U -expression "vector((pos().y-10+0.0003)/0.0003,0,0)" -time 0 -condition "pos().x>0 && pos().x<30 && pos().y>10 && pos().y<20" -dimension "[0 1 -1 0 0 0 0]" , it is OK.

I want to know the error of my previous expression: vector(log((pos().y-10+0.0003)/0.0003),0,0).
Have a look at the stack-traces: the problem occurs when evaluating the logarithm. The logarithm for a negative number is undefined. If you have in your mesh cells with y<(10-0.0003) then this is the case
gschaider is offline   Reply With Quote

Old   February 28, 2012, 07:10
Default
  #5
Senior Member
 
Jian Zhong
Join Date: Feb 2012
Location: Birmingham
Posts: 108
Rep Power: 5
zxj160 is on a distinguished road
Quote:
Originally Posted by gschaider View Post
Have a look at the stack-traces: the problem occurs when evaluating the logarithm. The logarithm for a negative number is undefined. If you have in your mesh cells with y<(10-0.0003) then this is the case

Yes, that may be the problem, but I has defined the conditions? How can I do achieve that log expression?

I also want to set : funkySetFields -field U -expression "(0,0,0)" -time 0 -keepPatches -condition "pos().x>0 && pos().x<30 && pos().y>10 && pos().y<20".
zxj160 is offline   Reply With Quote

Old   February 28, 2012, 09:12
Default
  #6
Senior Member
 
Jian Zhong
Join Date: Feb 2012
Location: Birmingham
Posts: 108
Rep Power: 5
zxj160 is on a distinguished road
Another question is that "can funkySetFields be used to create a uniform field". I want to keep the velocity in the some parts of the domain uniforma.
zxj160 is offline   Reply With Quote

Old   February 28, 2012, 10:11
Default
  #7
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by zxj160 View Post
Yes, that may be the problem, but I has defined the conditions? How can I do achieve that log expression?

I also want to set : funkySetFields -field U -expression "(0,0,0)" -time 0 -keepPatches -condition "pos().x>0 && pos().x<30 && pos().y>10 && pos().y<20".
Ah. Sorry. Just seen that. OK. In theory you guarded against that. The problem is that the expression is evaluated for the whole domain (that's where the problem occurs) and then values are picked according to the condition (so it comes to late). So you'll have to modify the log calculation to something like

log(max((pos().y-10+0.0003)/0.0003),1),0,0)
gschaider is offline   Reply With Quote

Old   February 28, 2012, 10:14
Default
  #8
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by zxj160 View Post
Another question is that "can funkySetFields be used to create a uniform field". I want to keep the velocity in the some parts of the domain uniforma.
Of course. If the expression yields a uniform field ... "vector(max(pos().y),0,0)" for instance (not that it makes much sense)

Of what do you mean with "keep uniform"?
gschaider is offline   Reply With Quote

Old   February 28, 2012, 13:34
Default
  #9
Senior Member
 
Jian Zhong
Join Date: Feb 2012
Location: Birmingham
Posts: 108
Rep Power: 5
zxj160 is on a distinguished road
Quote:
Originally Posted by gschaider View Post
So you'll have to modify the log calculation to something like

log(max((pos().y-10+0.0003)/0.0003),1),0,0)

Fantastic. This can solve the problem. Many thanks.
zxj160 is offline   Reply With Quote

Old   February 28, 2012, 13:39
Default
  #10
Senior Member
 
Jian Zhong
Join Date: Feb 2012
Location: Birmingham
Posts: 108
Rep Power: 5
zxj160 is on a distinguished road
Quote:
Originally Posted by gschaider View Post
Of course. If the expression yields a uniform field ... "vector(max(pos().y),0,0)" for instance (not that it makes much sense)

Of what do you mean with "keep uniform"?

Yes, I want to keep the some field uniform when running the code. I use the LES model.
zxj160 is offline   Reply With Quote

Old   February 28, 2012, 14:41
Default
  #11
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by zxj160 View Post
Yes, I want to keep the some field uniform when running the code. I use the LES model.
So in a certain region you want to override the solution? I don't endorse this kind of thing (violation of all kinds of conservation), but support it via swak4Foam (I'm that kind of irresponsible person):

- the swakFunctionObjects-library has a functionObject manipulateField. Field is reset at the end of each time-step. This requires no modification of the solver. As you've mastered FSF you'll be comfortable with the expression/condition-semantics
- the forceEquation-class in the swakSourceFields allows fixing a field in certain regions. This requires modifications of the solver. See the example-solver interFoamWithFixed and discussions about expressionSource elsewhere here on the forum
gschaider is offline   Reply With Quote

Old   February 29, 2012, 11:01
Default
  #12
Senior Member
 
Jian Zhong
Join Date: Feb 2012
Location: Birmingham
Posts: 108
Rep Power: 5
zxj160 is on a distinguished road
Actually, I want to make the velocity outcome like the attached picture (from website). The upper region of the canyon is uniform. The inlet and outlet is cyclic. I do not know how to do that. Is it possible to calculate the different region with different turbulent model (laminar and LES)? Could you suggest me some ideas? Many thanks.
Attached Images
File Type: jpg canyon.jpg (54.7 KB, 52 views)
zxj160 is offline   Reply With Quote

Old   February 29, 2012, 19:20
Default
  #13
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by zxj160 View Post
Actually, I want to make the velocity outcome like the attached picture (from website). The upper region of the canyon is uniform. The inlet and outlet is cyclic. I do not know how to do that. Is it possible to calculate the different region with different turbulent model (laminar and LES)? Could you suggest me some ideas? Many thanks.
The picture doesn't make it clearer for me (for instance: which regions should be uniform ... etc)

I don't think that the laminar/LES-questions fits the topic of this thread
gschaider is offline   Reply With Quote

Old   October 3, 2013, 12:42
Default
  #14
New Member
 
sasan
Join Date: Sep 2013
Posts: 28
Rep Power: 3
Sasy is on a distinguished road
Hi all
I want simulate two phase flow and I have Non-uniform initial conditions,I know,should use funkySetFields for this, and I read http://openfoamwiki.net/index.php/Co...funkySetFields
but I have problem,I attach my equation (that show interface two phase)
any body know how Write this equation with funkySetFields.
Attached Images
File Type: jpg a.JPG (10.6 KB, 35 views)
Sasy is offline   Reply With Quote

Old   October 3, 2013, 12:52
Default
  #15
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Sasy View Post
Hi all
I want simulate two phase flow and I have Non-uniform initial conditions,I know,should use funkySetFields for this, and I read http://openfoamwiki.net/index.php/Co...funkySetFields
but I have problem,I attach my equation (that show interface two phase)
any body know how Write this equation with funkySetFields.
My problem is that I'd have to guess the meaning of the letters in your equation. And what exactly is your problem?
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Reply

Tags
funkysetfields

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
groovyBC and funkySetFields married and got a kid named swak4Foam gschaider OpenFOAM 164 January 13, 2015 03:52
funkySetFields and OF1.7.0 rcastilla OpenFOAM Running, Solving & CFD 5 November 6, 2012 04:33
funkySetFields and multiple sets and fields mturcios777 OpenFOAM Pre-Processing 1 January 7, 2012 18:51
numerical beach with funkySetFields?! maxonline OpenFOAM 6 June 17, 2011 04:59
swak4Foam - funkySetFields - not recognizing turbulent wall BC gonpe OpenFOAM Pre-Processing 2 January 10, 2011 11:30


All times are GMT -4. The time now is 15:35.