CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   A problem for equation (http://www.cfd-online.com/Forums/openfoam/93825-problem-equation.html)

bojiezhang October 27, 2011 10:22

A problem for equation
 
HI every former:
I have a problem about equation. Now I have a equation like this:
fvVectorMatrix UEqn
(
fvm::ddt(rho, U)
+ fvm::div(rhoPhi, U)
- (add)
);
the function for "add" in the () is like this:
for X dirction: add(x)=x ; fro Y dirction: add(y)=u.component(y)*y; for Z dirction add(z)=0;
how can add for this? I really hope someone can heip me. Thank you in davance!

bojie zhang

nimasam October 30, 2011 03:24

first declare a volVectorField add variable, then loop over it and fill it with your values.
Quote:

forAll (add , celli)
{
add[celli] = vector (mesh.C()[celli].x() ,U[celli].y(),0.0);

}
then add it in your Eqn.
Quote:

fvVectorMatrix UEqn
(
fvm::ddt(rho, U)
+ fvm::div(rhoPhi, U)
- (add)
);
of course i didn't have checked it, but its the general idea

bojiezhang October 31, 2011 04:52

Thank you very much! I will try it right now!


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