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 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 03:46.