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 - how to set two "zones"? (https://www.cfd-online.com/Forums/openfoam-community-contributions/74815-funkysetfields-how-set-two-zones.html)

gwierink April 9, 2010 03:30

funkySetFields - how to set two "zones"?
 
Dear all,

I use funkySetFields to create a spherical zone (a drop or a bubble) and that works great. Now, does anyone have any idea how to set the field to two bubbles or e.g. two water blobs in the damBreak case? Can I for example just plug two expressions in funkySetFields (one for each bubble/drop)? Many thanks in advance!

sega April 9, 2010 06:37

Quote:

Originally Posted by gwierink (Post 253890)
Dear all,

I use funkySetFields to create a spherical zone (a drop or a bubble) and that works great. Now, does anyone have any idea how to set the field to two bubbles or e.g. two water blobs in the damBreak case? Can I for example just plug two expressions in funkySetFields (one for each bubble/drop)? Many thanks in advance!

I think you can't use two expression in funkySetFields.
But you can run it twice with the appropriate expression.
funkySetFields will not overwrite your previously set fields.

gwierink April 9, 2010 06:42

Quote:

But you can run it twice
Hmm, that's an interesting idea I haven't thought of yet. Thank you, I will go and try it.

gschaider April 9, 2010 07:20

Quote:

Originally Posted by gwierink (Post 253917)
Hmm, that's an interesting idea I haven't thought of yet. Thank you, I will go and try it.

It works together with the -condition-flag (see section 3.1 on the Wiki page for an example)

gwierink April 9, 2010 08:13

@Sebastian:
Thank you, it works! Behold, two bubbles rising and colliding :D.

http://users.tkk.fi/%7Egwierink/of-s...bles-small.png


@Bernhard:
Hi Bernhard,
Quote:

It works together with the -condition-flag
I used the following expression (for two different positions for two different bubbles of course :)):
Code:

funkySetFields -field alpha1 -expression 1 -time 0 -keepPatches -condition "pow(pos().x,2) + pow(pos().y+0.1,2) < pow(0.02,2)"
Do you mean you can set a condition to make two spheres? If so, what would be the syntax for that? Thanks in advance!

Have a good weekend!

gschaider April 12, 2010 04:44

Quote:

Originally Posted by gwierink (Post 253937)
Do you mean you can set a condition to make two spheres? If so, what would be the syntax for that? Thanks in advance!

I quote from http://openfoamwiki.net/index.php/Co...nd_line_usage:
Code:

An optional option is -condition: only cells for which this expression evaluates to true are overwritten with the expression. For all other cells the old value is kept.
Sometimes I wonder why I bother to write ANY documentation (not that I write too much)

gwierink April 13, 2010 15:08

Hi Bernhard,

Quote:

I quote from http://openfoamwiki.net/index.php/Co...nd_line_usage:
Code:
An optional option is -condition: only cells for which this expression evaluates to true are overwritten with the expression. For all other cells the old value is kept.
Yes, I have seen that. I understand, as it says in the Wiki, that cells for which the expression is true are overwritten. This is what I used to generate the image above. My question was/is whether it is possible to use several expressions in the -condition flag, in my case to generate two spheres.

Quote:

Sometimes I wonder why I bother to write ANY documentation (not that I write too much)
Well, I am sorry if my question is frustrating, I appreciate your contributions and documentation very much. :)

gschaider April 14, 2010 12:14

Quote:

Originally Posted by gwierink (Post 254469)
Hi Bernhard,

Yes, I have seen that. I understand, as it says in the Wiki, that cells for which the expression is true are overwritten. This is what I used to generate the image above. My question was/is whether it is possible to use several expressions in the -condition flag, in my case to generate two spheres.

Well, I am sorry if my question is frustrating, I appreciate your contributions and documentation very much. :)

Sorry for being rude. I was in a hurry and misread your expression. Didn't see that you already were using a condition

OK. You're halfway there. For more than one sphere just use the operator for a "logical or" || to connect your conditions (basically "(sphere1cond) || (sphere2cond)" put brackets around the expressions to avoid problems)

Bernhard

gwierink April 14, 2010 14:36

Hi Bernhard,

No worries, we're all in a hurry sometimes :).
Thank you for the tip, that was exactly what I was looking for!

Thanks again and take care :)

johnchang June 4, 2010 02:24

Hi Gijsbert,

I am a beginner in the OF. I have a geometry exported from the STL file which needs to be divided into 2 zones. So my question is can I do that through funkySetFields or have to go through the normal process like creating cellSet, faceSet, and setsToZones??

And how can I do that?because I am confused what numbers to put into the topoSetSources......

Your advice would be highly appreciated.

Cheers.

gwierink June 4, 2010 02:39

Hi John,

Do you mean you want to create two zones as in two separate e.g. fluid zones? I think you have to do that with a mesh generator. In my understanding funkySetFields sets a field to a certain value, e.g. a sphere filled with air. But perhaps Bernhard knows a trick?

johnchang June 4, 2010 02:51

Thank you for the prompt reply Gijsbert. 2 separate zones as in 2 layers of which the heat transfer mode is different for each. The logic goes like this, if you are in zone A use this equation if else use this. But zone B values are highly dependent on zone A value.

I'm leaning more towards the cellSet and faceSet methods, but have no idea how to divide the geometry into 2 respective zones.

Thank you for you time.

gwierink June 4, 2010 03:10

I think you should define two separate zones on your mesh generator for that. You need to split a volume (so that they're still connected) and give them different names, like e.g. fluidZone1 and fluidZone2. Then, you can define different rules for each zone.

johnchang June 4, 2010 03:37

Thanks again for the reply. Yes, what you said is exactly what I want to do. However, I can't seem to define two separate zones in one geometry using my mesh generator. I thought I can do this from setting up the cellSet and faceSet but again I don't quite know how to use them.

If you don't mind giving me your email address, I will forward you to my case.

Cheers

gwierink June 4, 2010 03:51

Hi John,

Well, I must confess I never used cellSet, I always define the zones in Gambit and then convert the mesh with the -writeZones flag. But I suppose you could use cellSet for that purpose as well. Check out this thread for some details. From what I gather from that thread you need to define a cellSetDict in the system directory, in which you define a name, an action, and a method to select cells ("topoSetSources"). So, it would look something like this:


Quote:

Code:

name rotor;
 
// One of clear/new/invert/add/delete|subset/list
action new;
 
// Actions to apply to cellSet. These are all the topoSetSource's ending
// in ..ToCell (see the meshTools library).
 
topoSetSources
(
    // Cells in cell zone
    boxToCell
    {
        box  (-1.2 -0.6 -1.2) (1.2 2.3 1.2);      // name of cellZone
    }
 
);


The code above is just pasted from the thread I included above and it seems there are still some things wrong with it, so please read through the thread carefully.

Quote:

If you don't mind giving me your email address, I will forward you to my case.
Sure, no problem. :) I will send you a PM with my e-mail address.

Disco_Caine July 5, 2010 05:27

Well, i hate to post the same thing twice (because of the clutter and such). But i really need some help with funkysetfields. I have a very simple mesh:

(0 0 0) //0
(1.05 -0.045844 0) //1
(1.25 -0.054576 0) //2
(12 -0.523931 0) //3
(12 0.523931 0) //4
(1.25 0.054576 0) //5
(1.05 0.045844 0) //6
(0 0 0) //7

It's a wedge of height 8.23 cm. So anyways, i want to set a field for the cells with cellcentre <= 0.0105 (yeah, i have it in meters). So i have this for FST:

expressions
(
temperature1
{
field T;
expression "52.96281*(pow(pos().z,0.262054))+273";
conditions "pos().x <= 0.0105";
keepPatches 1;
}

The thing is, that it is setting the field for the whole wedge, as if my condition wasnt there. Perhaps im using the condition wrong, or theres another way to write it. Any help would be much appreciated.

I have tried putting it in cm, putting a another expression temperature2 for the rest of the mesh (it just uses this for the whole mesh). Ive tried limiting the position in the y and z axis. Anyways, im having a problem using the condition.

Anyones help is welcome, thanks in advance!
GB

gwierink July 5, 2010 07:12

Hi GB,

Quote:

(0 0 0) //0
(1.05 -0.045844 0) //1
(1.25 -0.054576 0) //2
(12 -0.523931 0) //3
(12 0.523931 0) //4
(1.25 0.054576 0) //5
(1.05 0.045844 0) //6
(0 0 0) //7
I don't think you need to declare the origin (points 0 and 7) twice, i.e. delete point 7.


Quote:

expression "52.96281*(pow(pos().z,0.262054))+273";
conditions "pos().x <= 0.0105";
Should the expression maybe be something like (or change the condition, in any case, that there is either z in both or x in both ...)
Code:

expression "52.96281*(pow(pos().x,0.262054))+273";
        conditions "pos().x <= 0.0105";

Since all your points are at z=0, they're all below 0.0105, so everything will be set to 1.

Hope this helps :)

Disco_Caine July 5, 2010 08:31

Hi Gijs, thanks for your reply. However, my mesh does have height (i just didnt put the other vertex). The thing is that the profile should change with height, and only for those x values. If you want, i can post the full blockmesh.

Thank you1

gwierink July 5, 2010 08:36

Hi GB,

Quote:

However, my mesh does have height
That's exactly the point. Your expression contains z, while your condition defines x. But if your case does not have height (which I see from the vertices) why use an expression in z? Shouldn't the expression also be in x?

Disco_Caine July 5, 2010 08:39

Ah well, its because im trying to put a temperature profile that varies with height (which is represented by the z coordinate in my mesh). So i want the field for the whole height, but not for the whole mesh. I want one part of the mesh (limited by x < 0.0105) to have the profile, and for the other i would like, in worse case, a fixed temperature (not the same profile).


All times are GMT -4. The time now is 16:01.