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] Power law inlet velocity using groovyBC (https://www.cfd-online.com/Forums/openfoam-community-contributions/126238-power-law-inlet-velocity-using-groovybc.html)

aviator November 11, 2013 22:34

Power law inlet velocity using groovyBC
 
Hi all,

I am using OpenFOAM 2.2.1 and have installed swak4Foam 0.2.4

I need to use a power law as an inlet velocity, and the outlet wind profile is set same as the inlet wind profile.

This is my 0/U
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.2.1                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField  uniform (6.751 0 0);

boundaryField
{
    upper
    {
        type            fixedValue;
        value          uniform (6.751 0 0);
    }

    front
    {
      type    groovyBC;
      value  uniform (0 0 0);
      variables (
    "Umet=6.751;"
    "height=pos().y;"
    "quo=height/60;"
      );
     
      valueExpression
            "-Umet*pow(quo,0.2)*normal()";
    }
    back
    {
      type    groovyBC;
      value  uniform (0 0 0);
      variables (
    "Umet=6.751;"
    "height=pos().y;"
    "quo=height/60;"
      );

      valueExpression
            "-Umet*pow(quo,0.2)*normal()";
    }

    square
    {
        type            fixedValue;
        value          uniform (0 0 0);
    }

    floor
    {
        type            fixedValue;
        value          uniform (0 0 0);
    }


    right
    {
        type            symmetryPlane;
    }
    left
    {
        type            symmetryPlane;
    }
}

// ************************************************************************* //

But I got the following error.

Code:

swak4Foam: Allocating new repository for sampledGlobalVariables
#0  Foam::error::printStack(Foam::Ostream&) in "/opt/openfoam221/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1  Foam::sigFpe::sigHandler(int) in "/opt/openfoam221/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2  in "/lib/x86_64-linux-gnu/libc.so.6"
#3  in "/lib/x86_64-linux-gnu/libm.so.6"
#4  Foam::pow(Foam::Field<double>&, Foam::UList<double> const&, Foam::UList<double> const&) in "/opt/openfoam221/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#5  Foam::pow(Foam::UList<double> const&, Foam::UList<double> const&) in "/opt/openfoam221/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#6  parserPatch::PatchValueExpressionParser::parse() in "/home/openfoam/OpenFOAM/openfoam-2.2.1/platforms/linux64GccDPOpt/lib/libswak4FoamParsers.so"
#7  Foam::PatchValueExpressionDriver::parseInternal(int) in "/home/openfoam/OpenFOAM/openfoam-2.2.1/platforms/linux64GccDPOpt/lib/libswak4FoamParsers.so"
#8  Foam::CommonValueExpressionDriver::parse(std::string const&, Foam::word const&) in "/home/openfoam/OpenFOAM/openfoam-2.2.1/platforms/linux64GccDPOpt/lib/libswak4FoamParsers.so"
#9  Foam::groovyBCFvPatchField<Foam::Vector<double> >::updateCoeffs() in "/home/openfoam/OpenFOAM/openfoam-2.2.1/platforms/linux64GccDPOpt/lib/libgroovyBC.so"
#10  at gaussLaplacianSchemes.C:0
#11  Foam::fv::gaussLaplacianScheme<Foam::Vector<double>, double>::fvmLaplacianUncorrected(Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) in "/opt/openfoam221/platforms/linux64GccDPOpt/lib/libfiniteVolume.so"
#12  Foam::fv::gaussLaplacianScheme<Foam::Vector<double>, double>::fvmLaplacian(Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) in "/opt/openfoam221/platforms/linux64GccDPOpt/lib/libfiniteVolume.so"
#13  Foam::fv::laplacianScheme<Foam::Vector<double>, double>::fvmLaplacian(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) in "/opt/openfoam221/platforms/linux64GccDPOpt/lib/libfiniteVolume.so"
#14  Foam::tmp<Foam::fvMatrix<Foam::Vector<double> > > Foam::fvm::laplacian<Foam::Vector<double>, double>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) in "/opt/openfoam221/platforms/linux64GccDPOpt/lib/libincompressibleTurbulenceModel.so"
#15  Foam::incompressible::RASModels::kOmegaSST::divDevReff(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>&) const in "/opt/openfoam221/platforms/linux64GccDPOpt/lib/libincompressibleRASModels.so"
#16 
 in "/opt/openfoam221/platforms/linux64GccDPOpt/bin/pisoFoam"
#17  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#18 
 in "/opt/openfoam221/platforms/linux64GccDPOpt/bin/pisoFoam"
Floating point exception (core dumped)

Can someone please clarify this. I am fairly new to OpenFOAM and would appreciate your help. Thank you.

duongquaphim November 12, 2013 09:53

First, do you have negative coordinate in y direction eg. pos().y < 0? If not, then try Foam::pow instead of pow only.

aviator November 12, 2013 21:02

Thank you for pointing that out.

After reading your comment, I think that I made a mistake. I should've use the z-coordinate, which is the height, since the inlet velocity varies at different height. My z-coordinate is always positive. Then I changed the code into something like this.

Code:

    front
    {
      type    groovyBC;
      value  uniform (0 0 0);
      variables "Umet=6.751;height=pos().z;";
      valueExpression "Umet*pow((height/60),0.2)*normal()";
           
    }

And it's running.

I did this assuming that pos().z would give me a vector of z-coordinate though. And by assuming that multiplying the equation with normal() would give me the velocity in the x-direction. Please let me know if this is not correct.

Thank you.

duongquaphim November 13, 2013 10:50

I think that's correct assuming your normal() is (1,0,0). What you can do to check is to visualize the velocity profile at the inlet at the next saved time step in paraview.

Cheers.


All times are GMT -4. The time now is 08:03.