CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (https://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   How to use setField to create sphere (https://www.cfd-online.com/Forums/openfoam-pre-processing/62049-how-use-setfield-create-sphere.html)

ngj July 25, 2008 09:38

Hi For that purpose I recom
 
Hi

For that purpose I recommend that you look into funkySetField. At the present it is not ready for the 1.5 version, thus you need to apply it in 1.4.1.

If you by a cylinder mean a circle in 2D, then you could turn off gravity and let viscosity do the job.

Best regards,

Niels

nammari July 25, 2008 14:12

Hi Thanks for the reply. If I
 
Hi
Thanks for the reply. If I don't want to use 1.4.1, I just installed 1.5 and just got it working http://www.cfd-online.com/OpenFOAM_D...part/happy.gif

Instead of going back is it possible to read the location of a cell at position ( x,y,z )and "update" the value of gamma from 0 to 1. I found after reading around in the discussion "mesh.findCell(x,y,z)" that would give me the ID of the cell, how do I use that cell location update its value.( I guess I can do write some primitive code that makes a cylinder of fluid).
Best regard and have a good weekend
D

ngj July 25, 2008 15:03

Hi D Well, then you would p
 
Hi D

Well, then you would probably be able to do something like this:

gamma[mesh.findCell(x,y,z)] = 1;

assumed that (x,y,z) is with in the cylinder.

But say that the cylinder is placed along the z-axis, then wouldn't something like this do the trick!?!

scalar xC(0.0), yC(0.0); // Center values of for the cross section.

forAll(gamma,gI)
{
if (sqr(mesh.C()[gI].component(0) - xC) + sqr(mesh.C()[gI].component(1) - yC) <= sqr(radius))
{
gamma[gI] = 1;
}
}

Simply put this before the time loop and initialize gamma to zero in /0/gamma. This is primitive but it would work and basicly do the same as funkySetField.

/ Niels

nammari July 28, 2008 03:19

Thanks very much Niels..hope y
 
Thanks very much Niels..hope you had a good week
That works wonderfully !

chiven September 10, 2009 22:01

Hi, dear Nammari, how about your progress on making a cylinder fluid? I am interested in this point. Thanks in advance.

best regards,
Chiven

nammari March 10, 2011 13:45

It has been ages
 
Chiven,
It worked well and I have managed to change it to make the problem a little more intresting, now I am trying to create "empty" tanks using snappyhexmesh, but not succsesful at all

D

agr April 13, 2011 09:54

Quote:

Originally Posted by gschaider (Post 207530)
Hi!

The most recent version of funkySetFields can be downloaded via the subversion command in the Downloads section of
http://openfoamwiki.net/index.php/Co...funkySetFields

Bernhard

Thanks, Bernard, for the nice and promising utility.

Dear Bernard and All,

I downloaded the swak4Foam package, tried to follow your instructions - additionally installed flex. Seems it was built without errors.

But I still cannot get - should one use funkySetFields instead of setFields or after?

I just placed your demo funkySetFields Dictionary in my case/system directory and run the funkySetFields utility. It returned me the error:
FOAM FATAL ERROR:
funkySetFields: time/latestTime option is required
What does that mean?

Thanks in advance for your advice,
Regards,
Gallyam

gwierink April 14, 2011 03:41

Hi Gallyam,

Quote:

I just placed your demo funkySetFields Dictionary in my case/system directory and run the funkySetFields utility. It returned me the error:
FOAM FATAL ERROR:
funkySetFields: time/latestTime option is required
What does that mean?
This means that funkySetFields wants to know where to write the new fields, i.e. in which time directory. If you just want to plug it into your 0 directory, use
Code:

funkySetFields -time 0
Quote:

But I still cannot get - should one use funkySetFields instead of setFields or after?
Depends on what you want to do. If you just need funkySetFields to set a field according to an algorithm, e.g. as fuction of some coordinate, then funkySetFields is enough.

agr April 14, 2011 05:04

Hello, Gijsbert!

Thanks a lot for your reply!

Now it works.

Regards,
Gallyam

JulytoNovember October 29, 2011 16:42

I want to create a sphere using funkysetfields, but I'm not having any success. Could anyone show me the proper code to accomplish my goal?

gschaider October 29, 2011 18:47

Quote:

Originally Posted by JulytoNovember (Post 329998)
I want to create a sphere using funkysetfields, but I'm not having any success. Could anyone show me the proper code to accomplish my goal?

funkySetFields -create -field test -time 0 -expression "mag(pos()-vector(1,0,0))<2 ? 1 : 0"

.... for instance

JulytoNovember November 1, 2011 18:35

Thank you for your help, sorry it took so long for me to respond. Could you better help me understand the vector component of that expression? I'm not certain what purpose the vector(1,0,0) serves.

gschaider November 2, 2011 12:26

Quote:

Originally Posted by JulytoNovember (Post 330368)
Thank you for your help, sorry it took so long for me to respond. Could you better help me understand the vector component of that expression? I'm not certain what purpose the vector(1,0,0) serves.

The purpose is to show how to do it in a general way (with a center of the sphere that is not the origin of the coordinate system). WHERE the center is in this concrete example is left as an exercise to the reader.

duongquaphim November 3, 2011 08:11

Hi Sebastian,

You can do that easily with setFields like

18 defaultFieldValues
19 (
20 volScalarFieldValue alpha1 0
21 );
22
23 regions
24 (
25 sphereToCell
26 {
27 centre (0.05 0.1 0.5);
28 radius 0.01;
29 fieldValues
30 (
31 volScalarFieldValue alpha1 1
32 );
33 }
34 );

cheers,

Duong

sinohe February 17, 2012 07:49

rising bubble
 
Hi Jaswi and Sebastian, i followed your posts about using funkysetfield for rising bubble case, may i ask for Jaswi code?
i want to simulate rising bubble and investigate terminal velocity like u (Sebastain). i am confuse with using setfield too.

thanks in advance

shchao February 20, 2012 03:39

Quote:

Originally Posted by jaswi (Post 207527)
Hi Sebastian

As far as I understand you are using interFoam and you want to initialize the gamma field with a spherical bubble.

If that is the case then funkySetFields is the best choice as it allows you to do that in a very simple way.

Let me know if you still trying to do that as I can send you the code (courtesy Bernhard) which compiles with the 1.4.1 version.

http://www.cfd-online.com/OpenFOAM_D...ges/1/7511.jpg

With Regards
Jaswinder

Can you send me the input files and the grid files shown in that picture? My email address:shenchao.sx@gmail.com
Thank you!

liguifan February 9, 2013 12:19

Quote:

Originally Posted by shchao (Post 345260)
Can you send me the input files and the grid files shown in that picture? My email address:shenchao.sx@gmail.com
Thank you!

Dear shchao,

How is going with your bubble rising from the water. I am currently working on the same thing, however, I am not able to figure out how to design a 3D bubble from the above picture given. Just wondering does someone has sent you the code for that? I have figured out the 2D model but not the 3D one.

If you have the code, do you think you can send me a copy for that? my email address is liguifan@gmail.com
Appreciated!

xoitx March 11, 2016 11:16

Quote:

Originally Posted by mkraposhin (Post 207525)
Hi, Sebastian,

you can do that with such steps:

1) Create spherical surface (for example, with Netgen)
2) Export this surface to stl-formal
3) use option surface surfaceToCell (like in cellSetDict)
4) run foamToVTK . . -cellSet <your_cell_set_name>
5) preview <your_cell_set_name> in paraview
6) Enjoy!

Any tutorial on this?
This is too crude .. just started openFoam 3 days ago
what to after a cad model shape and how does it get its reference point...
Thanks

ht2017 January 13, 2022 00:39

could you send me the code to create a sphere by funkysetfiled?

my email: hoaithanhbk281113@gmail.com

Thank you so much!


All times are GMT -4. The time now is 00:40.