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

Access boundaryMesh / boundaryField on cellZone

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By jhoepken

Reply
 
LinkBack Thread Tools Display Modes
Old   August 13, 2014, 16:36
Default Access boundaryMesh / boundaryField on cellZone
  #1
Member
 
Ken
Join Date: Aug 2012
Posts: 65
Blog Entries: 1
Rep Power: 6
Nucleophobe is on a distinguished road
Hi all:

I have a question similar to one posed in an earlier thread regarding the manipulation of cellZones.

I would like to calculate the wall shear stress on the boundary of a cellZone which I have created using topoSet. I think this would be something like:

Code:
            const label cellZoneID = mesh.cellZones().findZoneID("myCellZone");
            if (cellZoneID < 0)
            {
                FatalError
                    << "Unable to find cell zone " << "myCellZone" << endl
                    << exit(FatalError);
            }
            const cellZone& zone = mesh.cellZones()[cellZoneID];
            const cellZoneMesh& zoneMesh = zone.zoneMesh();
            const labelList& cellsZone = zoneMesh[cellZoneID];

           // Calculate WSS as in 'wallShearStress' utility:
            autoPtr<incompressible::RASModel> model
            (
                incompressible::RASModel::New(U, phi, laminarTransport)
            );
            const volSymmTensorField Reff(model->devReff());

            // Perform this calculation over the cell set only - how?
            scalarField zoneWSS = mag( (-mesh.Sf().boundaryField()[cellZoneID]/mesh.magSf().boundaryField()[cellZoneID]) & Reff.boundaryField()[cellZoneID] )
But I don't think "mesh.Sf().boundaryField()[cellZoneID]" is correct (this would access the patch corresponding to cellZoneID, not the cellZone, right?).

Can anyone give me some guidance on how to proceed? Thanks!

-Nuc

P.S.
Relevant thread:
How to compute cellZone volume
Quote:
Originally Posted by rob3rt View Post
... I know there is a function like mag(mesh.Sf().boundaryField()[cellZoneID][cI]) ... <-- This is what I'm looking for, but I'm not sure about the syntax
Nucleophobe is offline   Reply With Quote

Old   August 14, 2014, 08:35
Default
  #2
Senior Member
 
Jens Höpken
Join Date: Apr 2009
Location: Duisburg, Germany
Posts: 156
Rep Power: 9
jhoepken is on a distinguished road
Send a message via Skype™ to jhoepken
Just a short question: Are there multiple boundary patches in the cellZone?
__________________
Blog: sourceflux.de/blog
"The OpenFOAM Technology Primer": sourceflux.de/book
Twitter: @sourceflux_de
Interested in courses on OpenFOAM?
jhoepken is offline   Reply With Quote

Old   August 14, 2014, 10:01
Default
  #3
Member
 
Ken
Join Date: Aug 2012
Posts: 65
Blog Entries: 1
Rep Power: 6
Nucleophobe is on a distinguished road
Quote:
Originally Posted by jhoepken View Post
Just a short question: Are there multiple boundary patches in the cellZone?
In this case, there is only one boundary patch (a wall) and then some exposed internal faces.

Is it possible to query a patch within a cellZone?
Nucleophobe is offline   Reply With Quote

Old   August 14, 2014, 10:10
Default
  #4
Senior Member
 
Jens Höpken
Join Date: Apr 2009
Location: Duisburg, Germany
Posts: 156
Rep Power: 9
jhoepken is on a distinguished road
Send a message via Skype™ to jhoepken
Why don't you create a faceZone that solely contains the boundary faces and just loop over them?
Nucleophobe likes this.
__________________
Blog: sourceflux.de/blog
"The OpenFOAM Technology Primer": sourceflux.de/book
Twitter: @sourceflux_de
Interested in courses on OpenFOAM?
jhoepken is offline   Reply With Quote

Old   August 14, 2014, 10:14
Default
  #5
Member
 
Ken
Join Date: Aug 2012
Posts: 65
Blog Entries: 1
Rep Power: 6
Nucleophobe is on a distinguished road
Quote:
Originally Posted by jhoepken View Post
Why don't you create a faceZone that solely contains the boundary faces and just loop over them?
jhoepken,

I tried this, but the faceSet I created included internal faces in my bounding box.If I can create a faceSet from a patch, that would work, so I'll look into that.

Thanks!
Nucleophobe is offline   Reply With Quote

Old   August 14, 2014, 16:07
Default
  #6
Member
 
Ken
Join Date: Aug 2012
Posts: 65
Blog Entries: 1
Rep Power: 6
Nucleophobe is on a distinguished road
*EDIT: I got it - see bottom

Okay, I was able to create a faceSet of boundary faces only via the following topoSetDict code (the key - use of "action subSet"):
Code:
    {
        name   myFaceSet;
        type    faceSet;
        action  new;
        source  patchToFace;
        sourceInfo
        {
            name myPatch;
        }
    }
    {
        name  myFaceSet;
        type    faceSet;
        action  subset;
        source boxToFace;
        sourceInfo
        {
            box   (-0.045 -0.0123 -0.02) (-0.00209 0.0105 0.015);
        }
    }
    {

        name     myFaceZone;
        type      faceZoneSet;
        action    new;
        source   setToFaceZone;
        sourceInfo
        {
            faceSet myFaceSet;
        }
    }
So, now I have a faceZone containing global indices to the faces in my region of interest. However, I am having trouble querying these faces. For example, mesh.magSf() allows for accessing faces using their global index, but it only includes internal faces, not boundary faces.

Meanwhile, mesh.magSf().boundaryField() allows for accessing boundary faces by patch ID and local face ID, not global face ID.

How would I instead query the face area of the faces in my faceZone, which are boundary faces? Thanks again!
Code:
           // Example Code:
           scalar zoneFaceArea(0);

           forAll (facesZone, faceI)
           {
                // mesh.magSf() addresses internal faces only, while the indices from facesZone[faceI] address boundary faces...
                zoneFaceArea += mesh.magSf()[facesZone[faceI]]; 
           }

*SOLUTION:
To convert between global faceID and local, patch-based faceID, you can use the 'whichPatch' and 'whichFace' functions. So, something like the following:
Code:
           scalar zoneFaceArea(0);

           forAll (facesZone, faceI)
           {
                label facePatchID = mesh.boundaryMesh().whichPatch(faceI);
                label faceID = mesh.boundaryMesh()[facePatchID].whichFace(facesZone[faceI]);                 

                zoneFaceArea += mesh.magSf().boundaryField()[facePatchID][faceID];
                // etc... 
           }
I found references to these functions in "src/fvOptions/sources/derived/effectivenessHeatExchangerSource/effectivenessHeatExchangerSource.C"

Thanks for the help jhoepken! I hope your book is coming along well - it looks interesting.

Last edited by Nucleophobe; August 15, 2014 at 07:35.
Nucleophobe is offline   Reply With Quote

Old   August 15, 2014, 07:25
Default
  #7
Senior Member
 
Jens Höpken
Join Date: Apr 2009
Location: Duisburg, Germany
Posts: 156
Rep Power: 9
jhoepken is on a distinguished road
Send a message via Skype™ to jhoepken
Great that you've figured it out! I was busy and could not answer, sorry .
__________________
Blog: sourceflux.de/blog
"The OpenFOAM Technology Primer": sourceflux.de/book
Twitter: @sourceflux_de
Interested in courses on OpenFOAM?
jhoepken is offline   Reply With Quote

Old   March 28, 2015, 13:08
Default
  #8
New Member
 
Join Date: Nov 2011
Posts: 28
Rep Power: 6
Andy_bm is on a distinguished road
I am interested of this topic.

I made faceZone with snappyHexMesh using stl file like:
Code:
faceZone1
{
level (1 1);
cellZone  cz1;
faceZone fz1;
...
}
And I want get access to pressure and U fields on this surface (fz1) during calculation. How it can be implemented? I tried to use code from this topic but has no effect.
Andy_bm is offline   Reply With Quote

Old   March 28, 2015, 13:14
Default
  #9
Member
 
Ken
Join Date: Aug 2012
Posts: 65
Blog Entries: 1
Rep Power: 6
Nucleophobe is on a distinguished road
Andy,

Can you post your code so we can see what's going on? You need to setup a few things before you can access faceZone data.
Nucleophobe is offline   Reply With Quote

Old   March 28, 2015, 14:25
Default
  #10
New Member
 
Join Date: Nov 2011
Posts: 28
Rep Power: 6
Andy_bm is on a distinguished road
It not easy because there is no way to see it in my project now. I tried different variants.
Code:
label zID = mesh.facesZone().findZoneID(zName);
const faceZone& facesZone = mesh.faceZone()[zID];
 
forAll(facesZone, I)
{
Here I want get access to pressure field. If I try code as
p.boundaryField()[zID][i]; 
I get acces to patch field with ID=zID
 
If I try 
facePatchID = mesh.boundaryMesh().whichPatch(zID);
fID = mesh.boundaryMesh[facePatchID].whichFace(facezZone[zID])
I get error during calculation.
}
Sorry, may be errors because I entered the code as I remember.
Andy_bm is offline   Reply With Quote

Old   April 1, 2015, 10:51
Default
  #11
New Member
 
Join Date: Nov 2011
Posts: 28
Rep Power: 6
Andy_bm is on a distinguished road
Do you have any idea?
Andy_bm is offline   Reply With Quote

Old   April 1, 2015, 10:58
Default
  #12
Member
 
Ken
Join Date: Aug 2012
Posts: 65
Blog Entries: 1
Rep Power: 6
Nucleophobe is on a distinguished road
Can you post your error message too? I'll dig up my code later and see how the syntax differs.

BTW: you have a typo in your code:
facezZone[zID]

facesZone[zID]
Nucleophobe is offline   Reply With Quote

Old   April 5, 2015, 12:43
Default
  #13
New Member
 
Join Date: Nov 2011
Posts: 28
Rep Power: 6
Andy_bm is on a distinguished road
PrintStack error. I think it is because faceZone length array and numder iteration in cycle is different
Code:
facezZone[zID]
facesZone[zID]
It's my mistake. All right in code
Andy_bm is offline   Reply With Quote

Old   April 7, 2015, 04:19
Default
  #14
New Member
 
Join Date: Nov 2011
Posts: 28
Rep Power: 6
Andy_bm is on a distinguished road
Maybe there is function in mesh which get faceID and return cellID?
Andy_bm is offline   Reply With Quote

Old   April 30, 2015, 18:25
Default
  #15
New Member
 
Join Date: Nov 2011
Posts: 28
Rep Power: 6
Andy_bm is on a distinguished road
I solved this problem but it is not work in parallel. Because there are boundaryfaces on processor and faces are duplicate. How can I delete duplicate faces on processor?
Andy_bm is offline   Reply With Quote

Old   February 26, 2016, 11:14
Default
  #16
Member
 
Join Date: Mar 2013
Posts: 92
Rep Power: 5
giack is on a distinguished road
Hi to all,

I'm also interested to the topic.
How did you solve the PrintStack error?

Thanks
Giacomo
giack is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[DesignModeler] DesignModeler Scripting: How to get Full Command Access ANT ANSYS Meshing & Geometry 41 August 26, 2016 07:02
Getting access to mesh (fvMesh) via object registry Chris Lucas OpenFOAM Programming & Development 15 July 29, 2016 21:17
defining two cellZone in SHM student666 OpenFOAM Native Meshers: snappyHexMesh and Others 0 July 15, 2014 08:33
OF-2.2.x: Derived class from cellZone and "undefined symbol error" A_Pete OpenFOAM Programming & Development 6 April 28, 2014 01:53
Error: access: unbound variable,HELP sudhakar FLUENT 0 January 16, 2007 00:21


All times are GMT -4. The time now is 14:00.