CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

localBlended

Register Blogs Community New Posts Updated Threads Search

Like Tree10Likes
  • 9 Post By bjnieuwboer
  • 1 Post By bjnieuwboer

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 10, 2012, 11:04
Default localBlended
  #1
Senior Member
 
Julien
Join Date: Jun 2012
Location: France
Posts: 152
Rep Power: 13
Djub is on a distinguished road
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 is offline   Reply With Quote

Old   August 21, 2012, 11:19
Unhappy
  #2
Senior Member
 
Julien
Join Date: Jun 2012
Location: France
Posts: 152
Rep Power: 13
Djub is on a distinguished road

sniff...
Nobody to help me...
Djub is offline   Reply With Quote

Old   April 30, 2015, 10:03
Default Piece of code for using the localBlend scheme
  #3
Member
 
Bas Nieuwboer
Join Date: Mar 2013
Posts: 32
Rep Power: 13
bjnieuwboer is on a distinguished road
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
syavash, Pagoda, Maff and 6 others like this.
bjnieuwboer is offline   Reply With Quote

Old   February 1, 2017, 13:09
Default
  #4
New Member
 
vsammartano's Avatar
 
Vincenzo
Join Date: Oct 2012
Location: Varese (IT)
Posts: 15
Rep Power: 13
vsammartano is on a distinguished road
Send a message via Skype™ to vsammartano
Quote:
Originally Posted by bjnieuwboer View Post
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
Hi Bas,
first of all thank you so much for your "mini" tutorial about the generation of a "damping" zone using a velocity blending factor. I have a question about the procedure u showed in this post: you have created the blending factors using the funkySetFieldsDict, but this is only an initialization of this factors or these parameters maintain the values you took during the simulation?
Thank you for your time.
Regars, Vincenzo
vsammartano is offline   Reply With Quote

Old   February 2, 2017, 04:24
Default
  #5
Member
 
Bas Nieuwboer
Join Date: Mar 2013
Posts: 32
Rep Power: 13
bjnieuwboer is on a distinguished road
Hi Vincenzo,

I indeed created the blendfactors at the start of my simulation and they are not adjusted during the simulation time. For example for U I created the UBlend using funkysetFields. In the solver this field is interpolated to the surfaceScalarField UBlendingfactor. This is automatically used by the localBlended scheme.

Regards,

Bas
bjnieuwboer is offline   Reply With Quote

Old   February 2, 2017, 04:32
Default
  #6
New Member
 
vsammartano's Avatar
 
Vincenzo
Join Date: Oct 2012
Location: Varese (IT)
Posts: 15
Rep Power: 13
vsammartano is on a distinguished road
Send a message via Skype™ to vsammartano
Hi Bas...so the blending factor works only when one start the funkySetField application? in this way we have not a permanent damping region... am i wrong?
thank you again
Vincenzo
vsammartano is offline   Reply With Quote

Old   February 2, 2017, 05:34
Default
  #7
Member
 
Bas Nieuwboer
Join Date: Mar 2013
Posts: 32
Rep Power: 13
bjnieuwboer is on a distinguished road
The blendingfactor works during the whole simulation. So you have a permanent damping region.

I've used the funkysetfields for creating the blend factors, because it was the easiest way to create a field for me.
vsammartano likes this.
bjnieuwboer is offline   Reply With Quote

Old   February 2, 2017, 05:50
Default
  #8
New Member
 
vsammartano's Avatar
 
Vincenzo
Join Date: Oct 2012
Location: Varese (IT)
Posts: 15
Rep Power: 13
vsammartano is on a distinguished road
Send a message via Skype™ to vsammartano
This is a really good news!! Thank you so much Bas!
Best Regards
Vincenzo
vsammartano is offline   Reply With Quote

Reply

Tags
localblended ; les


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
non-constant blending function sven82 OpenFOAM 2 December 12, 2009 06:34
Using the localBlended scheme for DES philippebv OpenFOAM 1 November 18, 2009 13:38
localBlended braennstroem OpenFOAM Running, Solving & CFD 0 July 28, 2009 02:50


All times are GMT -4. The time now is 17:37.