CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Compute shear stress interFoam (https://www.cfd-online.com/Forums/openfoam-post-processing/61393-compute-shear-stress-interfoam.html)

hsieh February 12, 2007 16:09

Hi, I completed a case usin
 
Hi,

I completed a case using interFoam. How can I compute shear stress of the 3D domain based on the transient data?

Thanks!

Pei

hartinger February 13, 2007 06:04

// you get the stress tensor w
 
// you get the stress tensor with:

volTensorField stressTensor = - mu * (fvc::grad(U) + (fvc::grad(U)).T());
// there might be a better way describing that, if haven't used the stressTensor directly

//if you're only interested in the shearRate, for shear-thinnning for example:

volScalarField shearRate = mag(fvc::grad(U));

for the wall shear stress check the tool 'wallShearStress'

regards
markus

hsieh February 13, 2007 10:28

Thanks a lot Markus! Pei
 
Thanks a lot Markus!

Pei

santos February 13, 2007 18:58

Hello Pei The tool 'wallShe
 
Hello Pei

The tool 'wallShearStress' didnt work for me (it kept asking me about turbulence model, but I was using DNS), so what I did was:

- Calculate U gradient at wall (using wallGradU utility);

- Then calculate the magnitude of wall shear stress by using the following:
volScalarField shear
(
IOobject
(
"shear",
runTime.timeName(),
mesh,
IOobject::NO_READ
),
8.9e-4*sqrt(sqr(wallGradU.component(vector::X)) + sqr(wallGradU.component(vector::Z)))
);
shear.write();

X and Z components were relevant in my case, your situation may be different. 8.9e-4 is the dynamic viscosity for water at room temperature, this way the shear stress comes in Pa.

Hope that this can help you!

Regards,
José Santos

hsieh February 16, 2007 14:15

Hi, José Santos, Thanks for
 
Hi, José Santos,

Thanks for the reply!

Do you have any idea if I would like to compute the tangential direction of wall shear stress? Because my wall is curved, so, the X and Z components may not necessarily tangent.

Pei

liu February 16, 2007 14:41

dot product with n (normal dir
 
dot product with n (normal direction)

hsieh February 16, 2007 16:42

Hi, Xiaofeng: Thanks for th
 
Hi, Xiaofeng:

Thanks for the answer. I did try it, but, I got a message said that n is not defined. What will I have to include to get n in post-processing?

Pei

liu February 16, 2007 17:38

I remember there are some disc
 
I remember there are some discussion on this issure. Search "wall shear stress" may do the work.

hsieh February 16, 2007 18:22

Hi, Xiaofeng, I did do a se
 
Hi, Xiaofeng,

I did do a search on "wall shear stress". I have also looked at the source code of wallShearStress under postprocessing/wall. It is not obvious to me how to get n.

Pei

philippose February 16, 2007 18:56

Hi, I just happened to brow
 
Hi,
I just happened to browse through this dialogue regarding calculating wall shear stresses.

In the simple case, if you take laminar flow, the wall shear stress is calculated using the equation:

Tau (shear stress) = mu * (dU/dy)

In this equation, "mu" is the dynamic viscosity of the medium, and "(dU/dy)" is the change in velocity "U" with change in "y", which is the distance from the wall in a direction normal to the wall.

Now, in the case of incompressible solvers in openFOAM, the whole system is normalised with respect to the fluid density "rho".... so in this case, the dynamic viscosity (mu) is given by:

mu = nu * rho

Where "nu" is the kinematic viscosity, defined in the "transportProperties" dictionary, and "rho" would depend on the fluid you are working with.

Now, to implement this in openFOAM, there exists a class member called "snGrad". This directly gives you the gradient of velocity (dU/dy) normal to each face of the wall patches.

So, you would use:

wallShear = nu * rho * mesh.boundaryField()[patchID].snGrad()

This directly gives you the wall shear stress (assuming the "patchID" refers to a wall patch ofcourse). Here, you can read "nu" from the transportProperties dictionary, and you will have to define "rho" somewhere.

When the case is not laminar, but turbulent, then things look a bit different, which is why you may have gotten confused when you looked through the wallShearStress source-code.

In this case, the Reynolds Stress Tensor gives you the shear stress, but not necessarily normal to the face, and you need to resolve the tensor along the normal to the face in order to obtain the wall shear stress.

This is because in the case of turbulent simulations, the viscosity is not a constant, and is an effective value which is a result of the turbulence model, and the Reynolds Stress Tensor.

So, to calculate the wall shear stress in the case of a turbulent simulation, you need to do something like:

wallShear = (-mesh.Sf().boundaryField()[patchID]/(mag(mesh.Sf().boundaryField()[patchID])) ) & (turbulence->R()().boundaryField()[patchID])

The above equation will give you the wall shear stress with the velocity gradient resolved in the direction normal to each face in the patch.

Have a nice day!

Philippose

hsieh February 17, 2007 05:52

Hi, Philipose, Thanks for t
 
Hi, Philipose,

Thanks for the detailed post.

The solver I used was standard interFoam. So, this is a laminar case.

The question I am having is:

Does U.boundaryField()[patchi].snGrad() contains normal component of shear (shear stress normal to wall)?

In my case, I have a curve wall with strong centrifugal force. I am only interested in the shear stress tangent to the wall.

Do a n dot U.boundaryField()[patchi].snGrad() should remove the normal component, correct?

What do I have to do to get n in post-processing?

Pei

philippose February 17, 2007 08:10

Hello Pei, A Good day to yo
 
Hello Pei,
A Good day to you!

Looks like you have a small confusion regarding the issue of shear stress at a wall.

Lets go from the basics.... we know that for a Newtonian fluid, shear stress (Tau) is given by the equation:

Tau = mu * (dU/dy)

This can be seen in the image below:

http://www.cfd-online.com/OpenFOAM_D...ges/1/3849.png

In your case, the "boundary plate (stationary)" would be the wall (i.e., the fluid is moving relative to the wall).

In the image, the term "gradient, dU/dy" is what is given by the openFOAM term:

U.boundaryField()[patchi].snGrad()

It is the "change in velocity U, with distance y, normal to the wall", which is basically, the gradient "dU/dy".

When you multiply this term with the dynamic viscosity of the medium, you get the shear stress on the wall due to the motion of the fluid, and ofcourse, this shear stress is by definition, tangential to the wall.

So you dont need to take a dot product of the snGrad with a vector tangential to the surface, because by definition, tangential wall shear stress is proportional to the gradient of velocity normal to the wall.

santos February 17, 2007 08:54

Hello Philippose I have a q
 
Hello Philippose

I have a question regarding your good explanation of wall shear stress.

When we calculate:

U.boundaryField()[patchi].snGrad()

we get the velocity gradient at the wall, and in OpenFOAM definition, U is a vector with components x, y and z, so the previous calculation would give us (assuming y is normal to the wall):

(dUx/dy, dUy/dy, dUz/dy)

Isnt dUy/dy a normal stress? And the shear stress wouldnt be calculated using the other two components?

Regards,
José Santos

philippose February 17, 2007 14:09

Hi José, Interesting questio
 
Hi José,
Interesting question! In order to answer that, I guess we will have to look deeper into the implementation of the "snGrad" function in OpenFOAM.

I was trying to locate the definition of the function, and found something in the "fvPatchField.H" file in the "finiteVolume/lnInclude" directory of the openFOAM source.

As far as I understood, the snGrad function takes the difference between the value (in this case U) at the patch face, and in the internal field next to the patch, and divides it by the distance from the patch face to the centre of the corresponding cell.

So technically, if there exists a velocity component in a direction normal to the wall, that would come up as a term in the stress calculation (I hope someone corrects me if I am wrong :-)!)

On the other hand, when one talks about laminar flow, one of the basic assumptions is that the fluid flows in the form of shear layers in regions close to walls, and at a distance of one cell height from the wall, you will not (must not / should not) have flow in a direction normal to the wall... if a normal component exists so close to a wall, it would be more or less violating the laminar flow assumptions.

If I am wrong, it would be great if someone could correct me :-)!

Have a nice day!

Philippose

hsieh February 18, 2007 06:55

Thanks Philippose! I get it
 
Thanks Philippose!

I get it now.

Pei

giovanni May 30, 2007 12:19

Hi all, I'm trying to use M
 
Hi all,

I'm trying to use Markus's

volTensorField stressTensor = - mu * (fvc::grad(U) + (fvc::grad(U)).T());

in a rhoSimpleFoam case for OpenFOAM 1.4, but appears this error message:

error: 'class Foam::tmp<foam::geometricfield<foam::tensor<double >, Foam::fvPatchField, Foam::volMesh> >' has no member named 'T'

Can anyone help me to solve this problem?

Thanks a lot!


Giovanni

hartinger May 30, 2007 13:12

Hi Giovanni, the stuff i po
 
Hi Giovanni,

the stuff i posted wasn't correct, do it like that:

volTensorField gradU = fvc::grad(U);

// stress tensor
volTensorField tau =
- mu * (gradU + gradU.T());

giovanni May 31, 2007 07:18

Thank you Markus, I'll try
 
Thank you Markus,

I'll try as soon as possible (this afternoon I think)!

Have a nice day!

Giovanni

ngj May 6, 2008 10:30

Hi and good eveninghttp://www.
 
Hi and good eveninghttp://www.cfd-online.com/OpenFOAM_D...part/happy.gif

I have been reading the above discussion several times, and I have been thinking what to do about the bed shear stresses. I like the procedure of simply calculating

dU_dn = U.boundaryField().snGrad()

though in my case, I will have vertical velocity components in the cell next to the wall, as I consider non-stationary flows such as wave boundary layers. Thus I will suggest a slightly modified version of Phillipposes (please consider if I am off track).

As I get a non-zero surface-normal component in dU_dn the bed shear stress is not aligned with the bed, which is wrong. Thus I suggest to make a projection of dU_dn onto the boundary patch. Then the bed shear stress will definitely be aligned with the bed, and therefor being shear stress components only and not a combination of shear and normal stresses.

Based on this: http://www.euclideanspace.com/maths/geometry/elements/plane/lineOnPlane/index.ht m l
the projection reads:

tau / mu = sf x (dU_dn x sf / magSf) / magSf

where sf is the surface normal gradient, magSf is the magnitude of sf and x takes the role of the cross product. I have projected dU_dn, since snGrad() takes care of the non-orthogonality of the mesh.

I would like to hear if you agree and especially if there are any numerical traps which I have walked straight into.

Best regards,

Niels

sven June 10, 2009 15:30

Hello,

in this thread you it is often mentioned to use something like "U.boundaryField()[patchi].snGrad()" to calculate a gradient. How do I do this? is this a command for bash or what do I have to do to use this function for calculating a gradient??

idrama March 26, 2010 06:56

Hey Foamers,

does anybody know a book or paper where the formula in wallShearStress.C is mathematically derived? I need something which I can cite it in my scientific work (I must guarantee that it work).

Furthermore, does anybody know a justifaction that I can use this formular even for two-phase flows, especally, in VOF?

Cheers in advanced!

idrama April 15, 2010 03:46

Hey folks!

I have used interFoam with an k-e-model. I modified wallShearStress.C that the material property directory is reading correctly. Now I need to know if the formular is still valid.

cheers

andboje April 16, 2010 06:53

Hi
I am trying to implement calculations of the shear stress in an interFoam case, simulating injection moulding.
I have been looking at the threads on this forum trying to figure out how to do this. In this thread it seems that something similar is done, but being new to the world of OpenFOAM I am looking for some more basic instructions.
Where do I implement the c++ code? Do I have to create new files or modify existing ones?
If someone has done shear stress implementation, I would much appreciate some help. For instance if you have a case where this is done I could take a look at, not nessesarily interFOAM. The same goes for the wallShearStress utility.

Best Regards
Anders

Daniele111 June 8, 2010 17:20

Hi
In Ras turbolent model, if i use wallShearStress tool, the result is normalised?

Best regards

idrama June 9, 2010 02:08

What you mean by "normelised"? If you mean that the calculated vectors have the length one, then No :eek: !. The vectors are actually tensor of rank 1, i.e. the vectors points in the direction to where forces acts and the magnitude of them are force acting.

Cheers

Daniele111 June 9, 2010 07:56

No, i would know if is there rho or not in the result

Best regards

Daniele111 June 25, 2010 07:00

Hi
How can I calulate the wallShearStress runtime?
Thanks

Daniele111 June 25, 2010 09:04

Can I use sampleDict to sample wallShearStress on bottom? I do:
1)blockMesh
2)simpleFoam
3)wallShearStress
4)sample -latestTime

but in my set directory output file of whall shear stress is 0 everywhere...

Peter85 September 16, 2010 16:22

Hi@all,

this week, I simulated a channel flow using rhoSimpleFoam with k-Omega-SST-Modell. To validate the results, I need to calculate the friction coefficient cf(Tau_wall / (0.5*roh_0*U_0^2).

There are now 2 possibilities to get Tau_wall.
First by taking the wall shear stress computed by the WallShearStress postprocessing tool. (Simply taking the magnitude of the wallshearstresses as Tau_wall). The second approach is to use the wallGradU tool, and compute the cf as described above by Santos. Surprisingly, the results were quite different (diffference of more than 10 Percent).

Is anybody able to explain the value differences?
My guess is that the shear stresses calculated by the wallshearstress tool are not exact. Is that true?

Thanks,

Peter

jiejie February 27, 2011 18:45

Quote:

Originally Posted by philippose (Post 186008)
Hi,


In the simple case, if you take laminar flow, the wall shear stress is calculated using the equation:

wallShear = nu * rho * mesh.boundaryField()[patchID].snGrad()

So, to calculate the wall shear stress in the case of a turbulent simulation, you need to do something like:

wallShear = (-mesh.Sf().boundaryField()[patchID]/(mag(mesh.Sf().boundaryField()[patchID])) ) & (turbulence->R()().boundaryField()[patchID])

Philippose

HI Philippose

I have tried both laminar flow and turbulent flow wss as you suggested for the same simulation. How come the wss calculated by the two methods vary so much from each other?

Do you need to multiple rho*nu for the turbulent case?

Thanks

Sergio13 April 11, 2011 12:17

Hello Guys
I am also very new to OpenFoam and CFD, and I was wondering how can I calculate the Viscous Stresses (say in a given point of the fluid).

In addition, note that instead of RAS, I am using a LES Turbulence model.

Thanks for your help

Sergio

David* June 23, 2011 09:33

There are so much unanswered questions in here, so I try to answer two of them:
Quote:

Originally Posted by Daniele111 (Post 262277)
No, i would know if is there rho or not in the result

At least for incompressible cases, rho is excluded, so you have to multiply the results from wallShearStress by your density.


Quote:

Originally Posted by Daniele111 (Post 264521)
Can I use sampleDict to sample wallShearStress on bottom? I do:
1)blockMesh
2)simpleFoam
3)wallShearStress
4)sample -latestTime

but in my set directory output file of whall shear stress is 0 everywhere...

The trick is to use
Code:

surfaces
(
        type        patch;
        patchName  bottom;
)

in your sampleDict.

Hope that helps someone!

oort January 14, 2012 07:55

Hello

So if we run the wallShearStress utility we must multiply the values by the rho?

For instance in my case i'm simulating water flow in a tube with spacers and after running the wallShearStress it gives me as in the figure.

The value of maximum magnitude of "displayed" wall shear stress is near 0.00043 (in unknown units...). If I multiply by the density of water (near 996 kg/m³) its gives 4.3 (in unkown units).

Is this new units Pascal?

Thanks,

Duarte Silva


http://www.carloscompleto.com/images/wss.png

idrama January 14, 2012 09:35

Yes, according to the wallShearStress.C code you must multiply by rho to obtain pascal. But to be sure, open the dictionaries wallShearStress in the time directories by using a editor and take a look at the dimension line. Here you can get the dimension of the data. Just do an dimension analysis and you will see that the data have to be multiplied by the density.

Elise August 28, 2012 08:12

Quote:

Originally Posted by philippose (Post 186008)
Hi,
wallShear = (-mesh.Sf().boundaryField()[patchID]/(mag(mesh.Sf().boundaryField()[patchID])) ) & (turbulence->R()().boundaryField()[patchID])

The above equation will give you the wall shear stress with the velocity gradient resolved in the direction normal to each face in the patch.

Philippose

Ok, but what is the meaning of the x, y and z values? Is the wall shear stress normal to each face then the magnitude of those values with x,y and z cartesian contributions? : Magnitude is then the wall shear stress normal to each face

What does the quoted code means;
mesh.Sf/mag(mesh.Sf) ; what does this term do? : gives a unit vector normal to the boundary element
& (turbulence->R()() ; is this the lookup of the wall shear stress from the Reynolds stress? : Yes, Reynolds stress

Yosmcer May 10, 2013 08:54

I know this post is old, but it is the best one I found related to my problem.

I have a wall that is parallel to the X axis, flow is laminar.

I compute the wallShearStress, and have a result.

I use paraFoam to look at this with Paraview.

I plot over line the wallShearsStress by placing the line on the boundary.

I see that I have a value for the magnitude of the wallShearStress, and three others values, one for each direction.

As my face is parallel to the X axis, I expect to have a signed value in the X direction, a value approximating zero in the two other direction, and the absolute value of the X's direction value.

But I also have a Y direction value, so a normal compound to the face. And this value is not negligible (the z value is negligible, but no flow in this direction).
The magnitude is the vectorial sum of the X and Y values (without the sign).

[EDIT]
I think this is because the shears stress must equilibrate at edges. So there is a normal compound corresponding to the tangential one of the perpendicular face, and a continuity of this across the face.

http://www.codecogs.com/users/23287/...tress-0002.png

Image from : http://www.codecogs.com/reference/en...ear_stress.php

So, considering the AB face, there is a normal compound to this face at the points A and B, but opposite, so there must be a continuous field across the face, and the resulting shear stress in not totally tangential to the face.

Please, correct me if there is/are mistake(s).
[\EDIT]

sophie_l May 22, 2013 08:11

Hi Yosmcer,

I am using interFoam, however the wallShearStress utility is intended for single phase transport models. I modified it to include "incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.H" and etc., and I've modified the option file according to that of interFoam. The compiling is ok, but when I run it, error message pops out.

Quote:

Time = 0
Reading field U
Reading/calculating face flux field phi
Selecting incompressible transport model Newtonian
Selecting incompressible transport model Newtonian

--> FOAM FATAL ERROR:
request for volScalarField alpha1 from objectRegistry region0 failed
available objects of type volScalarField are
2
(
nu1
nu2
)

From function objectRegistry::lookupObject<Type>(const word&) const
in file /lv1/data/openfoam/OpenFOAM-1.7.1/src/OpenFOAM/lnInclude/objectRegistryTemplates.C at line 139.
FOAM aborting
Don't know what solver you are using, but how did you compute the wallShearStress?

Could you shed some light on my problem please?

Many thanks in advance.
Sophie

Phicau May 22, 2013 10:15

Hi Sophie,

alpha1 is not in the object registry in this case. You have to do the same as with U, read it from the time folder.

Best,

Pablo

sophie_l May 22, 2013 10:40

Hi Pablo,

Thank you so much! I've got it solved.

Best,
Sophie

kmou December 9, 2013 12:45

Quote:

Originally Posted by andboje (Post 254919)
Hi
I am trying to implement calculations of the shear stress in an interFoam case, simulating injection moulding.
I have been looking at the threads on this forum trying to figure out how to do this. In this thread it seems that something similar is done, but being new to the world of OpenFOAM I am looking for some more basic instructions.
Where do I implement the c++ code? Do I have to create new files or modify existing ones?
If someone has done shear stress implementation, I would much appreciate some help. For instance if you have a case where this is done I could take a look at, not nessesarily interFOAM. The same goes for the wallShearStress utility.

Best Regards
Anders

Hi Anders,
I have the exact same issue and unfortunately did not understand how to do this as I am myself very new to C++ and OpenFOAM. I would like to calculate dU/dy for my fuel injection with interFoam and then the shear stresses.
I would appreciate your knowledge on this, if you did figure it out.
Thank you very much.


All times are GMT -4. The time now is 01:14.