CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Shear-Rate calculation (https://www.cfd-online.com/Forums/openfoam-post-processing/242430-shear-rate-calculation.html)

giano April 21, 2022 07:53

Shear-Rate calculation
 
Hi everyone, I am trying to calculate the Shear rate, defined as the square root of the double dot product of the strain-rate tensor with itself. In order to do so I added the following lines of code to the createFields.H of the solver I am currently using:


Code:


Info<< "Reading field strainRate\n" << endl;
volScalarField strainRate
(
    IOobject
    (
        "strainRate",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::AUTO_WRITE
    ),
    1.41421356237*mag(symm(fvc::grad(U)))
);


The solver can be compiled and it run correctly, but the results of the new function are pratically 0 eveyrwhere. If I explore the folders corresponding to the time steps, what I found in the file is:


Code:

/*--------------------------------*- C++ -*----------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    | Website:  https://openfoam.org
    \\  /    A nd          | Version:  7
    \\/    M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      binary;
    class      volScalarField;
    location    "0.1";
    object      strainRate;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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

internalField  uniform 0;

boundaryField
{
    leftWall
    {
        type            calculated;
        value          uniform 0;
    }
    rightWall
    {
        type            calculated;
        value          uniform 0;
    }
    lowerWall
    {
        type            calculated;
        value          uniform 0;
    }
    atmosphere
    {
        type            calculated;
        value          uniform 0;
    }
    defaultFaces
    {
        type            empty;
    }
}


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


So it basically performs the computation on the initial velocity field (U=0 everywhere).
Can someone help me?


Thanks in advance.

missios May 3, 2022 13:10

Hi Giano,



createFields is executed once as a result the strainRate is calculated once based on the initial U which is zero everywhere. In the next timesteps you dont recalculate strainRate and thus it remains zero for the rest of your simulation.



If I have to suggest something I would say to incorporate this into a coded function object in your controlDict ( https://www.openfoam.com/documentati...ionObject.html). In this way you will have something that is not hardcoded and you will be able to use in other solvers as well.


Best

K


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