CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (http://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   sampleDict output needs to be fixed! (http://www.cfd-online.com/Forums/openfoam-post-processing/121797-sampledict-output-needs-fixed.html)

musahossein August 5, 2013 15:02

sampleDict output needs to be fixed!
 
Dear all:

The out out from sample dict for pressures need to be fixed. My code in sample dict was as follows:
leftwall
{
type patch;
patches (leftWall);
rhoName rhoInf;
rhoInf 998.2; //Reference density for fluid
interpolate true;
triangulate false;
}

the output is as shown in the attached images. The output filenames are not consistent. Can some one tell me how/where to fix this so that it is either leftwalls or leftwall? If on the otherhand the same code is embedded in controlDict, the files names come out as .leftwalls. Thanks!
http://www.cfd-online.com/Forums/dat...AASUVORK5CYII=

musahossein August 5, 2013 15:04

1 Attachment(s)
looks like the image did not attach. Here goes....

musahossein August 6, 2013 09:51

output time interval in sample dict
 
Can anyone tell me if the output time can be set in sampledict? IN controldict for example, I can specify the output at 0.05 secs. I did a run with this time interval. However I would now like obtain output at 0.01 by using sampleDict, without running the solver again.

I am running the sloshingTan2D example in interDyMFOAM.

Thankyou
Musa

wyldckat August 17, 2013 07:43

Greetings Musaddeque,

From your description, it looks like you used 0.05 for writing outputs from the solver and now you want to sample with another period, although I'm not 100% if you want 0.01 or 0.1.
So, there are two possible situations:
  • If you want 0.1, then that means that need to tell sample which time instances you want to use:
    Code:

    sample -time "$(echo $(foamListTimes | awk '(NR+1)%2==0') | sed 's= =,=g')"
    It's a pretty convoluted way of doing this... but basically:
    1. foamListTimes - gives the list of existing times.
    2. The awk command gets only the odd number lines (0, 0.1, 0.2, etc).
    3. The sed command will replace spaces for commas.
    4. The "$()" is a way of launching sub-shells, i.e., to run commands from within the current command line.
  • If you want 0.01, that's somewhat insane, specially with a case that has the mesh moving around. In essence, this would imply that you want to interpolate data in time... for which OpenFOAM actually does give you this ability:
    Code:

    temporalInterpolate -divisions 5 -interpolationType spline -fields '(U alpha1 p_rgh)'
    Use "-help" for more options. As for the "p" field, the problem is that it doesn't exist in the folder "0", so you'll have to create one if you need it, which I think you can base yourself on the "p_rgh" field.
Best regards,
Bruno

musahossein August 27, 2013 15:45

ControlDict error for forces
 
Thanks for the response. I think it is better to rerun controDict rather than add more code for post processing. I have, however another problem. I noted that OpenFOAM lets you obtain forces using the following code snippet in the controlDict:
Code:

    forces
    {
    type forces;
    functionObjectLibs ("libforces.so"); //Lib to load
    patches (leftWall rightWall lowerWall);
        pName    p;
        UName  U;
    rhoName rhoInf;

    rhoInf 998.2; //Reference density for fluid
        nuInf 1e-06
    CofR (0 -0.071 0.25); //Origin for moment calculations
    outputControl timeStep;
        outputInterval 1;
    }

However, when I run interDyMFoam, I get the following error:

Code:

Starting time loop

Reading surface description:
    leftwalls
    rightwalls

--> FOAM Warning :
    From function void forces::read(const dictionary&)
    in file forces/forces.C at line 509
    Could not find U, p: in database.
    De-activating forces.
Interface Courant Number mean: 0 max: 0
Courant Number mean: 0.000151945 max: 0.00047273
deltaT = 0.00116279
Time = 0.00116279

Which U, p is it referring to?

musahossein August 27, 2013 17:18

keyword nu is undefined in dictionary "home/..../transportProperties"
 
Please ignore the previous post. I had a colon after the p and not a semi-colon. So I was getting an error and am now not getting an error. However, now I get an error that looks like this:

[9] --> FOAM FATAL IO ERROR:
[9] keyword nu is undefined in dictionary "/home/cfsengineers/OpenFOAM/cfsengineers-2.2.1/run/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/processor9/constant/transportProperties"
[9]
[9] file: /home/cfsengineers/OpenFOAM/cfsengineers-2.2.1/run/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/processor9/constant/transportProperties from line 0 to line 0.

nu is defined in the transportProperties. However, the lines referenced are line 0 to line 0. I cant understand what this means. Can anyone help?

wyldckat August 27, 2013 18:33

Hi Musaddeque,

That's a bit strange. Does the file "processor9/constant/transportProperties" exist?
And is it empty or does it have the same contents as the one at the main "constant/transportProperties"?

Because the message about "line 0 to 0" means that the file is either empty or non-existent, or something went wrong when reading the file, such as not enough permissions or the file is binary or something like that.

Best regards,
Bruno

musahossein August 27, 2013 21:00

I agree that it is indeed strange. The transport properties file is as follows:

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.0.1                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    location    "constant";
    object      transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Phase1 is water; phase2 is air. Values for Standard Temperature and pressure (0 deg C, 14.69 psi
// or 101.325 kPa, ) in accordance with NIST
//

phase1
{
    transportModel  Newtonian;
    nu              nu [ 0 2 -1 0 0 0 0 ] 1e-06;
    rho            rho [ 1 -3 0 0 0 0 0 ] 998.2;
}

phase2
{
    transportModel  Newtonian;
    nu              nu [ 0 2 -1 0 0 0 0 ] 1.50e-05;
    rho            rho [ 1 -3 0 0 0 0 0 ] 1.2;
}

sigma          sigma [ 1 0 -2 0 0 0 0 ] 0;


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

There may also be the case where there are additional files that OpenFOAM is trying to read in the same folder. As I have found out there are some instances where OpenFOAM will assume that all the files in the folder are relevant and will try to read all of them. So if you store older files for reference, then OpenFOAM may give error messages.

musahossein August 27, 2013 21:25

Quote:

Originally Posted by wyldckat (Post 448402)
Hi Musaddeque,

That's a bit strange. Does the file "processor9/constant/transportProperties" exist?
And is it empty or does it have the same contents as the one at the main "constant/transportProperties"?

Because the message about "line 0 to 0" means that the file is either empty or non-existent, or something went wrong when reading the file, such as not enough permissions or the file is binary or something like that.

Best regards,
Bruno

I checked the constant folder for processor 9. The folder does not have a transportProperties file. Only the polymesh file. I assumed that during parallel processing interDyMFoam would create or copy the transport properties folder into the constant folder of each processor. My assumption was incorrect?

wyldckat August 28, 2013 15:24

Hi Musaddeque,

Decomposition is usually only performed for the fields and mesh. All other dictionary files are meant to be only placed on the base case folder, since this way they will either:
  • be accessible to all parallel processes;
  • or the master process is the only one that needs to be aware of it.

The problem can be that you are trying to use something that is not aware that it should be looking in the base case folder and not inside the processor folder, which leads to this problem.

Wait... you're trying to use the forces function object, correct? Is there any other functions objects you are trying to use?
I ask this because there is a another possibility: the solver or function object might be trying to find the main "nu" value, as if there was only one fluid. But your case has got two fluids, which means that whatever you are using was only conceived for a single fluid.

Best regards,
Bruno

musahossein August 28, 2013 16:13

I am trying to capture wall pressure and wall forces. For the first one I am calling "libsurfaces.so" and for the second one "libforces.so". The nu error comes up when I call "libforces.so" and not when I call "libsurfaces.so"

My controldict code is as follows:


Code:

\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application    interDyMFoam;

startFrom      startTime;

startTime      0;

stopAt          endTime;

endTime        48;
//endTime        0.02;

//deltaT        0.01;
deltaT        0.001;

writeControl    adjustableRunTime;

 writeInterval  0.05;
//writeInterval  0.02;

purgeWrite      0;

writeFormat    ascii;

writePrecision  6;

writeCompression compressed;

timeFormat      general;

timePrecision  6;

runTimeModifiable yes;

adjustTimeStep  yes;

maxCo          0.5;
maxAlphaCo      0.5;

maxDeltaT      1;

functions
{

//    probes
//    {
//        type            probes;
//        functionObjectLibs ("libsampling.so");
//        outputControl  outputTime;
//        outputInterval  1;
//        probeLocations
//        (
//            ( 0 -20.0 0 )
//            ( 0  20.0 0 )
//        );
//        fields
//        (
//            p
//        );
//    }

      wallPressure
      {
        type            surfaces;
        functionObjectLibs ("libsampling.so");
        outputControl  outputTime;
        surfaceFormat  raw;
        fields    ( alpha1
                  p
            );
    interpolationScheme cell;
        surfaces
        (
            leftwalls
            {
                type        patch;
                patches    (leftWall);
        interpolate true;
                triangulate false;
            }
        rightwalls
            {
                type        patch;
                patches    (rightWall);
        interpolate true;
                triangulate false;
            }
        );
      }

    forces
    {
    type forces;
    functionObjectLibs ("libforces.so");        //Lib to load
    outputControl outputTime;
    patches (leftWall rightWall);
    pName p;
    UName U;
    rhoName rhoInf;
    rhoInf 998.2;                    //Reference density for fluid
    nuInf 1e-06;
    CofR (0 0 0);                    //Origin for moment calculations

    outputControl timeStep;
        outputInterval 1;
    }
   

} // end functions

I realize that this issue as been discussed on this forum, but it appears that this was corrected in OpenFOAM 2.2.1 which I have. But the error is still there.

musahossein August 28, 2013 16:15

I am sorry - nu is not a problem for libsampling.so not libsurfaces.so

wyldckat August 31, 2013 13:18

Hi Musaddeque,

I've tried the function objects you have on your "controlDict" in the tutorial case "multiphase/interDyMFoam/ras/testTubeMixer". And I found out that the problem comes from trying to use the function object "forces".

In addition, it doesn't matter if I run in serial or in parallel. The problem is that you're telling the "forces" function object to use "rhoInf" as the "rho" field, which is used for incompressible flow. But since you're using a solver of the type multiphase, you have 2 "nu" values and respectively 2 "rho" fields.
I searched with Google for:
Code:

openfoam multiphase forces
And found this thread: http://www.cfd-online.com/Forums/ope...mulations.html
I suggest you give it a very good read, to learn how to do this!

Good luck! Best regards,
Bruno


edit: if by any chance your patches or walls are all only in contact with a single phase, then perhaps you can use the rho for that phase. For example:
Code:

rhoName rho1;
or:
Code:

rhoName rho2;

danny123 September 6, 2013 03:58

Hi Bruno, hi musahossein,

I have looked up your suggestions. Seems to me that the file Forces.C has to be altered and recompiled.

There are several cases mentioned that cover a couple of other solvers than interFoam. Reading the code there the program is looking for a something named
"obr_.foundObject" to identify which model to apply. First it Looks for RAS, and indeed I have a RASproperties file (even thoughI do not know what it is good for since flow conditions are laminar). At this point the code asks for rho(), which may not be defined for the interFoam solver. The Definition of RAS seems to broad to me.

Later on in the code it calls for LESModel, this will not apply anyway, then for "basicThermo". I do not know what this is.

Finally, the program looks for

singlePhaseTransportModel. This is whare the nu error seems to be generated.

Is there any obr_.foundObject variable identifying interDymFoam or InterFoam? Maybe use multiPhaseTransportModel as an identifier? Is there an identifier just for 2-phase laminar flow?

Another question:

The above mentioned thread treats the shear Forces generated, but there should also be the system pressure somewhere. For single Phase incompressible this is p x rho or p_rgh - rho g h if you have defined gravity. For a two Phase System, the Definition of p_rgh does not make much sense to me.

Where do I find the proper pressure Definition? Does the definition of p_rgh really make sense for InterFoam?

Regards,

Daniel

musahossein September 6, 2013 08:23

danny123:

I am running interDymfoam for sloshingtank 2d case. I am using a 12 core server to run my code. My controldict referenced libforces.so. When I ran it the first time, error message "keyword nu not found" came up for each processor which did not make sense. The workaround involved making the following change to two files as described below:

In turbulence properties set:

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

simulationType RASModel;

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

In rasproperties set:

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

RASModel laminar;

turbulence off;

printCoeffs on;


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

For me this took care of the "nu" issue. However, as has been discussed in this thread, libforces.so still complains when running but does not affect the result.

wyldckat September 7, 2013 07:03

Greetings to all!

@Musaddeque:
Quote:

Originally Posted by musahossein (Post 450211)
For me this took care of the "nu" issue. However, as has been discussed in this thread, libforces.so still complains when running but does not affect the result.

Keep in mind that means that you are telling the solver to assume the flow is laminar and not turbulent! But if your flow is turbulent by nature, then you should be getting seriously big problems on the results...


@Daniel:
Quote:

Originally Posted by danny123 (Post 450168)
Where do I find the proper pressure Definition? Does the definition of p_rgh really make sense for InterFoam?

What you're looking for is already detailed here: http://www.cfd-online.com/Forums/ope...tml#post364630 - post #21

Best regards,
Bruno

danny123 September 11, 2013 11:39

Hello musahossein, hello Bruno,

my flow conditions are laminar all time, so I am not worried about turbulence. The method musahossein does indeed calculate forces.

Bruno, the method decribed in the post you sent us is not correct. The author may got the calculation of viscous forces right. However, pressure forces are pressure forces. There should be no difference whether it is Phase 1 or 2.

For the effect of gravity, I found the following post:

http://www.cfd-online.com/Forums/ope...e-gravity.html

I agree with author that for multi-phase systems, to account for gravity, you need to add rho() g to all fluid cells instead of using p_rgh static pressure. Do you know if this is implemented in interDymFoam? What kind of pressure definition should I use to account for gravity? Is it sufficient defining pd instead of p and it will use gravity g automatically (p being defined pd / rho I guess)?

Regards,

Daniel

musahossein September 13, 2013 21:51

Quote:

Originally Posted by danny123 (Post 451155)
Hello musahossein, hello Bruno,

my flow conditions are laminar all time, so I am not worried about turbulence. The method musahossein does indeed calculate forces.

Bruno, the method decribed in the post you sent us is not correct. The author may got the calculation of viscous forces right. However, pressure forces are pressure forces. There should be no difference whether it is Phase 1 or 2.

For the effect of gravity, I found the following post:

http://www.cfd-online.com/Forums/ope...e-gravity.html

I agree with author that for multi-phase systems, to account for gravity, you need to add rho() g to all fluid cells instead of using p_rgh static pressure. Do you know if this is implemented in interDymFoam? What kind of pressure definition should I use to account for gravity? Is it sufficient defining pd instead of p and it will use gravity g automatically (p being defined pd / rho I guess)?

Regards,

Daniel

Daniel: You may want to check out this thread. It may be of some help to you.

http://www.cfd-online.com/Forums/ope...rgh-1-7-a.html


All times are GMT -4. The time now is 13:36.