CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   How to handle internal patches for p,T,U (https://www.cfd-online.com/Forums/openfoam/93135-how-handle-internal-patches-p-t-u.html)

monsoon October 5, 2011 23:37

How to handle internal patches for p,T,U
 
I have two cylinders connected to each other. Mesh generated in netgen. After netgenNeutralToFoam, it creates two internal patches where these two cylinders interface with each other. If I assign the same bc to these internal faces in netgen, then one of these patches is eliminated but the other one shows up with double the number of faces. How do you handle the boundaryField p,T,U for the internal patch. I just want the fluid to pass through. Removing the patch from PloyMesh/boundary does not work. Can someone help.

my boundary file looks like this

{
version 2.0;
format ascii;
class polyBoundaryMesh;
location "constant/polyMesh";
object boundary;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

6
(
patch0
{
type patch;
physicalType patch;
nFaces 0;
startFace 5532;
}
patch_wall1
{
type wall;
physicalType patch;
nFaces 1092;
startFace 5532;
}
patch2
{
type patch;
physicalType patch;
nFaces 54;
startFace 6624;
}
patch_out
{
type patch;
physicalType patch;
nFaces 27;
startFace 6678;
}
patch_wall2
{
type wall;
physicalType patch;
nFaces 1096;
startFace 6705;
}
patch_in
{
type patch;
physicalType patch;
nFaces 27;
startFace 7801;
}
)

Arnoldinho October 6, 2011 01:39

Hi,

I'm not sure if there is any possibility of handling internal faces as transient ones. But you could have a look at mergeMeshes and stitchMesh which enables you to completely 'delete' internal faces for merged meshes. This could save you from a lot of trouble and has always worked for me.

Regards,
Arne

tomislav_maric October 6, 2011 02:58

Hi,

patches are usually used in OF if you need some special operation done on a set of faces (always a kind of BC), if you want the flow to just flow through, there will be no boundary condition for any internal face. The internal faces are used (together with the corresponding volume centres: owner-neighbour) to assemble the coefficient matrix of the system.

This kind of thing used to happen to me as well when I used Salome-CAD to generate meshes, but there was an option to invert the face normals, and during the creation of the so called component mesh in Salome, there was an option to merge patches. Try mergeMeshes utility, or check if there is a similar option in Netgen.

Tomislav

monsoon October 6, 2011 21:00

Thanks for your replies. Following your recommendations I did manage to run mergeMeshes and the boundary file was created in the next time step(in my case 0.0005). My question is how do I use stitchMesh now. I have two boundary files in my case folder now. one is the original one TwoCyl/contant/polyMesh/boundary and the second one is TwoCly/0.0005/polyMesh/boundary (this one has the merged patches). I still have the interface patches I need to get rid of.

tomislav_maric October 7, 2011 03:57

2 Attachment(s)
Quote:

Originally Posted by monsoon (Post 326988)
Thanks for your replies. Following your recommendations I did manage to run mergeMeshes and the boundary file was created in the next time step(in my case 0.0005). My question is how do I use stitchMesh now. I have two boundary files in my case folder now. one is the original one TwoCyl/contant/polyMesh/boundary and the second one is TwoCly/0.0005/polyMesh/boundary (this one has the merged patches). I still have the interface patches I need to get rid of.

I've made two cases: cavity and cavityAppend.

This is what you can do to see how the stitchPatches works (unpack the cases in the same directory, I have set two patches of the two faces called stitch1 and stitch2 that should be stitched together to form internal set of faces, check out the blockMeshDict files):

Code:

cd cavity
blockMesh
cd ../cavityAppend
blockMesh
cd ../cavity
mergeMeshes . . ../cavityAppend ../cavityAppend
cp -r 0.005/polyMesh constant/

If you have pyFoam:

Code:

pyFoamCreateBoundaryPatches.py --clear -unused 0/p
pyFoamCreateBoundaryPatches.py --clear -unused 0/U

If you don't have pyFoam, you need to add the BCs (stitch1 and stitch2) for the fields p and U (and for your case, all the other fields that are variables in the governing equation system).

After you have added the BCs (still inside the cavity directory),

Code:

stitchMesh stitch1 stitch2 -perfect -overwrite -case .
Examine the mesh in paraFoam: the stitched patches are converted to zones, and the actual patch sizes are set to "0".

To confirm that the case is properly set up and the mesh has no internal walls or what not:
Code:

icoFoam
There you go. Two stitched patches. :)

Hope this helps,

Tomislav

monsoon October 8, 2011 23:36

Thank you Tomislav and Arne. I finally got it working.
Aru

musahossein December 5, 2011 17:14

naming patches
 
Dear all:
I have a 2D rectangular tank. I need to label the left wall as leftwall and the right wall as rightwall. How can I name the patches accordingly?

musahossein December 6, 2011 10:58

Naming Patches in OpenFOAM
 
Dear all:
I am modeling a rectangular tank and my blockMeshDict file looks like as follows:
vertices
(
(-0.5 -20 -10.0) // Vertex back lower left corner = 0
(-0.5 20 -10.0) // Vertex back lower right corner= 1
(-0.5 20 10.0) // Vertex back upper right corner= 2
(-0.5 -20 10.0) // Vertex back upper left corner = 3

(0.5 -20 -10.0) // Vertex front lower left corner = 4
(0.5 20 -10.0) // Vertex front lower right corner= 5
(0.5 20 10.0) // Vertex front upper right corner = 6
(0.5 -20 10.0) // Vertex front upper left corner =7

);

blocks
(
// block0
hex (0 1 2 3 4 5 6 7)
(40 40 1)
simpleGrading (1 1 1)
);

//patches
boundary
(
lowerWall
{
type patch;
faces
(
(0 1 5 4)
);
}
rightWall
{
type patch;
faces
(
(1 2 6 5)
);
}
atmosphere
{
type patch;
faces
(
(2 3 7 6)
);
}
leftWall
{
type patch;
faces
(
(0 4 7 3)
);
}
frontAndBack
{
type Empty;
faces
(
(4 5 6 7)
(0 3 2 1)
);
}
);
when I run blockmesh it seems to run ok per output from openfoam:

musa@musa-Satellite-M35X:~/OpenFOAM/musa-2.0.1/run/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D$ blockMesh
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.0.1 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : 2.0.1-51f1de99a4bc
Exec : blockMesh
Date : Dec 06 2011
Time : 10:45:44
Host : musa-Satellite-M35X
PID : 3021
Case : /home/musa/OpenFOAM/musa-2.0.1/run/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Disallowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Creating block mesh from
"/home/musa/OpenFOAM/musa-2.0.1/run/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/constant/polyMesh/blockMeshDict"
No non-linear edges defined
Creating topology blocks
Creating topology patches

Creating block mesh topology

Check topology

Basic statistics
Number of internal faces : 0
Number of boundary faces : 6
Number of defined boundary faces : 6
Number of undefined boundary faces : 0
Checking patch -> block consistency

Creating block offsets
Creating merge list .

Creating polyMesh from blockMesh
Creating patches
Creating cells
Creating points with scale 1

There are no merge patch pairs edges

Writing polyMesh
----------------
Mesh Information
----------------
boundingBox: (-0.5 -20 -10) (0.5 20 10)
nPoints: 3362
nCells: 1600
nFaces: 6480
nInternalFaces: 3120
----------------
Patches
----------------
patch 0 (start: 3120 size: 40) name: lowerWall
patch 1 (start: 3160 size: 40) name: rightWall
patch 2 (start: 3200 size: 40) name: atmosphere
patch 3 (start: 3240 size: 40) name: leftWall
patch 4 (start: 3280 size: 3200) name: frontAndBack

End

but when I try to view it in paraFoam, the viewer opens up, but soon closes and gives the following error message:

musa@musa-Satellite-M35X:~/OpenFOAM/musa-2.0.1/run/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D$ paraFoam
created temporary 'sloshingTank2D.OpenFOAM'


--> FOAM FATAL IO ERROR:
keyword lowerWall is undefined in dictionary "/home/musa/OpenFOAM/musa-2.0.1/run/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/0/U::boundaryField"

file: /home/musa/OpenFOAM/musa-2.0.1/run/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/0/U::boundaryField from line 25 to line 26.

From function dictionary::subDict(const word& keyword) const
in file db/dictionary/dictionary.C at line 461.

FOAM exiting

Sorry for the long post. But is the error in the blockMeshDict file or some where else?

Arnoldinho December 6, 2011 11:04

The error is what it says: "keyword lowerWall is undefined in dictionary "/home/musa/OpenFOAM/musa-2.0.1/run/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/0/U::boundaryField"

It means that you did not define "lowerWall" in your U file under boundaryField.

Arne

musahossein December 6, 2011 11:22

Quote:

Originally Posted by Arnoldinho (Post 334891)
The error is what it says: "keyword lowerWall is undefined in dictionary "/home/musa/OpenFOAM/musa-2.0.1/run/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/0/U::boundaryField"

It means that you did not define "lowerWall" in your U file under boundaryField.

Arne

Thanks for your response. When I look at the U file it has the following contents:
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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

internalField uniform (0 0 0);

boundaryField
{
walls
{
type movingWallVelocity;
value uniform (0 0 0);
}
}

where would I define it? and would I need to define the other patches too? can you direct me to where this is discussed in the OpenFoam user guide -- if it is?

Arnoldinho December 6, 2011 11:30

Yup. So "lowerWall" is missing. You have to define every patch (which can be found in constant/polyMesh/boundary) in your "files" in 0 folder.

Regarding the User guide, just have a look at chapter 2.1.1.2 "Boundary and initial conditions". It might be worth working with these tutorials first...

Arne

musahossein December 6, 2011 12:22

Agreed! Thanks for the reference. One question though. Where would I find explanation of key words such as buoyantPressure in OpenFOAM.

musahossein December 6, 2011 12:44

Quote:

Originally Posted by Arnoldinho (Post 334897)
Yup. So "lowerWall" is missing. You have to define every patch (which can be found in constant/polyMesh/boundary) in your "files" in 0 folder.

Regarding the User guide, just have a look at chapter 2.1.1.2 "Boundary and initial conditions". It might be worth working with these tutorials first...

Arne

I revised the U file to include the various patches:
dimensions [0 1 -1 0 0 0 0];

internalField uniform (0 0 0);

boundaryField
{
lowerWall
{
type movingWallVelocity;
value uniform (0 0 0);
}
rightWall
{
type movingWallVelocity;
value uniform (0 0 0);
}
atmosphere
{
type movingWallVelocity;
value uniform (0 0 0);
}
leftWall
{
type movingWallVelocity;
value uniform (0 0 0);
}
frontAndBack
{
type empty;
}
}

Since this is a 2D case, the front and back walls have been defined as empty in the blockmeshdict file. However, paraFoam does not like it:
musa@musa-Satellite-M35X:~/OpenFOAM/musa-2.0.1/run/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D$ paraFoam
created temporary 'sloshingTank2D.OpenFOAM'


--> FOAM FATAL IO ERROR:

patch type 'genericPatch' not constraint type 'empty'
for patch frontAndBack of field U in file "/home/musa/OpenFOAM/musa-2.0.1/run/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/0/U"

file: /home/musa/OpenFOAM/musa-2.0.1/run/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/0/U::boundaryField::frontAndBack from line 45 to line 45.

From function emptyFvPatchField<Type>::emptyFvPatchField
(
const fvPatch& p,
const Field<Type>& field,
const dictionary& dict
)

in file fields/fvPatchFields/constraint/empty/emptyFvPatchField.C at line 100.

FOAM exiting

Any suggestions? Also, I am not sure about the "atmosphere". Is this a moving wall (in the sense it moves with the tank) since it has to move with the tank? I noted that in the sloshingTank2D examples, all patches were defined as moving wall in the U folder.

amirr July 23, 2012 06:55

stitching 2 volumes
 
Hi this really helps understanding the stitching procedure. but i have a situation where i have to combine one rectangle into another ( one small volume into a bigger volume). mergeMesh works well but after running a simple flow i realize that the meshes are not combine at all. any suggestion ? thanks in advance

Quote:

Originally Posted by tomislav_maric (Post 327020)
I've made two cases: cavity and cavityAppend.

This is what you can do to see how the stitchPatches works (unpack the cases in the same directory, I have set two patches of the two faces called stitch1 and stitch2 that should be stitched together to form internal set of faces, check out the blockMeshDict files):

Code:

cd cavity
blockMesh
cd ../cavityAppend
blockMesh
cd ../cavity
mergeMeshes . . ../cavityAppend ../cavityAppend
cp -r 0.005/polyMesh constant/

If you have pyFoam:

Code:

pyFoamCreateBoundaryPatches.py --clear -unused 0/p
pyFoamCreateBoundaryPatches.py --clear -unused 0/U

If you don't have pyFoam, you need to add the BCs (stitch1 and stitch2) for the fields p and U (and for your case, all the other fields that are variables in the governing equation system).

After you have added the BCs (still inside the cavity directory),

Code:

stitchMesh stitch1 stitch2 -perfect -overwrite -case .
Examine the mesh in paraFoam: the stitched patches are converted to zones, and the actual patch sizes are set to "0".

To confirm that the case is properly set up and the mesh has no internal walls or what not:
Code:

icoFoam
There you go. Two stitched patches. :)

Hope this helps,

Tomislav


Mojtaba.a August 17, 2012 05:59

Quote:

Originally Posted by tomislav_maric (Post 327020)
I've made two cases: cavity and cavityAppend.

This is what you can do to see how the stitchPatches works (unpack the cases in the same directory, I have set two patches of the two faces called stitch1 and stitch2 that should be stitched together to form internal set of faces, check out the blockMeshDict files):

Code:

cd cavity
blockMesh
cd ../cavityAppend
blockMesh
cd ../cavity
mergeMeshes . . ../cavityAppend ../cavityAppend
cp -r 0.005/polyMesh constant/

If you have pyFoam:

Code:

pyFoamCreateBoundaryPatches.py --clear -unused 0/p
pyFoamCreateBoundaryPatches.py --clear -unused 0/U

If you don't have pyFoam, you need to add the BCs (stitch1 and stitch2) for the fields p and U (and for your case, all the other fields that are variables in the governing equation system).

After you have added the BCs (still inside the cavity directory),

Code:

stitchMesh stitch1 stitch2 -perfect -overwrite -case .
Examine the mesh in paraFoam: the stitched patches are converted to zones, and the actual patch sizes are set to "0".

To confirm that the case is properly set up and the mesh has no internal walls or what not:
Code:

icoFoam
There you go. Two stitched patches. :)

Hope this helps,

Tomislav

Hi Tomislav, Thanks for your help.
I now understand how to stitch to faces, but the new problem in openFOAM is that it can't stitch multiple faces which are connected to each other. It means that as soon as I stitch to faces, the neighbor faces which are both interfaces can not be stitched. Someone reported it as a bug to openFOAM but no solution have been suggested. until now I haven't found any solution for this problem. There are lots of threads about stitchMesh but unfortunately they haven't reached to any solution. There is is just a little procedure in this post:

but I really couldn't understand it well. Do u have any idea how we can handle this?

Quote:

Originally Posted by amirr (Post 372959)
Hi this really helps understanding the stitching procedure. but i have a situation where i have to combine one rectangle into another ( one small volume into a bigger volume). mergeMesh works well but after running a simple flow i realize that the meshes are not combine at all. any suggestion ? thanks in advance

Hi amir,
Have you found any solution for this? I have the same problem.

Regards~
Mojtaba

openfoam_user October 4, 2012 09:04

stitchMesh
 
Dear Tomislav,

I am struggling with the 'stitchMesh' command to get rid of the interface between 2 meshes. The grids have done with ICEM Hexa.

Tomislav, I have redone your testcase. It works. But you have the same point density on the 2 faces (stitch1 and stitch2).
If the point density is different does it still work ?

They are a lot a comments about it in the forum, but no final answer on how to solve it. Need help.

Regards,
Stephane.

aujamal20 March 22, 2013 15:00

how to create internal patch
 
Dear
I am having a case of fluid passing through a cylinder. Fluid is entering from inlet patch and leaving the cylinder through outlet patch. There is a small tube having central axis coinciding the cylinder axis.
Now you can imagine as the fluid enters the cylinder and runs parallel to central axis a portion of fluid also passes through the tube. And I am interested to know the mass flow rate and T of fluid through that tube.
What I am trying to do is using topoSet to define a faceZone and using createBaffles utility to make a patch. I can create patch but the problems occur as that patch also appears as boundray patch and i fail to get required things.
Please let me know how I can fix this problem by defining internal patch and using that internal patch name in functionObjects which are defined in control dict to calculate mass flow through patch.
:cool::cool::cool::cool::cool:

Thanks
Jamal


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