CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)

Hi everybody,
any one know how can I define a convergent (center-oriented) gravity field in OF? I have a sphere that have a convergent gravity field.

Thank you

 nimasam July 28, 2012 05:54

what is "convergent gravity field"?

1 Attachment(s)
Quote:
 Originally Posted by nimasam (Post 374084) what is "convergent gravity field"?
Hi Nima,

Assume we want to solve convection heat transfer in a spherical body that it has a gravity field. for example the earth, the earth gravity vectors are perpendicular to the surface and they are intersecting each other at the center of sphere(earth- a center-oriented field).

Do you know how can I define such gravity field that varies with radius of sphere?

Thank you

 nimasam July 28, 2012 08:00

it is possible with some pieces of coding:
i have an idea, instead of using a dimensionVector "g" , define a VolVectorField "g"
then, using funkySetField or setField utility to define a non-uniform "g"

Quote:
 Originally Posted by nimasam (Post 374101) it is possible with some pieces of coding: i have an idea, instead of using a dimensionVector "g" , define a VolVectorField "g" then, using funkySetField or setField utility to define a non-uniform "g"
thank you, Nima

I will test it.

 niaz July 29, 2012 01:07

it seems that your field is constant over time.
the simplest way is to look how the points are written in constant/points. then write a code with a programming language to create a non uniform distribution.

Quote:
 Originally Posted by niaz (Post 374149) Dear adam it seems that your field is constant over time. the simplest way is to look how the points are written in constant/points. then write a code with a programming language to create a non uniform distribution.
hi Niaz,
just now I'm trying!!!!!!!!

thank you

Quote:
 Originally Posted by niaz (Post 374149) Dear adam it seems that your field is constant over time. the simplest way is to look how the points are written in constant/points. then write a code with a programming language to create a non uniform distribution.
hi,
I try but I couldn't do it, I never did it before and I'm pretty a new user of OF.

thank you

 niaz July 29, 2012 07:21

Dear mahmoud
do you use blockmesh. if yes, send me your case to describe you

Quote:
 Originally Posted by niaz (Post 374179) Dear mahmoud do you use blockmesh. if yes, send me your case to describe you
Dear Niaz,

No, I create it with Gambit (.msh) and I've used fluent3DMeshToFoam. have you any idea???

Thank you
Mostafa Mahmoudi

 niaz July 29, 2012 11:33

if you can please show it in the site for better understanding

1 Attachment(s)
Quote:
 Originally Posted by niaz (Post 374210) if you can please show it in the site for better understanding
its file size is about 19Mb. so I attach you a picture.
it is similar to the earth, it has a hot core and its surface is at ambient temperature. assume that the mantle of earth is a fluid. I want to solve the convection in mantle.

Thank you niaz
Mostafa Mahmoudi

 niaz July 29, 2012 14:45

if you set your center to (0 0 0) you can use your point for creating the fields.
you should define a vector field then use your points to calculate the vector.
gfield=g*(x/R*i+y/R*j+z/R*k)
R=(x2+y2+z2)^1/2

Quote:
 Originally Posted by niaz (Post 374223) Dear adam if you set your center to (0 0 0) you can use your point for creating the fields. you should define a vector field then use your points to calculate the vector. gfield=g*(x/R*i+y/R*j+z/R*k) R=(x2+y2+z2)^1/2
thank you niaz for your replies,
Where should I define this field? I never do anything such it before. do I apply it to g file in constant directory? please explain it for me with more details. how can I calculating the vector by using points? at least I have 1 million points.
a new problem is that my gravity is varying with depth!!!! it means that the gravity at 0.5R isn't equal to gravity at R!!!! What should I do????

again thank you niaz

 wyldckat July 29, 2012 18:22

Greetings to all!

This isn't the first time I see someone asking about changing how gravity works in OpenFOAM. But after a quick search, I only found this to be relevant: http://www.cfd-online.com/Forums/ope...tml#post360969 post #23
That particular post has an implementation that might be a good source of information or at least idea on how to do what you're looking for.

Good luck!
Bruno

Quote:
 Originally Posted by wyldckat (Post 374235) Greetings to all! This isn't the first time I see someone asking about changing how gravity works in OpenFOAM. But after a quick search, I only found this to be relevant: http://www.cfd-online.com/Forums/ope...tml#post360969 post #23 That particular post has an implementation that might be a good source of information or at least idea on how to do what you're looking for. Good luck! Bruno
Thank you wyldckat,

that was great, I got many ideas from it!
all of posts were about time dependence of gravity, but my problem is varying it with depth. it is independent of time. how can I apply it? of course, after defining my gravity pattern!!!! because I have problems in defining a center-oriented gravity field yet!

 niaz July 30, 2012 03:23

please look at your points in constant folder. your points are written in the form of (x y z).
you need to drive a unit vector which I discuss in last post.

Quote:
 Originally Posted by niaz (Post 374289) Dear adam please look at your points in constant folder. your points are written in the form of (x y z). you need to drive a unit vector which I discuss in last post.
hi niaz,

this is a portion of points file:

Code:

```/*--------------------------------*- C++ -*----------------------------------*\ | =========                |                                                | | \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          | |  \\    /  O peration    | Version:  2.0.1                                | |  \\  /    A nd          | Web:      www.OpenFOAM.com                      | |    \\/    M anipulation  |                                                | \*---------------------------------------------------------------------------*/ FoamFile {     version    2.0;     format      ascii;     class      vectorField;     location    "constant/polyMesh";     object      points; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 43003 ( (-0.01847759065 0.007653668647 0) (-0.01779042759 0.007552721936 0.005143644393) (-0.01960468925 0.003159255628 0.002382281129) (0.007679387991 -0.006329673946 -0.01734826296) (0.01688526706 -0.01020474922 0.003278848865) (-0.01834319804 0.002810689581 0.007458358384) (-0.01584939034 0.006818828176 0.01011436642) (-0.01460689264 0.01135644457 0.007594067049) (-0.01592745136 0.01184211524 0.002465887277) (-0.01597723029 0.01167792986 -0.002890340183) (-0.01295887432 0.01522695429 -0.0004554552274) (-0.01220887115 0.01514557064 0.004642752982) (-0.01213174065 0.01012345964 0.01226117587) (-0.01034525646 0.01425080084 0.009481051856) (-0.01950515249 0.003259328014 -0.00298760896) (-0.01772160189 0.007511999119 -0.005432742923) (-0.01591634427 0.001975366477 0.01194855273) (-0.01287687011 0.005423605639 0.01430981195) (-0.01940682589 -0.001585931407 0.004567267278) (-0.01994415536 -0.00137345384 -0.0005867635026) (-0.01762641938 -0.001868149175 0.009263873847) (-0.009026652487 0.01777835472 0.001565135287) (-0.007606758639 0.01740382727 0.006264504705) (-0.00769419341 0.01248809659 0.01359583875) (-0.005493030072 0.01606271423 0.01057430056) (-0.008817764601 0.008133616155 0.01600285336) (-0.01261059616 0.0005972273644 0.01551180788) (-0.009091657511 0.003292598427 0.01750715737) (-0.01806927596 0.003124101276 -0.007983812223) (-0.0190956556 -0.001197339263 -0.005824286735) (-0.01901153672 -0.005970452141 0.001707387688) (-0.01888850544 -0.005639026881 -0.003380197942) (-0.01249883992 0.01462668367 -0.005462520073) . . . .```
my problem is how can I do it? how can I establish a relation between g and this points?

thank you

 nimasam July 30, 2012 05:33

as my friend niaz told you before, you need a unit vector.
unit vector can be find like that:
(r-r0)/|r-r0|
which r is the position vector in each point and r0 is the position vector of your center,
as i before said i guess you should define a volVectorField instead of dimensionedVector (Burno post give you the idea how to implement it), then you can define easily such a function with funkySetFields or groovyBC