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] Inlet velocity profile for turbulent pipe flow using swak4Foam (https://www.cfd-online.com/Forums/openfoam-community-contributions/131828-inlet-velocity-profile-turbulent-pipe-flow-using-swak4foam.html)

zordiack March 21, 2014 08:47

Inlet velocity profile for turbulent pipe flow using swak4Foam
 
Hi, I wanted a fully developed inlet velocity profile for my 3D-case and I decided to implement it using swak4Foam since I couldn't figure out how to do it with native OpenFOAM tools. So, I thought I'd share my solution here since it took me a while to figure it out.

Please note that in my case the inlet pipe centerline run along the y-axis, but it should by easy enough to modify for other cases too. Turbulent velocity profile is calculated using the power law formulation.

Code:

        pipe_inlet
        {
              type groovyBC;
              value uniform (0 0 0);
              variables (
                "n=7;"  //power law coefficient n
                "d=0.125;"  //pipe diameter
                "volFlowRate=0.1;"  //volumetric flow rate
                "Umean=volFlowRate/(pi*pow((d/2),2));"  //calculate mean velocity
                "Umax=Umean*(((n+1)*(2*n+1))/(2*pow(n,2)));"  //calculate max velocity
                "profile=Umax*pow(1-sqrt(pow(pos().x,2)+pow(pos().z,2))/(d/2),(1/n));"
                //calcucate power law velocity profile Umax*(1-r/R)^(1/n)
                );
              valueExpression "normal()*-profile";
              //apply to boundary, normal() is surface normal vector and minus is needed for inflow
        }

I hope someone finds this useful :)

PS: swak4Foam development version compiles for OpenFOAM-2.3.x and at least groovyBC is working fine

rohitpurdue April 6, 2014 23:08

Hi Zor,

Do we have to make any other change in any other folder or the code which you have given is good enough to implement the fully-developed boundary condition?

Thanks,

Rohit:)

zordiack April 7, 2014 03:18

You need to install swak4Foam according to instructions.

Files that need to be mofidied are 0/U and system/controlDict (add swak4Foam libs, which is shown in the installation instructions).

student666 October 1, 2015 16:27

Hi,

hope someone helps me as this thread is quite old...

Anyway, I set the inlet profile for my pipe simulation according to the upper BC for inlet.

When I set the power law coefficient as 1/n<1, simpleFoam crashes (floating point exception).
For values 1/n>= 1, simpleFoam works fine, but my inlet profile isn't real.

this is my error:
Code:

Time = 1

#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigFpe::sigHandler(int) at ??:?
#2  in "/lib/x86_64-linux-gnu/libc.so.6"
#3  in "/lib/x86_64-linux-gnu/libm.so.6"
#4  pow in "/lib/x86_64-linux-gnu/libm.so.6"
#5  Foam::pow(Foam::Field<double>&, Foam::UList<double> const&, Foam::UList<double> const&) at ??:?
#6  Foam::pow(Foam::UList<double> const&, Foam::UList<double> const&) at ??:?
#7  parserPatch::PatchValueExpressionParser::parse() at ??:?
#8  Foam::PatchValueExpressionDriver::parseInternal(int) at ??:?
#9  Foam::CommonValueExpressionDriver::parse(Foam::exprString const&, Foam::word const&) at ??:?
#10  Foam::CommonValueExpressionDriver::evaluateVariable(Foam::word const&, Foam::exprString const&) at ??:?
#11  Foam::CommonValueExpressionDriver::addVariables(Foam::exprString const&, bool) at ??:?
#12  Foam::CommonValueExpressionDriver::addVariables(Foam::List<Foam::exprString> const&, bool) at ??:?
#13  Foam::CommonValueExpressionDriver::clearVariables() at ??:?
#14  Foam::groovyBCFvPatchField<Foam::Vector<double> >::updateCoeffs() at ??:?
#15  Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField::updateCoeffs() at ??:?
#16  Foam::fvMatrix<Foam::Vector<double> >::fvMatrix(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::dimensionSet const&) at ??:?
#17 
 at ??:?
#18 
 at ??:?
#19  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#20 
 at ??:?
Floating point exception (core dumped)

can't really uderstand why I have this error, can someone help me please?

this is my check Mesh -allGeometry -allTopolgy log
Code:

............
 ***Cells with small determinant (< 0.001) found, number of cells: 100
  <<Writing 100 under-determined cells to set underdeterminedCells
    ..............
Failed 1 mesh checks.

End

are those 100 cells giving me the error?

Thank you very much.

Mitchell Baum February 21, 2016 22:52

Hi student666,

I have just encountered the same error. Have you made any progress on this since your last post?

Regards,
Mitch

student666 February 23, 2016 01:52

Quote:

Originally Posted by Mitchell Baum (Post 586205)
Hi student666,

I have just encountered the same error. Have you made any progress on this since your last post?

Regards,
Mitch

My issue was related to a very small cell size. I solevd it by meshing with dimension of the cells bigger. hope it can helps you. Cheers


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