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

How to use setField to create sphere

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 25, 2008, 10:38
Default Hi For that purpose I recom
  #21
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
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
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   July 25, 2008, 15:12
Default Hi Thanks for the reply. If I
  #22
New Member
 
Diauddin Nammari
Join Date: Mar 2009
Posts: 8
Rep Power: 17
nammari is on a distinguished road
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

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
nammari is offline   Reply With Quote

Old   July 25, 2008, 16:03
Default Hi D Well, then you would p
  #23
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
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
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   July 28, 2008, 04:19
Default Thanks very much Niels..hope y
  #24
New Member
 
Diauddin Nammari
Join Date: Mar 2009
Posts: 8
Rep Power: 17
nammari is on a distinguished road
Thanks very much Niels..hope you had a good week
That works wonderfully !
nammari is offline   Reply With Quote

Old   September 10, 2009, 23:01
Default
  #25
Senior Member
 
J. Cai
Join Date: Apr 2009
Posts: 180
Rep Power: 17
chiven is on a distinguished road
Hi, dear Nammari, how about your progress on making a cylinder fluid? I am interested in this point. Thanks in advance.

best regards,
Chiven
chiven is offline   Reply With Quote

Old   March 10, 2011, 14:45
Default It has been ages
  #26
New Member
 
Diauddin Nammari
Join Date: Mar 2009
Posts: 8
Rep Power: 17
nammari is on a distinguished road
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
nammari is offline   Reply With Quote

Old   April 13, 2011, 10:54
Default
  #27
agr
New Member
 
agr
Join Date: Apr 2011
Posts: 2
Rep Power: 0
agr is on a distinguished road
Quote:
Originally Posted by gschaider View Post
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
agr is offline   Reply With Quote

Old   April 14, 2011, 04:41
Default
  #28
Senior Member
 
Gijsbert Wierink
Join Date: Mar 2009
Posts: 383
Rep Power: 18
gwierink is on a distinguished road
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.
__________________
Regards, Gijs
gwierink is offline   Reply With Quote

Old   April 14, 2011, 06:04
Default
  #29
agr
New Member
 
agr
Join Date: Apr 2011
Posts: 2
Rep Power: 0
agr is on a distinguished road
Hello, Gijsbert!

Thanks a lot for your reply!

Now it works.

Regards,
Gallyam
agr is offline   Reply With Quote

Old   October 29, 2011, 17:42
Default
  #30
Member
 
Jason Eason
Join Date: Jan 2010
Location: Portage, Michigan
Posts: 45
Rep Power: 16
JulytoNovember is on a distinguished road
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?
__________________
Debian Squeeze - OpenFOAM-2.1.x, Paraview-3.12.0
JulytoNovember is offline   Reply With Quote

Old   October 29, 2011, 19:47
Default
  #31
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 JulytoNovember View Post
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
gschaider is offline   Reply With Quote

Old   November 1, 2011, 19:35
Default
  #32
Member
 
Jason Eason
Join Date: Jan 2010
Location: Portage, Michigan
Posts: 45
Rep Power: 16
JulytoNovember is on a distinguished road
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.
__________________
Debian Squeeze - OpenFOAM-2.1.x, Paraview-3.12.0
JulytoNovember is offline   Reply With Quote

Old   November 2, 2011, 13:26
Default
  #33
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 JulytoNovember View Post
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.
gschaider is offline   Reply With Quote

Old   November 3, 2011, 09:11
Default
  #34
Member
 
Duong A. Hoang
Join Date: Apr 2009
Location: Delft, Netherlands
Posts: 93
Rep Power: 17
duongquaphim is on a distinguished road
Send a message via Yahoo to duongquaphim
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
krishtej23 likes this.
duongquaphim is offline   Reply With Quote

Old   February 17, 2012, 08:49
Lightbulb rising bubble
  #35
New Member
 
navid
Join Date: Feb 2012
Posts: 3
Rep Power: 14
sinohe is on a distinguished road
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
sinohe is offline   Reply With Quote

Old   February 20, 2012, 04:39
Default
  #36
New Member
 
anonymous
Join Date: Apr 2010
Posts: 14
Rep Power: 16
shchao is on a distinguished road
Quote:
Originally Posted by jaswi View Post
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.



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!
shchao is offline   Reply With Quote

Old   February 9, 2013, 13:19
Default
  #37
Member
 
Guifan Li
Join Date: Apr 2011
Location: New York City, U.S.
Posts: 96
Rep Power: 15
liguifan is on a distinguished road
Quote:
Originally Posted by shchao View Post
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!
liguifan is offline   Reply With Quote

Old   March 11, 2016, 12:16
Default
  #38
New Member
 
Alpha Beta
Join Date: Mar 2016
Posts: 28
Rep Power: 10
xoitx is on a distinguished road
Quote:
Originally Posted by mkraposhin View Post
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
xoitx is offline   Reply With Quote

Old   January 13, 2022, 01:39
Default
  #39
Member
 
ESI
Join Date: Sep 2017
Posts: 49
Rep Power: 9
ht2017 is on a distinguished road
could you send me the code to create a sphere by funkysetfiled?

my email: hoaithanhbk281113@gmail.com

Thank you so much!
ht2017 is offline   Reply With Quote

Reply


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
[blockMesh] Create a mesh for flow around a sphere harly OpenFOAM Meshing & Mesh Conversion 7 November 6, 2013 17:28
SetField problem in OpenFoam 14 joakim OpenFOAM Bugs 17 October 30, 2009 08:18
How to use SetField tian OpenFOAM Pre-Processing 2 May 18, 2009 05:06
cd of sphere senthil FLUENT 3 June 1, 2006 06:22
Sphere tie FLUENT 0 July 5, 2005 15:29


All times are GMT -4. The time now is 04:39.