|
[Sponsors] |
July 22, 2019, 16:07 |
Example of sending a struct over a Pstream?
|
#1 |
New Member
Gavin Ridley
Join Date: Jan 2019
Location: Tennessee, USA
Posts: 25
Rep Power: 7 |
Hi all,
I am working on a solver where I have some structs (just a few pieces of data, about 5 integers and a handful of booleans) that sometimes need to be sent across processor boundaries. It's being used to track whether cells are in the vicinity of the liquid/gas interface in VOF calculations. Can anyone point me to an example of sending a new struct or class using Pstreams? From what I have gathered, you just need to defined a operator>> and operator<< for the IPStream and OPstreams, but I seem to have made a mistake in doing this. In particular, I'm confused about the order that stuff in the struct should be packed and unpacked into the Pstream. I can provide an example of what my current code looks like if needed. The specific error which arises is a segfault. |
|
July 23, 2019, 12:03 |
|
#2 |
New Member
Gavin Ridley
Join Date: Jan 2019
Location: Tennessee, USA
Posts: 25
Rep Power: 7 |
For anyone else who encounters an issue with this, the solution is to make something look like this:
Code:
struct ProcessorRequest { label swagLevel; label originalProcessor; label neighborProcessor; Pair<bool> result; bool done; }; Ostream& operator<<(Ostream& os, const ProcessorRequest& pr) { os << pr.swagLevel; << pr.originalProcessor; << pr.neighborProcessor; << pr.result; << pr.done; return os; } Istream& operator>>(Istream& is, ProcessorRequest& me) { is >> me.swagLevel >> me.originalProcessor >> me.neighborProcessor >> me.depth >> me.result >> me.done; return is; } |
|
Tags |
pstream library, pstreams |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
big difference between clockTime and executionTime | LM4112 | OpenFOAM Running, Solving & CFD | 21 | February 15, 2019 04:05 |
long error when using make-install SU2_AD. | tomp1993 | SU2 Installation | 3 | March 17, 2018 07:25 |
Sending a large bufffer between processes (with Pstream?) | knuckles | OpenFOAM Programming & Development | 4 | January 11, 2016 20:55 |
Accessing phi from a fvPatchField at same patch | johndeas | OpenFOAM | 1 | September 13, 2010 21:23 |
[Netgen] Compiling Netgen on Fedora Core is driving me crazy | jango | OpenFOAM Meshing & Mesh Conversion | 3 | November 9, 2007 14:29 |