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

Extract cells from multiple cell zones

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

Like Tree1Likes
  • 1 Post By olesen

Reply
 
LinkBack Thread Tools Display Modes
Old   May 2, 2012, 22:18
Post Extract cells from multiple cell zones
  #1
New Member
 
deok-kyu choi
Join Date: Feb 2012
Location: Rep. of Korea
Posts: 12
Rep Power: 5
ggoggodak85 is on a distinguished road
is it possible to extract cells from multiple cell zones?

and how can i set the vector value to selected cells?


regards,
ggoggodak85 is offline   Reply With Quote

Old   May 3, 2012, 02:30
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 777
Rep Power: 18
olesen will become famous soon enough
Quote:
Originally Posted by ggoggodak85 View Post
is it possible to extract cells from multiple cell zones?

and how can i set the vector value to selected cells?


regards,
To loop through the cells, you'd need something like the following. Note that this will not work "as is", but is just a guide:


Code:
        // cellZoneIds with the IDs of your cell zones
        // mesh_ is a reference to the mesh
 
        forAll(cellZoneIds, zoneI)
        {
            const labelList& cells = mesh_.cellZones()[cellZoneIds[zoneI]];
            forAll(cells, i)
            {
                // do something for cells[i]
            }
        }
olesen is offline   Reply With Quote

Old   May 4, 2012, 05:46
Default
  #3
New Member
 
deok-kyu choi
Join Date: Feb 2012
Location: Rep. of Korea
Posts: 12
Rep Power: 5
ggoggodak85 is on a distinguished road
Quote:
Originally Posted by olesen View Post
To loop through the cells, you'd need something like the following. Note that this will not work "as is", but is just a guide:


Code:
        // cellZoneIds with the IDs of your cell zones
        // mesh_ is a reference to the mesh
 
        forAll(cellZoneIds, zoneI)
        {
            const labelList& cells = mesh_.cellZones()[cellZoneIds[zoneI]];
            forAll(cells, i)
            {
                // do something for cells[i]
            }
        }
Dear olesen,
finally I did by olesen's favor!
But I'd like to do something more.

Following screenshot, it seems to be calculated for every cells.

How can i apply coriolis force for selected cell zone (celltable_2) ?
zone of celltable_2 is circle area in box.

Here is my code, but is just a guide

forAll(mesh.cellZones(),i)
{
const cellZone& zone = mesh.cellZones()[i];

if (zone.name()=="cellTable_2")
{
const labelList& cellLabels = mesh.cellZones()[i];
Info << "Found matching zone " << zone.name() << " with " << cellLabels.size() << " cells." << endl;

forAll(cellLabels, i)
{
// Calculate the coriolis force in selected cells (cellTable_2)
volVectorField Fcoriolis = Omega ^ (mesh.C() - Origin);
Fcoriolis.write();
}
}
}

regards,
Attached Images
File Type: jpg Screenshot.jpg (43.6 KB, 21 views)
ggoggodak85 is offline   Reply With Quote

Old   May 4, 2012, 06:39
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 777
Rep Power: 18
olesen will become famous soon enough
Quote:
Originally Posted by ggoggodak85 View Post
How can i apply coriolis force for selected cell zone (celltable_2) ?
zone of celltable_2 is circle area in box.
Two approaches.

1. if you will only ever have a single zone:
Code:
label zoneId = mesh.cellZones().findIndex("cellTable_2");
if (zoneId != -1)
{
    const labelList& cellIds = mesh.cellZones()[zoneId];
    forAll(cellIds, i)
    {
...
    }
}
2. if you want a regex to select one or more zones:
Code:
labelList zoneIds = mesh.cellZones().findIndices("cellTable_[1-3]");
forAll(zoneIds, zoneI)
{
    const labelList& cellIds = mesh.cellZones()[zoneIds[zoneI]];
    forAll(cellIds, i)
    {
...
    }
}
As usual, the code example may not be exactly correct.
mm.abdollahzadeh likes this.
olesen 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
how to set periodic boundary conditions Ganesh FLUENT 13 January 22, 2014 05:11
Cells with t below lower limit Purushothama CD-adapco 2 May 31, 2010 21:58
Warning 097- AB CD-adapco 6 November 15, 2004 05:41
two adjacent cell zones. Thejasvi FLUENT 3 November 26, 2001 09:35
Tracking/Modifying Cell Zones Greg Perkins FLUENT 1 November 7, 2000 00:35


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