|
[Sponsors] |
May 28, 2021, 01:20 |
Write out labelListList cellCells()
|
#1 |
New Member
Sam Douglass
Join Date: Jun 2020
Posts: 2
Rep Power: 0 |
Hello all,
I am attempting to write out cell center connectivity to a file. I started with the foamToFluent utility and modified it according to my needs. However, my C++ and research skills are rapidly running out. From All cells connected via edge to cell. and https://jibranhaider.com/blog/mesh-i...connectivities I know that I need to access cellCells() and that it is a labelListList. My understanding is that this is a list of lists, which makes sense. The section of my code indented to write this information to file is below. When compiling I am getting an error relating to, I believe, a mismatch in expected data type for the ```edge_list << neighbour[celli] ``` command. This error message is shown below. I think my lack of understanding of labelListList is the root cause of this error. And after some exhaustive searching I am not sure of where to go from here. I would greatly appreciate help in understanding what I am doing wrong. I can easily imagine that naively calling cellCells()[celli] is not how I should go about this, but without knowing the structure of cellCells I am left to guess. Any help is greatly appreciated, thank you, - Sam Compiler error message: Code:
error: no match for ‘operator<<’ (operand types are ‘std::basic_ostream<char>’ and ‘const Foam::List<int>’) edge_list << " " << neighbour[celli]; Code:
// Open a file for the edges std::ofstream edge_list ( time().rootPath() / time().caseName() / "graph" / "edges.txt" ); Info<< "Writing edges.txt" << endl; // Writing cells based on neighbors const labelListList neighbour = this->mesh.cellCells(); // Writing number of cells edge_list << "(" << nCells() << ")" << std::endl; edge_list << "("; forAll(neighbour, celli) { edge_list << " " << neighbour[celli]; edge_list << "\n"; } edge_list << ")" << std::endl; |
|
May 31, 2021, 01:55 |
|
#2 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,686
Rep Power: 40 |
Using OFstream instead of std :: ofstream will work better.
BTW you should not be taking a copy when you obtain the cellCells() - use a const ref instead. The structure of labelListList is in the name - a list of lists of labels. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to write UDF programme inside FLUENT? | coolyihao | Fluent UDF and Scheme Programming | 9 | June 5, 2016 21:08 |
Have only process 0 write data | syavash | OpenFOAM Running, Solving & CFD | 1 | November 3, 2015 06:05 |
Write control: write only U field | ezekiel | OpenFOAM Running, Solving & CFD | 0 | January 27, 2015 17:59 |
Phase locked average in run time | panara | OpenFOAM | 2 | February 20, 2008 14:37 |
Problem when I try to write the geometry file | massimo | Siemens | 0 | January 14, 2003 04:58 |