CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Measuring wall shear stress in bend pipe (https://www.cfd-online.com/Forums/openfoam/92507-measuring-wall-shear-stress-bend-pipe.html)

liguifan September 16, 2011 00:43

Measuring wall shear stress in bend pipe
 
My geometry is a bifurcation and on of the vessel is bent. I want to measure the wall shear stress along the bent vessel. The wall shear stress is already calculated. I only find a way to measure the wall shear stress along the straight pipe but no idea how to do it in bent pipe.

Any hind would be helpful.

Cheers!

Bernhard September 16, 2011 01:40

You can use the utility wallShearStress.

liguifan September 16, 2011 01:46

Quote:

Originally Posted by Bernhard (Post 324339)
You can use the utility wallShearStress.

Hi Bernhard,

I think wallShearStress utility is for turbulent flow. My case is laminar flow and I want to plot the wall shear stress along the pipe. My code is to find laminar flow but don't know how to measure it.

Thanks for the hind anyway.

Bernhard September 16, 2011 02:06

Of course you can still use that utility. I suppose it reads turbulenceProperties or RASProperties. You set it to laminar there. Otherwise you make your own version of the wallShearStress utility and update it for laminar flow. I think the first method will work, since the RASModels have a dummy laminar model included.

Amir September 16, 2011 02:38

Quote:

Originally Posted by Bernhard (Post 324339)
You can use the utility wallShearStress.

Dear Bernhard,
I think this utility needs some modifications because it computes wall traction instead of wall shear stress, right?

liguifan September 16, 2011 03:55

Quote:

Originally Posted by Amir (Post 324342)
Dear Bernhard,
I think this utility needs some modifications because it computes wall traction instead of wall shear stress, right?

Hi Amir,

What modification have you done to measure the wall shear stress ?

Thanks

liguifan September 16, 2011 03:59

Quote:

Originally Posted by Bernhard (Post 324341)
Of course you can still use that utility. I suppose it reads turbulenceProperties or RASProperties. You set it to laminar there. Otherwise you make your own version of the wallShearStress utility and update it for laminar flow. I think the first method will work, since the RASModels have a dummy laminar model included.

Hi Bernhard,

I will try it later today. However, i still don't understand how to plot wall shear stress along a bent pipe.

Have you got any idea for that?

Thanks

Amir September 16, 2011 05:08

Quote:

Originally Posted by liguifan (Post 324358)
Hi Amir,

What modification have you done to measure the wall shear stress ?

Thanks

Dear Guifan,

In many solvers such as FLUENT and OpenFOAM wall traction is considered as wall shear stress and I don't know why!
If we assume T as stress tensor and n as unit normal vector of desired face we have:
t= T.n ; t= traction (force vector exerted to desired face per unit area); the utility compute this, but we want:
shear stress= t - (t.n)n ;which shear stress is tangential vector here.

Bests,

liguifan September 16, 2011 23:30

Can any one tell me the difference between wallShearStress and the definition?

For newtonian flow the wall shear stress is defined as mu*du/dy which is proportional to the normal velocity gradient to the wall
But in wallShearStress it is defined:
wallShearStress.boundaryField()[patchi] =
(
-mesh.Sf().boundaryField()[patchi]
/mesh.magSf().boundaryField()[patchi]
) & Reff.boundaryField()[patchi]; -- What does this code mean? why it calculated wall shear stress ?

In wallGradU:
The velocity gradient is defined as
wallGradU.boundaryField()[patchi] =
-U.boundaryField()[patchi].snGrad(); -- This makes sense to me.
And mu*wallGradU is the definition one.

Can anyone explain?

liguifan September 16, 2011 23:36

Quote:

Originally Posted by Amir (Post 324369)
Dear Guifan,

In many solvers such as FLUENT and OpenFOAM wall traction is considered as wall shear stress and I don't know why!
If we assume T as stress tensor and n as unit normal vector of desired face we have:
t= T.n ; t= traction (force vector exerted to desired face per unit area); the utility compute this, but we want:
shear stress= t - (t.n)n ;which shear stress is tangential vector here.

Bests,

Dear Amir,

Thanks for your reply.

To my knowledge, the wall shear stress is mu*velocity gradient. In the code of wallShearStress:
-mesh.Sf().boundaryField()[patchi]
/mesh.magSf().boundaryField()[patchi]
Do you mean this is the T(stress tensor)?

Why the say shear stress = t-(t.n)n ? If T is the shear tensor, isn't T's normal component T.n already the shear stress?

I am confused here.

Amir September 17, 2011 07:37

Quote:

Originally Posted by liguifan (Post 324480)
Dear Amir,

Thanks for your reply.

To my knowledge, the wall shear stress is mu*velocity gradient. In the code of wallShearStress:
-mesh.Sf().boundaryField()[patchi]
/mesh.magSf().boundaryField()[patchi]
Do you mean this is the T(stress tensor)?

Why the say shear stress = t-(t.n)n ? If T is the shear tensor, isn't T's normal component T.n already the shear stress?

I am confused here.

Dear Guifan,

T is stress tensor and n is unit normal vector, according to openFOAM definitions:
Code:

n=-mesh.Sf().boundaryField()[patchi] / mesh.magSf().boundaryField()[patchi]
and,
Code:

T=Reff.boundaryField()[patchi]
so t=T.n is:
Code:

            wallShearStress.boundaryField()[patchi] =
            (
                -mesh.Sf().boundaryField()[patchi]
                /mesh.magSf().boundaryField()[patchi]
            ) & Reff.boundaryField()[patchi];

it's traction definition not shear force. in other words, it contains normal component, so I proposed:
Code:

shear stress= t - (t.n)n
Bests,

liguifan September 18, 2011 08:21

Quote:

Originally Posted by Amir (Post 324505)
Dear Guifan,

T is stress tensor and n is unit normal vector, according to openFOAM definitions:
Code:

n=-mesh.Sf().boundaryField()[patchi] / mesh.magSf().boundaryField()[patchi]
and,
Code:

T=Reff.boundaryField()[patchi]
so t=T.n is:
Code:

            wallShearStress.boundaryField()[patchi] =
            (
                -mesh.Sf().boundaryField()[patchi]
                /mesh.magSf().boundaryField()[patchi]
            ) & Reff.boundaryField()[patchi];

it's traction definition not shear force. in other words, it contains normal component, so I proposed:
Code:

shear stress= t - (t.n)n
Bests,

Dear Amir,

Thanks for the reply.

I found that the tangetient component of traction tensor is t-(t.n)n as you decribed.

For the code stuff:
Is this the right thing:
forAll(real_wall_shear_stress.boundaryField(),patc hi)
{
wallShearStress.boundaryField()[patchi] =
(
-mesh.Sf().boundaryField()[patchi]
/mesh.magSf().boundaryField()[patchi]
) & Reff.boundaryField()[patchi];[/CODE]
real_wall_shear_stress.boundaryField()[patchi]= wallShearStress-(wallShearStress&(mesh.Sf().boundaryField()[patchi] /mesh.magSf().boundaryField()[patchi]))&(mesh.Sf().boundaryField()[patchi]/mesh.magSf().boundaryField()[patchi])
}
the right results since mesh.Sf().boundaryField()[patchi] /mesh.magSf().boundaryField()[patchi] is the "n"

Please let me know if there is something wrong.

Btw, why the tangential component of t is not t&n but t-(t&n)&n ?

Thanks again!

Amir September 18, 2011 08:42

Quote:

Originally Posted by liguifan (Post 324553)
Dear Amir,

Thanks for the reply.

I found that the tangetient component of traction tensor is t-(t.n)n as you decribed.

For the code stuff:
Is this the right thing:
forAll(real_wall_shear_stress.boundaryField(),patc hi)
{
wallShearStress.boundaryField()[patchi] =
(
-mesh.Sf().boundaryField()[patchi]
/mesh.magSf().boundaryField()[patchi]
) & Reff.boundaryField()[patchi];[/CODE]
real_wall_shear_stress.boundaryField()[patchi]= wallShearStress-(wallShearStress&(mesh.Sf().boundaryField()[patchi] /mesh.magSf().boundaryField()[patchi]))&(mesh.Sf().boundaryField()[patchi]/mesh.magSf().boundaryField()[patchi])
}
the right results since mesh.Sf().boundaryField()[patchi] /mesh.magSf().boundaryField()[patchi] is the "n"

Please let me know if there is something wrong.

Btw, why the tangential component of t is not t&n but t-(t&n)&n ?

Thanks again!

There are few errors in this part of code:
First of all: I'm not sure that inner product is overloaded for 2 variables which one of them is scalar and another is vector, so it's better to use:
Code:

t-(t&n)n
As you know, t&n retrieves projection of vector t on normal vector n, so the tangential component would be
Code:

t-(t&n)n
Another tip; OpenFOAM can not compile such successive terms (as I know; because I'm new in developing); I developed a code for that which may help (it's not the best one as I said before):
Code:

                  volTensorField gradU=fvc::grad(U);
                  volTensorField T=mu*(gradU+gradU.T());
                  volVectorField nn
            (
                IOobject
                (
                    "nn",
                    runTime.timeName(),
                    mesh,
                    IOobject::NO_READ,
                    IOobject::NO_WRITE
                ),
                          mesh,
                          vector::zero
            );
        forAll(nn.boundaryField(), patchI)
        {
            nn.boundaryField()[patchI] =
            (
                -mesh.Sf().boundaryField()[patchI]
                /mesh.magSf().boundaryField()[patchI]
            );
        }
                         
        forAll(wallShearStress.boundaryField(), patchI)
        {
            wallShearStress.boundaryField()[patchI] =
              nn.boundaryField()[patchI] & T.boundaryField()[patchI];
        }
                 
        forAll(normal.boundaryField(), patchI)
        {
            normal.boundaryField()[patchI] =
                                  (nn.boundaryField()[patchI] & wallShearStress.boundaryField()[patchI])
                                  *nn.boundaryField()[patchI];
        }
       
        forAll(shear.boundaryField(), patchI)
        {
                          shear.boundaryField()[patchI] =
                          wallShearStress.boundaryField()[patchI]-normal.boundaryField()[patchI];
        }

Here, shear variable is what you need and wallShearStress is previous definition.
Obviously, you can change some part to use other stress tensor objects.

Bests,

liguifan September 19, 2011 19:23

Quote:

Originally Posted by Amir (Post 324555)
There are few errors in this part of code:
First of all: I'm not sure that inner product is overloaded for 2 variables which one of them is scalar and another is vector, so it's better to use:
Code:

t-(t&n)n
As you know, t&n retrieves projection of vector t on normal vector n, so the tangential component would be
Code:

t-(t&n)n
Another tip; OpenFOAM can not compile such successive terms (as I know; because I'm new in developing); I developed a code for that which may help (it's not the best one as I said before):
Code:

                  volTensorField gradU=fvc::grad(U);
                  volTensorField T=mu*(gradU+gradU.T());
                  volVectorField nn
            (
                IOobject
                (
                    "nn",
                    runTime.timeName(),
                    mesh,
                    IOobject::NO_READ,
                    IOobject::NO_WRITE
                ),
                          mesh,
                          vector::zero
            );
        forAll(nn.boundaryField(), patchI)
        {
            nn.boundaryField()[patchI] =
            (
                -mesh.Sf().boundaryField()[patchI]
                /mesh.magSf().boundaryField()[patchI]
            );
        }
                         
        forAll(wallShearStress.boundaryField(), patchI)
        {
            wallShearStress.boundaryField()[patchI] =
              nn.boundaryField()[patchI] & T.boundaryField()[patchI];
        }
                 
        forAll(normal.boundaryField(), patchI)
        {
            normal.boundaryField()[patchI] =
                                  (nn.boundaryField()[patchI] & wallShearStress.boundaryField()[patchI])
                                  *nn.boundaryField()[patchI];
        }
       
        forAll(shear.boundaryField(), patchI)
        {
                          shear.boundaryField()[patchI] =
                          wallShearStress.boundaryField()[patchI]-normal.boundaryField()[patchI];
        }

Here, shear variable is what you need and wallShearStress is previous definition.
Obviously, you can change some part to use other stress tensor objects.

Bests,

Dear Amir,

Thanks for the correction.

This code works however the results are a little bit different from it should be in my case. After a little bit research. I found that the definition of Shear tensor is T=2*mu*(gamma_hat)*D where D=1/2(gradU+gradU.T()).
gamma_hat is shear rate. For newtonian case , mu is independent of gamma_hat, for non-Newtonian case, mu is a function of gamma_hat.

gamma_hat=sqrt(2.0)*mag(symm(gradU)) for Newtonian case.

In your code, I found "volTensorField T=mu*(gradU+gradU.T())" and there is a difference in gamma_hat(shear rate) term. Did you miss it or I did something wrong( please correct me if I am wrong).

Cheers!

Amir September 19, 2011 22:14

Quote:

Originally Posted by liguifan (Post 324767)
Dear Amir,

Thanks for the correction.

This code works however the results are a little bit different from it should be in my case. After a little bit research. I found that the definition of Shear tensor is T=2*mu*(gamma_hat)*D where D=1/2(gradU+gradU.T()).
gamma_hat is shear rate. For newtonian case , mu is independent of gamma_hat, for non-Newtonian case, mu is a function of gamma_hat.

gamma_hat=sqrt(2.0)*mag(symm(gradU)) for Newtonian case.

In your code, I found "volTensorField T=mu*(gradU+gradU.T())" and there is a difference in gamma_hat(shear rate) term. Did you miss it or I did something wrong( please correct me if I am wrong).

Cheers!

Dear Guifan,

Your definition is wrong; here, viscosity is a function of shear rate, it's not a multiplication term! :eek:
T=2 \eta (\gamma\dot{} ) D
The differences maybe due to coarse grid near boundaries or schemes for gradients.

Bests,

liguifan September 19, 2011 22:28

Quote:

Originally Posted by Amir (Post 324775)
Dear Guifan,

Your definition is wrong; here, viscosity is a function of shear rate, it's not a multiplication term! :eek:
T=2 \eta (\gamma\dot{} ) D
The differences maybe due to coarse grid near boundaries or schemes for gradients.

Bests,

Dear Amir,

Thanks for the correction. I misunderstood the definition.

I try to finer my mesh and see what happened next.

Regards

liguifan September 23, 2011 06:06

Dear Amir,

I tried \tau=\mu*\frac{du}{dy} and your code to get some wall shear stress plots.

In published paper, they normally define wall shear stress as the way you did.

After some comparison, I found that my wall shear stress is quite low than what they did on paper. There are still more than 20% difference between my plots and their plots after I multiple a factor to my plots.

Have you got any experience with these kind of problem? I am stuck with it for quite a while.

From the other method:\tau=\mu*\frac{du}{dy}The plots are totally different. Do you have any idea with this?

Any idea would be appreciated:)

Thanks

lintao September 23, 2011 09:07

thx u very much. it helps a lot.

Amir September 23, 2011 09:15

Quote:

Originally Posted by liguifan (Post 325343)
Dear Amir,

I tried \tau=\mu*\frac{du}{dy} and your code to get some wall shear stress plots.

In published paper, they normally define wall shear stress as the way you did.

After some comparison, I found that my wall shear stress is quite low than what they did on paper. There are still more than 20% difference between my plots and their plots after I multiple a factor to my plots.

Have you got any experience with these kind of problem? I am stuck with it for quite a while.

From the other method:\tau=\mu*\frac{du}{dy}The plots are totally different. Do you have any idea with this?

Any idea would be appreciated:)

Thanks

Dear Guifan,

First of all, note that this relation for shear stress we discussed about is valid just for incompressible flow; for compressible cases, another term should be added.
As you know, in many papers, wall traction is reported instead of wall shear stress, so I suggest you check OpenFOAM utility without changes and see what will happen.
Ensure you have reached grid independence solution by examining wall shear stress of boundaries.
Another suggestion; there is another utility for evaluating velocity gradient @ boundaries (wallGradU), obviously it can compute grad(U) more precisely which you can also use that in your code.
Also try high order schemes for gradient and others.

Bests,

itsme_kit February 13, 2012 09:26

Quote:

Originally Posted by liguifan (Post 324337)
My geometry is a bifurcation and on of the vessel is bent. I want to measure the wall shear stress along the bent vessel. The wall shear stress is already calculated. I only find a way to measure the wall shear stress along the straight pipe but no idea how to do it in bent pipe.

Any hind would be helpful.

Cheers!

Hi
Can you tell me how to measure the wall shear stress?
I'm confused why my wall shear stress is zero and only a tiny part in inlet is non-zero
I am modelling a 3D laminar straight pipe flow by using star ccm

liguifan February 13, 2012 19:02

Can you post your bifurcation geometry as well as how you measure the WSS?



Quote:

Originally Posted by itsme_kit (Post 344142)
Hi
Can you tell me how to measure the wall shear stress?
I'm confused why my wall shear stress is zero and only a tiny part in inlet is non-zero
I am modelling a 3D laminar straight pipe flow by using star ccm


itsme_kit February 14, 2012 10:24

5 Attachment(s)
Quote:

Originally Posted by liguifan (Post 344238)
Can you post your bifurcation geometry as well as how you measure the WSS?

I uploaded some plots and you can have a look
I'm not sure how to measure WSS
I just created a scalar plot and then selected wall in parts and WSS in function

Appreciate any useful suggestion

Thanks

liguifan February 14, 2012 18:50

I think there is tool under filter is plot over intersection curve.
1) In property inspection field, choose the wall object (whoever the name you named it).
2) Use "Clip" to get rid of the part you do not want to measure.
3) Use "Plot over intersection curve" to plot the wall shear stress over the line which is the intersection of a plane and the wall.




Quote:

Originally Posted by itsme_kit (Post 344376)
I uploaded some plots and you can have a look
I'm not sure how to measure WSS
I just created a scalar plot and then selected wall in parts and WSS in function

Appreciate any useful suggestion

Thanks


TianC August 13, 2012 09:11

Hi guys,

Is there any way that you can output the wall shear stress at every calculated time step (to use this as a measure of convergence to a steady state)? I would like to incorporate it into the solver but not quite sure what the script would look like. Any help would be greatly appreciated.

Cheers,

Tian

Amir August 13, 2012 09:17

Hi,

Try this:
solve->monitor->surface .... wall fluxes (wall shear stress)

Bests,

TianC August 13, 2012 13:42

Quote:

Originally Posted by Amir (Post 376809)
Hi,

Try this:
solve->monitor->surface .... wall fluxes (wall shear stress)

Bests,

Sorry, where does this go? In the solver.C file? (I have made a new solver called mypisoFoam) I have been trying to incorporate an average wall shear stress calculator over the top surface of my simulation. I have added this to mypisoFoam.C:

// Print out average wall shear stress over topSurface
// // find the identification number (e.g. label) for our boundary of interest.
label topSurfacePatch = mesh.boundaryMesh().findPatchID("topSurface");
// if we don't have such a patch, warn the user
//
if (topSurfacePatch==-1)
{
Info << "Failure to find patch named topSurface for average wall shear stress calc."
<< endl;
}
else // calculate the result and do output
{
// the sum operator implicity loops over the boundary faces and stores the result in avgWSS

scalar avgWSS = 0.0;
avgWSS = sum(wallShearStress.boundaryField()[topSurfacePatch]);
reduce(avgWSS,sumOp<scalar>());
Info << "Monitor: at Time = " << runTime.timeName() << " -- Average wall shear stress over top surface= " << avgWSS <<" [kg/(m*s^2)] " ;
}

When compiling with wmake, the following message appears:

Making dependency list for source file mypisoFoam1.C
SOURCE=mypisoFoam1.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-100 -I/hpcwarwick/openfoam/2.1.0/OpenFOAM-2.1.0/src/turbulenceModels/incompressible/turbulenceModel -I/hpcwarwick/openfoam/2.1.0/OpenFOAM-2.1.0/src/transportModels -I/hpcwarwick/openfoam/2.1.0/OpenFOAM-2.1.0/src/transportModels/incompressible/singlePhaseTransportModel -I/hpcwarwick/openfoam/2.1.0/OpenFOAM-2.1.0/src/finiteVolume/lnInclude -IlnInclude -I. -I/hpcwarwick/openfoam/2.1.0/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude -I/hpcwarwick/openfoam/2.1.0/OpenFOAM-2.1.0/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/mypisoFoam1.o
mypisoFoam1.C: In function ‘int main(int, char**)’:
mypisoFoam1.C:175: error: ‘wallShearStress’ was not declared in this scope
/hpcwarwick/openfoam/2.1.0/OpenFOAM-2.1.0/src/finiteVolume/lnInclude/readPISOControls.H:3: warning: unused variable ‘nOuterCorr’
/hpcwarwick/openfoam/2.1.0/OpenFOAM-2.1.0/src/finiteVolume/lnInclude/readPISOControls.H:15: warning: unused variable ‘transonic’
make: *** [Make/linux64GccDPOpt/mypisoFoam1.o] Error 1

The problem appears to be that it can't find wallShearStress as a variable. How do I make it calculate/read this?

Cheers

Tian

Amir August 13, 2012 14:37

1 Attachment(s)
Oh, sorry about previous post, that was a forum conflict! :o
But in openFoam it seems that the original utility compute wall traction instead of wall shear stress and I posted the revised form you can easily embed it in your solver and assess its changing. (note that it's a revised utility now which can be used in this form as a utility or you can put in your desired code with few manipulation)
see the attachment ...
(the error of your code is that you haven't defined wall shear stress yet)

TianC August 13, 2012 18:04

Thanks a lot for your reply Amir. Does the old wallShearStress function not actually give wall shear stress then? In your utility it requires a tau file in the 0 directory and therefore gives the resulting error message:

--> FOAM FATAL IO ERROR:
cannot find file

file: /gpfs/home/eng/mauiie/OpenFOAM/mauiie-2.1.0/run/project/cavity2D/solverTest/0/tau at line 0.

From function regIOobject::readStream()
in file db/regIOobject/regIOobjectRead.C at line 73.

FOAM exiting

Is this a file used by the RAS solvers? It appears that this utility is designed for RAS not LES. With the old utility it was possible to make some alterations to the script (mainly changing RAS to LES wherever it occurred) and the utility would just as well with an LES case. Is this possible also with this solver?

Also, how would you embed the function into the solver? Would you simply copy and paste it in? Or would you do something more a long the lines I started with?

Sorry for all the questions, I am a bit new to OpenFOAM. Please bear with me :)

Amir August 14, 2012 06:26

1 Attachment(s)
Quote:

Originally Posted by TianC (Post 376910)
Does the old wallShearStress function not actually give wall shear stress then?

No, as I said it leads to wall traction instead of wall shear stress. (you can easily check the formulation)
Quote:

Originally Posted by TianC (Post 376910)
In your utility it requires a tau file in the 0 directory and therefore gives the resulting error message:

--> FOAM FATAL IO ERROR:
cannot find file

file: /gpfs/home/eng/mauiie/OpenFOAM/mauiie-2.1.0/run/project/cavity2D/solverTest/0/tau at line 0.

From function regIOobject::readStream()
in file db/regIOobject/regIOobjectRead.C at line 73.

FOAM exiting

Of course it is! the tau parameter depends on your model. (actually I prepared it for viscoelastic solver where the tau parameter exists but for general cases you have to set its formulation in your code)
Quote:

Originally Posted by TianC (Post 376910)
Is this a file used by the RAS solvers? It appears that this utility is designed for RAS not LES. With the old utility it was possible to make some alterations to the script (mainly changing RAS to LES wherever it occurred) and the utility would just as well with an LES case. Is this possible also with this solver?

It's the general from and you can set it for any solver appropriately.
Quote:

Originally Posted by TianC (Post 376910)
Also, how would you embed the function into the solver? Would you simply copy and paste it in? Or would you do something more a long the lines I started with?

Sure, I did it for a simple code which uses moving reference frame; but note that according to the code, there must be initializing files additional to the current one in 0 folder where you can change them according to your purpose from IOobject control .... (see the attachment) it's just a template; you can change the IOobject.

TianC August 15, 2012 07:23

Thank you again for your help so far.

I've managed to incorporate the wall shear stress into my solver now (after some modifications to createFields.H).

Ideally what I want is to output an average of wall shear stress over the top surface of my simulation into a log file (for every deltaT). I have put this script in at the end of my script:

// Print out average wall shear stress over topSurface
// // find the identification number (e.g. label) for our boundary of interest.
label topSurfacePatch = mesh.boundaryMesh().findPatchID("topSurface");
// if we don't have such a patch, warn the user
//

if (topSurfacePatch==-1)
{
Info << "Failure to find patch named topSurface for average wall shear stress calc."
<< endl;
}
else // calculate the result and do output
{
// the sum operator implicity loops over the boundary faces and stores the result in avgWSS

scalar avgWSS = 0.0;
avgWSS = sum(mag(shear.boundaryField()[topSurfacePatch]));
reduce(avgWSS,sumOp<scalar>());
Info << "Monitor: at Time = " << runTime.timeName() << " -- Average wall shear stress over top surface= " << avgWSS <<" [kg/(m*s^2)] " ;
}

It is now outputting the sum of over all of that patch. The only thing I need to know is how to say divide by the total number of points on that face??(this is because I need the average not the sum)

Cheers

Tian

TianC August 15, 2012 07:31

Also, the script that gives a line break would be very useful :)

Amir August 15, 2012 08:55

Quote:

Originally Posted by TianC (Post 377182)
It is now outputting the sum of over all of that patch. The only thing I need to know is how to say divide by the total number of points on that face??(this is because I need the average not the sum)

Have you taken a look over patchAverage utility? (postProcessing->patch->patchAverage)
As you can see; you'll need to compute patch area there (not the numbers!):

scalar area = gSum(mesh.magSf().boundaryField()[patchI]);

Quote:

Originally Posted by TianC (Post 377183)
Also, the script that gives a line break would be very useful :)

use endl (see the above utility (patchAverage))

Bests,

TianC August 15, 2012 09:53

Quote:

Originally Posted by Amir (Post 377214)
Have you taken a look over patchAverage utility? (postProcessing->patch->patchAverage)
As you can see; you'll need to compute patch area there (not the numbers!):

scalar area = gSum(mesh.magSf().boundaryField()[patchI]);

Thank you again Amir, your help is greatly appreciated.

Why should it be over the patch area rather than the number of points on that patch? Since the shear utility outputs a vector at every point on the patch, surely the more points you have (i.e. a finer resolution of mesh) the greater the sum of these vectors will be. So it is by dividing by the number of points that you would achieve the average.

Cheers,

Tian

Amir August 15, 2012 10:47

Quote:

Originally Posted by TianC (Post 377228)
Why should it be over the patch area rather than the number of points on that patch? Since the shear utility outputs a vector at every point on the patch, surely the more points you have (i.e. a finer resolution of mesh) the greater the sum of these vectors will be. So it is by dividing by the number of points that you would achieve the average.

The resolution is not the concern but the mesh grading is. If you have equal-size faces, you'll achieve the same result. But generally, your formulation doesn't lead to the average value physically because it doesn't contribute the weighting! these are the formulations:
- your formulation: (1/N)*sum(shear)
- The correct formulation: (1/area)*sum(shear*area)

Bests,

TianC August 15, 2012 11:25

Ah, I see... I did not realise the calculated values were weighted by the size of the cells!

Looking over the script I have an understanding of all aspects except, why do you write this:
volTensorField T=mu*(gradU+gradU.T());

T you say is the stress tensor which is the Jacobian of the velocity (i.e. gradU) and I assume you multiply by mu because it's as good a stage as any to do so. However, why the "+gradU.T()"?

Cheers

Tian

Amir August 15, 2012 14:43

Quote:

Originally Posted by TianC (Post 377242)
T you say is the stress tensor which is the Jacobian of the velocity (i.e. gradU) and I assume you multiply by mu because it's as good a stage as any to do so. However, why the "+gradU.T()"?
Tian

Because it's the constitutive equation! Take a look over basic fluid mechanic equation in a continuum media.
(T=2*mu*D) for incompressible flow
D : symmetric part of grad(U)

Bests,

TianC August 26, 2012 05:02

Hi again!

I seem to be getting far too high values out for wall shear stress. I have implemented a monitor in my solver, so that it outputs average wall shear stress over the top surface of my simulation. The code looks as follows:

volTensorField gradU=fvc::grad(U);
volTensorField T=mu*(gradU+gradU.T());
volVectorField nn
(
IOobject
(
"nn",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
vector::zero
);
forAll(nn.boundaryField(), patchI)
{
nn.boundaryField()[patchI] =
(
-mesh.Sf().boundaryField()[patchI]
/mesh.magSf().boundaryField()[patchI]
);
}

forAll(wallShearStress.boundaryField(), patchI)
{
wallShearStress.boundaryField()[patchI] =
nn.boundaryField()[patchI] & T.boundaryField()[patchI];
}

forAll(normal.boundaryField(), patchI)
{
normal.boundaryField()[patchI] =
(nn.boundaryField()[patchI] & wallShearStress.boundaryField()[patchI])
*nn.boundaryField()[patchI];
}

forAll(shear.boundaryField(), patchI)
{
shear.boundaryField()[patchI] =
wallShearStress.boundaryField()[patchI]-normal.boundaryField()[patchI];
}

// Print out average wall shear stress over topSurface
// find the identification number (e.g. label) for our boundary of interest.
label topSurfacePatch = mesh.boundaryMesh().findPatchID("topSurface");
// if we don't have such a patch, warn the user


if (topSurfacePatch==-1)
{
Info << "Failure to find patch named topSurface for average wall shear stress calc."
<< endl;
}
else // calculate the result and do output
{
// the sum operator implicity loops over the boundary faces and stores the result in avgWSS

scalar area = gSum(mesh.magSf().boundaryField()[topSurfacePatch]);
scalar avgWSS = gSum(mag(shear.boundaryField()[topSurfacePatch]))/area;
// reduce(avgWSS,sumOp<scalar>());
Info << "Monitor: at Time = " << runTime.timeName() << " -- Average wall shear stress over top surface= " << avgWSS <<" [kg/(m*s^2)] " << "Area = " << area << " [m^2] ";
}

The values I am getting out are far too high for my simulation, for example average wall shear stress of 40 where mean velocity is magnitude 1. I have searched through the code trying to work out where the issue is occurring. Do you have any suggestions please?

Cheers,

Tian

ngj August 26, 2012 05:21

Hi Tian,

I think (am certain) that the error is in the following line:

Code:

scalar avgWSS = gSum(mag(shear.boundaryField()[topSurfacePatch]))/area;
where, if you want a area weighted average, you should do

Code:

scalar avgWSS = gSum(mag(shear.boundaryField()[topSurfacePatch]) * mesh.magSf().boundaryField()[topSurfacePatch])/area;
Kind regards,

Niels

TianC August 26, 2012 05:40

Ahhh... That is so much better.

Thank you Niels :) you're a life saver!

Tian

ngj August 26, 2012 05:47

No problem.

BTW: In stead of making the stress tensor yourself, you could benefit from the turbulence model by calling devReff(). The only thing to remember is that this tensor is also non-tangential with the wall, so you have to perform the same projection (as you already do) onto the boundary face.

The upside of using the turbulence model is that you do not have to implement turbulence model specific shear stress methods, because the turbulence model itself tells, how the shear stress is defined.

/ Niels


All times are GMT -4. The time now is 16:05.