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

[swak4Foam] funkySetFields and funkySetBoundaryFields

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By gschaider

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 24, 2012, 12:08
Default funkySetFields and funkySetBoundaryFields
  #1
Senior Member
 
Jian Zhong
Join Date: Feb 2012
Location: Birmingham
Posts: 109
Rep Power: 14
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: 4,225
Rep Power: 51
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: 109
Rep Power: 14
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: 4,225
Rep Power: 51
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: 109
Rep Power: 14
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: 109
Rep Power: 14
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: 4,225
Rep Power: 51
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: 4,225
Rep Power: 51
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: 109
Rep Power: 14
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: 109
Rep Power: 14
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: 4,225
Rep Power: 51
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: 109
Rep Power: 14
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, 186 views)
zxj160 is offline   Reply With Quote

Old   February 29, 2012, 19:20
Default
  #13
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
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, 13:42
Default
  #14
New Member
 
sasan
Join Date: Sep 2013
Posts: 28
Rep Power: 13
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, 136 views)
Sasy is offline   Reply With Quote

Old   October 3, 2013, 13:52
Default
  #15
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
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

Old   February 7, 2018, 04:13
Default set a boundary condition with funky
  #16
Senior Member
 
A. Min
Join Date: Mar 2015
Posts: 308
Rep Power: 12
alimea is on a distinguished road
Hi
consider a 3D box that I want to put a circular input on that with U=(0,5,0) boundary condition(on one of my walls that is rectangular)
If I want to use funkySetFields:

funkySetFields -case hotRoom -time 0 -field U -keepPatches -valuePatches "pipe" -condition "...." -expression 'vector(0,5,0)'

I put it just in time=0 ! however I want to use it as a boundary condition in my all timeSteps.

plz help me if you know what should I do.
Thank you
alimea is offline   Reply With Quote

Old   February 7, 2018, 20:32
Default
  #17
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by alimea View Post
Hi
consider a 3D box that I want to put a circular input on that with U=(0,5,0) boundary condition(on one of my walls that is rectangular)
If I want to use funkySetFields:

funkySetFields -case hotRoom -time 0 -field U -keepPatches -valuePatches "pipe" -condition "...." -expression 'vector(0,5,0)'

I put it just in time=0 ! however I want to use it as a boundary condition in my all timeSteps.

plz help me if you know what should I do.
Thank you
If the pipe-patch is of type fixedValue you sould be fine. Look at the 0/U-file after applying funkySetFields: it now has a "value nonuniform ...". This value will be read on startup and will not change during the simulation (thus the name "fixedValue") just like a "value uniform (0 5 0)" will not change during the simulation.

But if you want a real calculated boundary condition look at groovyBC
__________________
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

Old   February 9, 2018, 13:00
Default
  #18
Senior Member
 
A. Min
Join Date: Mar 2015
Posts: 308
Rep Power: 12
alimea is on a distinguished road
Quote:
Originally Posted by gschaider View Post
If the pipe-patch is of type fixedValue you sould be fine. Look at the 0/U-file after applying funkySetFields: it now has a "value nonuniform ...". This value will be read on startup and will not change during the simulation (thus the name "fixedValue") just like a "value uniform (0 5 0)" will not change during the simulation.

But if you want a real calculated boundary condition look at groovyBC
Dear Bernhard
Yes, that is fixedValue. In fact I want to have this boundary condition till end time of problem, like the other boundary conditions.
But I didn't get what you said. I put fixedValue front of internalField in 0/U and made it like boundary conditions.
But it gave me an error!
could you plz explain more?
Thanks
alimea is offline   Reply With Quote

Old   February 12, 2018, 08:58
Default
  #19
Senior Member
 
A. Min
Join Date: Mar 2015
Posts: 308
Rep Power: 12
alimea is on a distinguished road
Quote:
Originally Posted by gschaider View Post
If the pipe-patch is of type fixedValue you sould be fine. Look at the 0/U-file after applying funkySetFields: it now has a "value nonuniform ...". This value will be read on startup and will not change during the simulation (thus the name "fixedValue") just like a "value uniform (0 5 0)" will not change during the simulation.

But if you want a real calculated boundary condition look at groovyBC
I think you didn't see my last question, could you plz answer it?
My question was:

Dear Bernhard
Yes, that is fixedValue. In fact I want to have this boundary condition till end time of problem, like the other boundary conditions.
But I didn't get what you said. I put fixedValue front of internalField in 0/U and made it like boundary conditions.
But it gave me an error!
could you plz explain more?
Thanks
alimea is offline   Reply With Quote

Old   February 14, 2018, 20:07
Default
  #20
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by alimea View Post
I think you didn't see my last question, could you plz answer it?
My question was:

Dear Bernhard
Yes, that is fixedValue. In fact I want to have this boundary condition till end time of problem, like the other boundary conditions.
But I didn't get what you said. I put fixedValue front of internalField in 0/U and made it like boundary conditions.
But it gave me an error!
could you plz explain more?
Thanks
Don't hand-edit the file. -keepPatches/-valuePatches helb you with that. Just like https://openfoamwiki.net/index.php/C...t-Room_Example (section 3.2.1)
alimea likes this.
__________________
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


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
[swak4Foam] groovyBC and funkySetFields married and got a kid named swak4Foam gschaider OpenFOAM Community Contributions 169 August 10, 2023 10:01
[swak4Foam] how to use funkySetFields function in muliregion case bryant_k OpenFOAM Community Contributions 15 October 15, 2021 03:50
[swak4Foam] funkySetFields: problem with processor boundary nmikhailov OpenFOAM Community Contributions 4 May 26, 2015 10:48
[swak4Foam] Problem with funkySetFields: How to set field on patch? DanielPT OpenFOAM Community Contributions 4 May 6, 2011 10:45
[swak4Foam] funkySetFields Chrisi1984 OpenFOAM Community Contributions 10 June 17, 2010 04:26


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