CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Question on sampleDict (http://www.cfd-online.com/Forums/openfoam-solving/116378-question-sampledict.html)

musahossein April 17, 2013 23:53

Question on sampleDict
 
Dear all:

Using sampleDict, I am trying to obtain pressure for the left and rightwall in a rectangular tank. The walls are called leftWall and rightWall in blockMesh. However sampleDict gives me reading for one wall only. How can I get it to read both walls? Any advice will be greatly appreciated.

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

setFormat raw;
surfaceFormat raw;


interpolationScheme cell;

fields
(alpha1
p);

surfaces
(
wallPressure
{
type patch;
patches (leftWall);
interpolate true;
triangulate false;
}
);

surfaces
(
wallPressure
{
type patch;
patches (rightWall);
interpolate true;
triangulate false;
}
);

wyldckat April 18, 2013 18:59

Hi Musaddeque,

Summarizing the problem:
  • You have this:
    Code:

    surfaces
    (
    wallPressure
    );

    surfaces
    (
    wallPressure
    );

  • What you really want is this:
    Code:

    surfaces
    (
    wallPressure
    wallPressure2
    );


The entry "surfaces" should be used as a single list and names should not be repeated:
Code:

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

setFormat    raw;
surfaceFormat raw;


interpolationScheme cell;
 
    fields
    (alpha1
    p);

    surfaces
      (   
    wallPressure
    {
    type        patch;
    patches        (leftWall);
    interpolate    true;
    triangulate    false;
    }
   
wallPressure2
    {
    type        patch;
    patches        (rightWall);
    interpolate    true;
    triangulate    false;
    }
    );

Best regards,
Bruno

musahossein April 18, 2013 22:47

Quote:

Originally Posted by wyldckat (Post 421640)
Hi Musaddeque,

Summarizing the problem:
  • You have this:
    Code:

    surfaces
    (
    wallPressure
    );

    surfaces
    (
    wallPressure
    );

  • What you really want is this:
    Code:

    surfaces
    (
    wallPressure
    wallPressure2
    );


The entry "surfaces" should be used as a single list and names should not be repeated:
Code:

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

setFormat    raw;
surfaceFormat raw;


interpolationScheme cell;
 
    fields
    (alpha1
    p);

    surfaces
      (   
    wallPressure
    {
    type        patch;
    patches        (leftWall);
    interpolate    true;
    triangulate    false;
    }
   
wallPressure2
    {
    type        patch;
    patches        (rightWall);
    interpolate    true;
    triangulate    false;
    }
    );

Best regards,
Bruno

Thanks for your response. I did the following and got the left and right wall cell pressures and phase equally well. It does the same thing as your suggestion. Thanks for your help!:
------------------------------------------------------------------------------------------------------------------------------------------------
fields (alpha1
p);

surfaces
(
left
{
type patch;
patches (leftWall);
interpolate true;
triangulate false;
}
right
{
type patch;
patches (rightWall);
interpolate true;
triangulate false;
}
);
--------------------------------------------------------------------------------------------------------------------------------------

musahossein May 7, 2013 15:54

OpenFoam does not recognize change in mesh size
 
Dear all:

I am running sloshingTank2D. In the blockMesh dict file, initially, the cell size was 50X50. Then I changed it to 271X271. Now when I run in parallel, I get the following error message:

--> FOAM FATAL IO ERROR:
size 2500 is not equal to the given value of 73441

file: /home/musa/OpenFOAM/musa-2.2.0/run/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/0/alpha1 from line 18 to line 2546.

Here 2500 is the previous mesh size. 73441 is the current mesh size of 271x271. So what does OpenFOAM mean by this error message. The alpha1.org file that it is refering to does not have any reference to the mesh size. So why is it pointing to the alpha1 file?

Thankyou.

wyldckat May 7, 2013 17:25

Hi Musaddeque,

The error message is due to the internal field for "alpha1" having a value count different from the mesh's own cell count. In essence, when setFields is executed, if the values are not all equal, it will define one value (scalar or vector) per cell of the mesh.

In the case folder you should find a file named "Allrun". This is a script that can be used to run the case as intended:
Code:

./Allrun
This folder can also be seen online, in case you've accidentally erased the Allrun script file: https://github.com/OpenFOAM/OpenFOAM...sloshingTank2D

From your description, it seems that you've missed two important steps:
Code:

cp 0/alpha1.org 0/alpha1
runApplication setFields

The first one recovers the original (".org") template file for the "alpha1" field. The second one defines the internal field values (i.e., fills the tank up to a certain height).

This is one of the quickest/easiest solutions there are, which is why it's the one shown in this tutorial ;)

In addition, there is also the "Allclean" script, which is designed to quickly clean the tutorial case to make it ready for another run, or just to save disk space. To run it, it's the same way:
Code:

./Allclean
Best regards,
Bruno

musahossein May 7, 2013 23:37

OpenFoam does not recognize change in mesh size
 
Quote:

Originally Posted by wyldckat (Post 425934)
Hi Musaddeque,

The error message is due to the internal field for "alpha1" having a value count different from the mesh's own cell count. In essence, when setFields is executed, if the values are not all equal, it will define one value (scalar or vector) per cell of the mesh.

In the case folder you should find a file named "Allrun". This is a script that can be used to run the case as intended:
Code:

./Allrun
This folder can also be seen online, in case you've accidentally erased the Allrun script file: https://github.com/OpenFOAM/OpenFOAM...sloshingTank2D

From your description, it seems that you've missed two important steps:
Code:

cp 0/alpha1.org 0/alpha1
runApplication setFields

The first one recovers the original (".org") template file for the "alpha1" field. The second one defines the internal field values (i.e., fills the tank up to a certain height).

This is one of the quickest/easiest solutions there are, which is why it's the one shown in this tutorial ;)

In addition, there is also the "Allclean" script, which is designed to quickly clean the tutorial case to make it ready for another run, or just to save disk space. To run it, it's the same way:
Code:

./Allclean
Best regards,
Bruno

Wyldcat: Thanks for your response. The problem is I get this error when I am running in parallel. The cp/... stuf I have in the Allrun file. However, I have modified the Allclean file to read:

#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory

foamCleanTutorials cases
#rm -rf 0/alpha1 0/alpha1.gz probes wallPressure pRefProbe

rm -rf probes wallPressure pRefProbe

# ----------------------------------------------------------------- end-of-file

Note that I commented out the removal of the 0/alpha1 fields because otherwise OpenFOAM deletes it each time Allclean is run and I do not know a way of recovering it. And I dont understand why the alpha files must be deleted each time. I am trying to call OpenFOAM from another code, so regenerating the alpha1 file each time is not something I can do.

Any suggestions?

musahossein May 7, 2013 23:46

OpenFoam does not recognize change in mesh size
 
The error message I get appears after MPI sets up the processors and is as follows. Initially I had 50X50 cells then I increased to 271x271 cells.


Processor 3
Number of cells = 9180
Number of faces shared with processor 1 = 135
Number of faces shared with processor 2 = 269
Number of processor patches = 2
Number of processor faces = 404
Number of boundary faces = 18496

Number of processor faces = 812
Max number of cells = 27540 (49.998% above average 18360.2)
Max number of processor patches = 2 (0% above average 2)
Max number of faces between processors = 408 (0.492611% above average 406)

Time = 0


--> FOAM FATAL IO ERROR:
size 2500 is not equal to the given value of 73441

file: /home/musa/OpenFOAM/musa-2.2.0/run/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/0/alpha1 from line 18 to line 2546.

From function Field<Type>::Field(const word& keyword, const dictionary&, const label)
in file /home/opencfd/OpenFOAM/OpenFOAM-2.2.0/src/OpenFOAM/lnInclude/Field.C at line 236.

FOAM exiting

musahossein May 8, 2013 14:25

One thing I dont understand is that we are running Allclean before Allrun. In Allclean the alpha1 and alpha1.org files are being removed from the 0 folder:
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory

foamCleanTutorials cases

rm -rf 0/alpha1 0/alpha1.gz
rm -rf probes wallPressure pRefProbe

# ----------------------------------------------------------------- end-of-file

Then Allrun is attempting to copy alpha1 file to alpha1.org as follows:

cp 0/alpha1.org 0/alpha1

But this cannot happen because alpha1 and alpha1.org files were deleted in the Allclean process. Is there something wrong here or am I missing something?

I look forward to your response.

wyldckat May 8, 2013 18:48

Hi Musahossein,

That's very strange... the "0/alpha1.org" should have not been erased by Allclean.
Only "0/alpha1" and "0/alpha1.gz" should have been erased!
These two are the uncompressed and compressed forms of the same file. They do not affect "alpha1.org".

Perhaps you accidentally erased "alpha1.org"?
If you are missing this file right now, you can get it back with this command:
Code:

cp $FOAM_TUTORIALS/multiphase/interDyMFoam/ras/sloshingTank2D/0/alpha1.org 0/alpha1.org
You can also try and modify the case in order to work in the same way that some other tutorials work. They use a complete "0.org" folder that acts as a template for the whole "0" folder.
Have a look for example at the tutorial "multiphase/interDyMFoam/ras/damBreakWithObstacle": https://github.com/OpenFOAM/OpenFOAM...akWithObstacle

Best regards,
Bruno


All times are GMT -4. The time now is 10:34.