CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Add a custom body force to the momentum equation, f=f(x,y,z) (http://www.cfd-online.com/Forums/openfoam-programming-development/98169-add-custom-body-force-momentum-equation-f-f-x-y-z.html)

enoch March 5, 2012 05:17

Add a custom body force to the momentum equation, f=f(x,y,z)
 
I wanted to add a force to the alpha-phase moment equation.
This is a funciton of x, y and z location, which force is not dependent on time. For an exmaple, customF = customF(x,y,z) where i,j and k are indexing counters. Below is the folmula expression that I'd like to use.

if(x(i)>x0 or x(i)<xl )
customF(i) = a*x(i-1)*y(j)*z(k)
+ a*x(i)*y(j)*z(k)
+ a*x(i+1)*y(j)*z(k);
else
customF(i) = 0;

The vector customF is composed of three components (x,y,z). How can I write this force in the OF?

gschaider March 5, 2012 15:44

Quote:

Originally Posted by enoch (Post 347647)
I wanted to add a force to the alpha-phase moment equation.
This is a funciton of x, y and z location, which force is not dependent on time. For an exmaple, customF = customF(x,y,z) where i,j and k are indexing counters. Below is the folmula expression that I'd like to use.

if(x(i)>x0 or x(i)<xl )
customF(i) = a*x(i-1)*y(j)*z(k)
+ a*x(i)*y(j)*z(k)
+ a*x(i+1)*y(j)*z(k);
else
customF(i) = 0;

The vector customF is composed of three components (x,y,z). How can I write this force in the OF?

You might want to have a look at this (the thread discusses various approaches to a similar problem, but my favourite is - for obvious reasons - expressionSource from swak4Foam):
http://www.cfd-online.com/Forums/ope...tml#post329700


All times are GMT -4. The time now is 13:10.