|
[Sponsors] |
[mesh manipulation] How to create a cellZone from a list of cells? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 16, 2011, 15:43 |
How to create a cellZone from a list of cells?
|
#1 |
Member
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 16 |
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? |
|
September 17, 2011, 08:49 |
|
#2 | |
Senior Member
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21 |
Quote:
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); What i find interesting is that the Code:
cellZone Code:
cellZoneMesh Code:
cellZone Hope this is of any help... T. |
||
September 19, 2011, 12:11 |
|
#3 |
Member
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 16 |
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 Thanks for helping out a newbie. |
|
September 19, 2011, 17:01 |
|
#4 | |
Senior Member
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21 |
Quote:
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 |
||
September 20, 2011, 09:10 |
|
#5 |
Member
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 16 |
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$ |
|
September 20, 2011, 09:15 |
|
#6 |
Member
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 16 |
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 |
|
September 20, 2011, 09:44 |
|
#7 | |
Senior Member
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21 |
Which OF version are you using? I'm on 1.6-ext.
Quote:
|
||
September 20, 2011, 10:21 |
|
#8 |
Member
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 16 |
Hmmm,
I'm on 2.0.1. Don't know why I keep upgrading.. it's nothing but trouble |
|
September 20, 2011, 11:05 |
|
#9 | |
Senior Member
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21 |
Quote:
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... |
||
September 20, 2011, 11:44 |
|
#10 |
Member
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 16 |
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?
|
|
September 20, 2011, 16:06 |
|
#11 |
Member
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 16 |
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? |
|
September 21, 2011, 07:00 |
|
#12 |
Senior Member
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21 |
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. How will you populate the lists is up to you of course. Have fun! |
|
January 22, 2024, 17:22 |
create a cellZone from a list of cells
|
#13 |
New Member
Shenhui Ruan
Join Date: Nov 2021
Location: Karlsruhe
Posts: 16
Rep Power: 5 |
A very delayed answer; I think the people in the post don't need the code. But I have such a problem, and I found a way to solve it. I hope it is helpful. Please contact me if anyone wants to discuss this.
Code:
// Initialise OF case #include "setRootCase.H" // These two create the time system (instance called runTime) and fvMesh (instance called mesh). #include "createTime.H" #include "createMesh.H" List<label> selectCellList; // add your procedure to append the list if (xxx) { selectCellList.append(cellid) } mesh.cellZones().append ( new cellZone ( "selectCellZone", selectCellList, // index, the max index of original cellzones is "size-1". // The value is used as only a cellzone is added mesh.cellZones().size(), mesh.cellZones() ) ); mesh.cellZones().write(); |
|
June 28, 2024, 12:26 |
|
#14 |
Member
Zeinab
Join Date: Feb 2023
Posts: 32
Rep Power: 3 |
Hello,
Yess I need a quicker way to create the cellZone from a labelList. Thanks |
|
June 28, 2024, 19:03 |
|
#15 |
New Member
Shenhui Ruan
Join Date: Nov 2021
Location: Karlsruhe
Posts: 16
Rep Power: 5 |
Hello Zeinab,
I am sorry that I don't understand what you mean of a quicker way. I think my code is not complicated. If you want to read a labellist from a file and then add a cellzone. I suggest you use IOList<T> to read and then modify the code I posted before. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[ICEM] Error in mesh writing | helios | ANSYS Meshing & Geometry | 21 | August 19, 2021 15:18 |
[swak4Foam] funkyDoCalc with OF2.3 massflow | NiFl | OpenFOAM Community Contributions | 14 | November 25, 2020 04:30 |
how to set periodic boundary conditions | Ganesh | FLUENT | 15 | November 18, 2020 07:09 |
cellZone not taking all the cells inside | rahulksoni | OpenFOAM Running, Solving & CFD | 6 | January 25, 2019 01:11 |
[Netgen] Import netgen mesh to OpenFOAM | hsieh | OpenFOAM Meshing & Mesh Conversion | 32 | September 13, 2011 06:50 |