lcchaos |
May 21, 2014 04:48 |
calculate gradient of U in groovyBC
Hello
I'm trying to calculate the force on a surface to update the moving-wall boundary condition of the surface. The gradient of U is needed for calculating viscous contribution of forces.
The code is based on the example on wiki
http://openfoamwiki.net/index.php/Co...ectionalForces
Code:
sphere
{
type groovyBC;
variables (
"pressure_force=sum(p*normal()*area());"
"viscous_force=sum(-snGrad(U)*area()*0.01);" //nu=0.01
"force=pressure_force+viscous_force;"
"acceleration=force*1000/33.51;" //density=1000;mass=33.51 SI
"torque=sum((pos()-vector(0,0.4,0))^(p*normal()*area()-snGrad(U)*area()*0.01));"
"angular_acceleration=torque*1000/0.5362;" //moment of inertia=0.5362
);
valueExpression "(time()>1.0) ? U+(vector(acceleration.x,0,0)+angular_acceleration^(pos()-vector(0,0.4,0)))*deltaT()*0.5 : U";
value uniform (0 0 0);
}
I noticed that snGrad(U) is not the inner product of normal vector of face and the deformation tensor. So I change snGrad(U) into grad(U)+grad(U)T (T means transport matrix). However, I got an error
Code:
--> FOAM FATAL ERROR:
Parser Error for driver PatchValueExpressionDriver at "1.1-4" :"field grad not existing or of wrong type"
"grad(U)"
^^^^
--|
Thanks for your help!
Regards,
|