CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Mesh Utilities

How to create a cellZone from a list of cells?

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

Reply
 
LinkBack Thread Tools Display Modes
Old   September 16, 2011, 14:43
Default How to create a cellZone from a list of cells?
  #1
Member
 
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 6
bigbang is on a distinguished road
So I've extracted a list of cell IDs from paraview after meshing. I want to create a cellZones file that contains a list of all these cells for use in simplePorousFoam.

Any ideas?
bigbang is offline   Reply With Quote

Old   September 17, 2011, 07:49
Default
  #2
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 245
Blog Entries: 5
Rep Power: 10
tomislav_maric is on a distinguished road
Quote:
Originally Posted by bigbang View Post
So I've extracted a list of cell IDs from paraview after meshing. I want to create a cellZones file that contains a list of all these cells for use in simplePorousFoam.

Any ideas?
Here's an idea:

Code:
      // Define a cellZoneMesh of size 0.

    cellZoneMesh zones
    (
        IOobject
        (
            "zones",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ
        ),
        mesh, 
        0
    );

    // Bogus label list definition, replace with your ID list here:
    // if you have created it from some outside app and written it 
    // onto the HDD, you will need to read and register it using a
    // LabelLiist<T> constructor.

        // Bogus label list of ten elements.  
    labelList selectCells (10,0);

        // Bogus selection, just for this example: select cells with
        // labels 0-9.
    forAll (selectCells, I)
    {
        selectCells[I] = I;
    }

    // Define a cellZone from the selectCells label list (not a cell list, a list of IDs is not 
    // a cell list, it's a label list :) )
    cellZone myZone
    (
        "myZone",
        selectCells, 
        0,
        zones
    );

    // Brute force write.
    OFstream outFile("myZone");
    myZone.write(outFile);
This is just the first thing I thought of. You probably won't be happy with the myZone.write(IOstream) approach.

What i find interesting is that the
Code:
cellZone
constructor requires a const reference to the
Code:
cellZoneMesh
which is a list of
Code:
cellZone
basically.

Hope this is of any help...

T.
tomislav_maric is offline   Reply With Quote

Old   September 19, 2011, 11:11
Default
  #3
Member
 
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 6
bigbang is on a distinguished road
Hi T,

Thanks for this reply.

I'm still relatively new to programming in openFoam.

I tried to splice your code into some tutorials that I've done, but when I compile I get the following error:

Code:
myZones.C:42:30: error: createFields.H: No such file or directory
myZones.C: In function ‘int main(int, char**)’:
myZones.C:88: error: ‘OFstream’ was not declared in this scope
myZones.C:88: error: expected ‘;’ before ‘outFile’
myZones.C:89: error: ‘outFile’ was not declared in this scope
/opt/openfoam201/src/finiteVolume/lnInclude/initContinuityErrs.H:37: warning: unused variable ‘cumulativeContErr’
make: *** [Make/linux64GccDPOpt/myZones.o] Error 1
alexander@alexander-G50VT:~/OpenFOAM/alexander-2.0.1/applications/myZones$ gedit myZones.C
Basically, what do I need to include to run your code?

Thanks for helping out a newbie.
bigbang is offline   Reply With Quote

Old   September 19, 2011, 16:01
Default
  #4
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 245
Blog Entries: 5
Rep Power: 10
tomislav_maric is on a distinguished road
Quote:
Originally Posted by bigbang View Post
Hi T,

Thanks for this reply.

I'm still relatively new to programming in openFoam.

I tried to splice your code into some tutorials that I've done, but when I compile I get the following error:

Code:
myZones.C:42:30: error: createFields.H: No such file or directory
myZones.C: In function ‘int main(int, char**)’:
myZones.C:88: error: ‘OFstream’ was not declared in this scope
myZones.C:88: error: expected ‘;’ before ‘outFile’
myZones.C:89: error: ‘outFile’ was not declared in this scope
/opt/openfoam201/src/finiteVolume/lnInclude/initContinuityErrs.H:37: warning: unused variable ‘cumulativeContErr’
make: *** [Make/linux64GccDPOpt/myZones.o] Error 1
alexander@alexander-G50VT:~/OpenFOAM/alexander-2.0.1/applications/myZones$ gedit myZones.C
Basically, what do I need to include to run your code?

Thanks for helping out a newbie.
Can you post the whole app here and I can try to plug the code in? I have tried to attach the .zip of my app to this post. If it doesn't help, post your code and we'll figure it out.

Btw, don't worry about being new to the code, without proper documentation everybody is new to the code, especially if they step out of their "comfort zone".

Best regards,
Tomislav
Attached Files
File Type: zip myCellZone.zip (1.8 KB, 36 views)
tomislav_maric is offline   Reply With Quote

Old   September 20, 2011, 08:10
Default
  #5
Member
 
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 6
bigbang is on a distinguished road
Thanks again T.

When I compile your application (wmake) from my $FOAM_RUN/myCellZone,
I get the following error:
Code:
Making dependency list for source file myCellZone.C
SOURCE=myCellZone.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam201/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/openfoam201/src/OpenFOAM/lnInclude -I/opt/openfoam201/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/myCellZone.o
myCellZone.C: In function ‘int main(int, char**)’:
myCellZone.C:85: error: ‘OFstream’ was not declared in this scope
myCellZone.C:85: error: expected ‘;’ before ‘outFile’
myCellZone.C:86: error: ‘outFile’ was not declared in this scope
make: *** [Make/linux64GccDPOpt/myCellZone.o] Error 1
alexander@alexander-G50VT:~/OpenFOAM/alexander-2.0.1/applications/myCellZone$
bigbang is offline   Reply With Quote

Old   September 20, 2011, 08:15
Default
  #6
Member
 
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 6
bigbang is on a distinguished road
And then if I add: #include "OFstream.H" in the main, I get this error:

Code:
Making dependency list for source file myCellZone.C
SOURCE=myCellZone.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam201/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/openfoam201/src/OpenFOAM/lnInclude -I/opt/openfoam201/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/myCellZone.o
In file included from /usr/include/c++/4.4/fstream:42,
                 from /opt/openfoam201/src/OpenFOAM/lnInclude/OFstream.H:42,
                 from myCellZone.C:42:
/usr/include/c++/4.4/bits/codecvt.h: In function ‘int main(int, char**)’:
/usr/include/c++/4.4/bits/codecvt.h:42: error: expected ‘=’ before ‘__attribute__’
/usr/include/c++/4.4/bits/codecvt.h:42: error: expected identifier before ‘__attribute__’
/usr/include/c++/4.4/bits/codecvt.h:42: error: expected ‘;’ before ‘__attribute__’
/usr/include/c++/4.4/bits/codecvt.h:42: error: expected primary-expression before ‘__attribute__’
/usr/include/c++/4.4/bits/codecvt.h:42: error: expected ‘;’ before ‘__attribute__’
myCellZone.C:95: error: expected ‘}’ at end of input
make: *** [Make/linux64GccDPOpt/myCellZone.o] Error 1
bigbang is offline   Reply With Quote

Old   September 20, 2011, 08:44
Default
  #7
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 245
Blog Entries: 5
Rep Power: 10
tomislav_maric is on a distinguished road
Which OF version are you using? I'm on 1.6-ext.

Quote:
Originally Posted by bigbang View Post
And then if I add: #include "OFstream.H" in the main, I get this error:

Code:
Making dependency list for source file myCellZone.C
SOURCE=myCellZone.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam201/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/openfoam201/src/OpenFOAM/lnInclude -I/opt/openfoam201/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/myCellZone.o
In file included from /usr/include/c++/4.4/fstream:42,
                 from /opt/openfoam201/src/OpenFOAM/lnInclude/OFstream.H:42,
                 from myCellZone.C:42:
/usr/include/c++/4.4/bits/codecvt.h: In function ‘int main(int, char**)’:
/usr/include/c++/4.4/bits/codecvt.h:42: error: expected ‘=’ before ‘__attribute__’
/usr/include/c++/4.4/bits/codecvt.h:42: error: expected identifier before ‘__attribute__’
/usr/include/c++/4.4/bits/codecvt.h:42: error: expected ‘;’ before ‘__attribute__’
/usr/include/c++/4.4/bits/codecvt.h:42: error: expected primary-expression before ‘__attribute__’
/usr/include/c++/4.4/bits/codecvt.h:42: error: expected ‘;’ before ‘__attribute__’
myCellZone.C:95: error: expected ‘}’ at end of input
make: *** [Make/linux64GccDPOpt/myCellZone.o] Error 1
tomislav_maric is offline   Reply With Quote

Old   September 20, 2011, 09:21
Default
  #8
Member
 
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 6
bigbang is on a distinguished road
Hmmm,

I'm on 2.0.1. Don't know why I keep upgrading.. it's nothing but trouble
bigbang is offline   Reply With Quote

Old   September 20, 2011, 10:05
Default
  #9
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 245
Blog Entries: 5
Rep Power: 10
tomislav_maric is on a distinguished road
Quote:
Originally Posted by bigbang View Post
Hmmm,

I'm on 2.0.1. Don't know why I keep upgrading.. it's nothing but trouble

That's where the problem lies.... updates are evil.

I think the only thing differences are in the Make/options file, I haven't used some new fancy functionality or a backward incompatible class...
tomislav_maric is offline   Reply With Quote

Old   September 20, 2011, 10:44
Default
  #10
Member
 
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 6
bigbang is on a distinguished road
Maybe it's possible that you can just post your cellZones file created from the program and I can use it as a template and replace the values for the cell Ids?
bigbang is offline   Reply With Quote

Old   September 20, 2011, 15:06
Default
  #11
Member
 
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 6
bigbang is on a distinguished road
I found a whole pdf on porous Zones. Click here

It says:
"Many porous zones can be added to the case. The number of porous zones is limited to the number
of cell zones in the mesh.
1
(
<cellZoneName>
{
Defintions.
}
)
2
(
<anotherCellZoneName>
{
Defintions.
}
)
"

So my questions is how do you replace "Definitions." with a list of cell IDs to define a zone? Or can you even define a zone with a list of cell IDs?
bigbang is offline   Reply With Quote

Old   September 21, 2011, 06:00
Default
  #12
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 245
Blog Entries: 5
Rep Power: 10
tomislav_maric is on a distinguished road
Here's the 2.0 app. It's in the attachment.

Look at the cellZone constructor: it needs a label list naturally, because the cellZone --> zone --> labelList (check out the doxygen). So, basically, cellZone is a kind of labelList.

Code:
class zone
: public labelList
 { 
    protected:      // Protected data
How will you populate the lists is up to you of course. Have fun!
Attached Files
File Type: zip myCellZone-2.0.zip (1.9 KB, 51 views)
tomislav_maric 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 04:11
Import netgen mesh to OpenFOAM hsieh Open Source Meshers: Gmsh, Netgen, CGNS, ... 32 September 13, 2011 05:50
Include list of points Hikachu OpenFOAM Native Meshers: blockMesh 0 June 20, 2011 09:03
couple cells from different meshes in parallel sylvester OpenFOAM Programming & Development 8 September 29, 2009 04:04
How to output a series of cells for paraFoam view jennyrui2008 OpenFOAM Meshing Format & General Technical 1 December 15, 2008 04:44


All times are GMT -4. The time now is 21:39.