CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   localBlended (http://www.cfd-online.com/Forums/openfoam-programming-development/105843-localblended.html)

Djub August 10, 2012 11:04

localBlended
 
Hi !
I would appreciate some info about the use of localBlended.

I know the post Using the localBlended scheme for DES (GO HERE)
and the post Sponge layer for outflow BC (GO THERE)
but I feel to week to manage alone.

I tried grep localBlended . -R from the tutorial folder, with no success...

Some help from anybody?

I want to run a LES calculation, and I'd like to prevent the vortices (created in a turbulent wake) to "explode" when reaching the outlet. Do you have another solution than
1/ have a very long domain
and
2/ use localBlended scheme (with a dissipative linear upwind scheme for U convection)
?

Thanks in advance,

Julien

Djub August 21, 2012 11:19

:(
sniff...
Nobody to help me...
:(

bjnieuwboer April 30, 2015 10:03

Piece of code for using the localBlend scheme
 
Hi Julian,

I know this response is way too late for you. I hope you solved your problem. However, I had a similar problem and I saw your post without an answer. This is how I solved it. In the first 3 steps you have to edit your solver. The next steps are to create the fields itself and use the localBlended scheme

1) Go to your solver and find the file "createFields.H". This reads all the fields from your 0 folder in your simulation.

2) Attach the following piece of code to the "createFields.H" or include it from another H-file. This script reads the blendingfactors for U,k and/or epsilon. The volScalarFields to be read are called UBlend, kBlend and/or epsilon. The script then interpolates these fields to surfaceScalarFields UBlendingFactor, kBlendingFactor and/or epsilonBlendingFactor. A IOobjects called UBlendingFactor is automatically used when the scheme localBlended is used.

Code:

//BJN 2015-04-30 extra file to read the volScalarFields for the blendingfactor used for localBlended scheme. For each variable that uses the localBlended scheme, there should be a volScalarField with the blendfactor. This volScalarField can be created by for instance the funkysetfields utility of swak4foam. In this file the volumeScalarFields are interpolated to surfaceScalarFields that are needed for the localBlended scheme.

/*Usage

    div(phi,U)      Gauss localBlended linear upwind; // When blendingfactor is 1 use the first scheme. When blendingfactor is 0 use the second.

*/
//Info<< "Reading field UBlend\n" << endl;
volScalarField UBlend
(
    IOobject
    (
        "UBlend",
        runTime.timeName(),
        mesh,
        IOobject::READ_IF_PRESENT,
        IOobject::NO_WRITE
    ),
    mesh,
    dimensionedScalar("zero", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0)
);

//Info<< "Transforming field UBlend to surfaceScalarField named: UBlendingFactor\n" << endl;
surfaceScalarField UBlendingFactor
(
    IOobject
    (
        "UBlendingFactor",
        runTime.timeName(),
        mesh,
        IOobject::READ_IF_PRESENT,
        IOobject::NO_WRITE
    ),
fvc::interpolate(UBlend)  // The interpolation. Please note: for the localBlended scheme to work on 'U' the variable UBlendingFactor should be present. It should be an IOobject and it should be a surfaceScalarField
);

//Info<< "Reading field kBlend\n" << endl;
volScalarField kBlend
(
    IOobject
    (
        "kBlend",
        runTime.timeName(),
        mesh,
        IOobject::READ_IF_PRESENT,
        IOobject::NO_WRITE
    ),
    mesh,
    dimensionedScalar("zero", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0)
);

//Info<< "Transforming field kBlend to surfaceScalarField named: kBlendingFactor\n" << endl;
surfaceScalarField kBlendingFactor
(
    IOobject
    (
        "kBlendingFactor",
        runTime.timeName(),
        mesh,
        IOobject::READ_IF_PRESENT,
        IOobject::NO_WRITE
    ),
fvc::interpolate(kBlend)
);

//Info<< "Reading field epsilonBlend\n" << endl;
volScalarField epsilonBlend
(
    IOobject
    (
        "epsilonBlend",
        runTime.timeName(),
        mesh,
        IOobject::READ_IF_PRESENT,
        IOobject::NO_WRITE
    ),
    mesh,
    dimensionedScalar("zero", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0)
);

//Info<< "Transforming field epsilonBlend to surfaceScalarField named: epsilonBlendingFactor\n" << endl;
surfaceScalarField epsilonBlendingFactor
(
    IOobject
    (
        "epsilonBlendingFactor",
        runTime.timeName(),
        mesh,
        IOobject::READ_IF_PRESENT,
        IOobject::NO_WRITE
    ),
fvc::interpolate(epsilonBlend)
);

3) Compile your new solver. Please follow instruction how to make a new solver elsewhere on this forum.

4) Change your div scheme in the fvSchemes. A value of 1 represents the linear discretisation. A value of 0 the upwind.
Code:

divSchemes
{
    default          none;
    div(phi,U)      Gauss localBlended linear upwind;
    div(phi,k)      Gauss localBlended linear upwind;
    div(phi,epsilon) Gauss localBlended linear upwind;
    div((nuEff*dev(T(grad(U))))) Gauss linear;
}

5) You still have to create the fields for the blendingfactor UBlend*. I have done this using the utility swak4foam. When installed you can create your own fields.
*note, this is the volScalarField you have to specify. UBlendingFactor is the computed surfaceScalarField that is automatically used by the localBlended scheme

6) Make a input file for the swak4foam utility called funkySetFields. The input file is called: "funkySetFieldsDict". This code shows how to create the three fields.

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.3.x                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2;
    format      ascii;
    class      dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

expressions
 (
    U_outer
    {
    field UBlend; //field to initialise
    create true;
    expression "0.7";
    condition "pow(pos().x,2) + pow(pos().y,2) >= pow(1,2)";
        keepPatches 0;
    }
    U_inner
    {
    field UBlend; //field to initialise
    expression "0.8";
    condition "pow(pos().x,2) + pow(pos().y,2) < pow(1,2)";
        keepPatches 0;
    }
    U_top
    {
    field UBlend; //field to initialise
    variables "BlendTop=0;BlendBottom=0.8;ZTop=1.4;ZBottom=0;R_i=0.26;Z0=0.7;";
    expression "BlendBottom+(BlendTop-BlendBottom)/(ZTop-ZBottom)*pos().z";
    keepPatches 0;
    condition "pow(pos().x,2) + pow(pos().y,2) < pow(R_i,2) && pos().z >= 0";
    }

    k
    {
    field kBlend; //field to initialise
    create true;
    expression "1.0 * UBlend";
        keepPatches 0;
    }
    epsilon
    {
    field epsilonBlend; //field to initialise
    create true;
    expression "1.0 * UBlend";
        keepPatches 0;
    }

7) Run the funkySetFields utility with the command "funkySetFields -latestTime"

8) Run your model with your new solver


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