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] funkySetFields and funkySetBoundaryFields (https://www.cfd-online.com/Forums/openfoam-community-contributions/97772-funkysetfields-funkysetboundaryfields.html)

zxj160 February 24, 2012 11:08

funkySetFields and funkySetBoundaryFields
 
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?

gschaider February 24, 2012 16:11

Quote:

Originally Posted by zxj160 (Post 346158)
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

zxj160 February 27, 2012 15:18

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::printStack(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::parse() at FieldValueExpressionParser.C:0
#7 Foam::FieldValueExpressionDriver::parse(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::printStack(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::parse() at FieldValueExpressionParser.C:0
#7 Foam::FieldValueExpressionDriver::parse(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).

gschaider February 27, 2012 16:41

Quote:

Originally Posted by zxj160 (Post 346515)
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

zxj160 February 28, 2012 06:10

Quote:

Originally Posted by gschaider (Post 346525)
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 February 28, 2012 08:12

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.

gschaider February 28, 2012 09:11

Quote:

Originally Posted by zxj160 (Post 346624)
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 February 28, 2012 09:14

Quote:

Originally Posted by zxj160 (Post 346671)
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"?

zxj160 February 28, 2012 12:34

Quote:

Originally Posted by gschaider (Post 346679)
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 February 28, 2012 12:39

Quote:

Originally Posted by gschaider (Post 346680)
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.

gschaider February 28, 2012 13:41

Quote:

Originally Posted by zxj160 (Post 346724)
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

zxj160 February 29, 2012 10:01

1 Attachment(s)
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.

gschaider February 29, 2012 18:20

Quote:

Originally Posted by zxj160 (Post 346918)
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

Sasy October 3, 2013 12:42

1 Attachment(s)
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.

gschaider October 3, 2013 12:52

Quote:

Originally Posted by Sasy (Post 454912)
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?

alimea February 7, 2018 03:13

set a boundary condition with funky
 
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

gschaider February 7, 2018 19:32

Quote:

Originally Posted by alimea (Post 680717)
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

alimea February 9, 2018 12:00

Quote:

Originally Posted by gschaider (Post 680803)
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 February 12, 2018 07:58

Quote:

Originally Posted by gschaider (Post 680803)
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

gschaider February 14, 2018 19:07

Quote:

Originally Posted by alimea (Post 681231)
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)


All times are GMT -4. The time now is 05:52.