CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [swak4Foam] calculate gradient of U in groovyBC (https://www.cfd-online.com/Forums/openfoam-community-contributions/135992-calculate-gradient-u-groovybc.html)

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,

RodriguezFatz May 21, 2014 06:49

Hi!
Quote:

Originally Posted by lcchaos (Post 493277)
I noticed that snGrad(U) is not the inner product of normal vector of face and the deformation tensor.

But what is snGrad(U) else?

lcchaos May 21, 2014 08:16

Quote:

Originally Posted by RodriguezFatz (Post 493300)
Hi!

But what is snGrad(U) else?

Hi, snGrad(U) is the gradient of U in the surface normal direction.

RodriguezFatz May 21, 2014 08:18

Well ok, this does not account for the moving wall... or what is the problem?

lcchaos May 21, 2014 09:30

Quote:

Originally Posted by RodriguezFatz (Post 493325)
Well ok, this does not account for the moving wall... or what is the problem?

Philipp, I want to impose a moving wall boundary condition on the surface of a sphere. The motion results from the hydrodynamic force . Therefore, the gradient of U at the surface must be obtained to calculate the force. The problem is that an error appears when I use grad(U). Using snGrad(U) is incorrect physically.

gschaider May 23, 2014 06:32

Quote:

Originally Posted by lcchaos (Post 493340)
Philipp, I want to impose a moving wall boundary condition on the surface of a sphere. The motion results from the hydrodynamic force . Therefore, the gradient of U at the surface must be obtained to calculate the force. The problem is that an error appears when I use grad(U). Using snGrad(U) is incorrect physically.

You need the gradient in tangential direction? There is no built in implementation for that in OF (and therefor not in swak). Best way to get this would be to calculate grad(U) (in a seperate step. groovyBC can't do this) on the interior and then get that value from the cells next to the patch (with internalField). But this is probably rather inaccurate.

On the other hand: as you probably know the U of the sphere it is probably better to calculate grad(U) in tangential direction analytically

lcchaos May 25, 2014 10:34

Quote:

Originally Posted by gschaider (Post 493773)
You need the gradient in tangential direction? There is no built in implementation for that in OF (and therefor not in swak). Best way to get this would be to calculate grad(U) (in a seperate step. groovyBC can't do this) on the interior and then get that value from the cells next to the patch (with internalField). But this is probably rather inaccurate.

On the other hand: as you probably know the U of the sphere it is probably better to calculate grad(U) in tangential direction analytically

Hi Bernhard,

Thanks for your advice! I' m trying to do the calculation by modify the source code. My general idea is adding a new equation for the tensor grad(U) after the momentum equation is solved. Does this way can avoid the inaccuracy?

Regards
Chao


All times are GMT -4. The time now is 06:30.