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

Write out labelListList cellCells()

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 28, 2021, 01:20
Default Write out labelListList cellCells()
  #1
New Member
 
Sam Douglass
Join Date: Jun 2020
Posts: 2
Rep Power: 0
Tallac is on a distinguished road
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:



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;
Tallac is offline   Reply With Quote

Old   May 31, 2021, 01:55
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,686
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
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.
olesen is offline   Reply With Quote

Reply


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


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


All times are GMT -4. The time now is 06:10.