|
[Sponsors] |
Adding Properties to Lagrangian Particle - IOstream problems |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 16, 2017, 11:45 |
Adding Properties to Lagrangian Particle - IOstream problems
|
#1 |
Member
Join Date: Jul 2011
Posts: 54
Rep Power: 15 |
Hi everyone,
I am trying to add some properties to the KinematicParcel class. The constructor I am having problems with is the one in KinematicParcelIO.C: Code:
template<class ParcelType> Foam::KinematicParcel<ParcelType>::KinematicParcel ( const polyMesh& mesh, Istream& is, bool readFields ) : ParcelType(mesh, is, readFields), active_(false), typeId_(0), nParticle_(0.0), d_(0.0), dTarget_(0.0), U_(Zero), rho_(0.0), age_(0.0), tTurb_(0.0), UTurb_(Zero), rhoc_(0.0), Uc_(Zero), muc_(0.0), newVar_(Zero) ... is.read(reinterpret_cast<char*>(&active_), sizeofFields_); ... Code:
template<class ParcelType> const std::size_t Foam::KinematicParcel<ParcelType>::sizeofFields_ ( offsetof(KinematicParcel<ParcelType>, rhoc_) // changing rhoc_ to newVar_ is not working - offsetof(KinematicParcel<ParcelType>, active_) ); Does anybody have any ideas on how to cope with this? Thanks in advance. Best regards, Andreas |
|
October 16, 2017, 14:51 |
|
#2 |
Member
ano
Join Date: Jan 2017
Location: Delft
Posts: 58
Rep Power: 10 |
Hello Andreas,
as far as I understand the sizeofFields gives the size of things you want to read. active_ is your first variable of your parcel properties, it ends before rhoc_ because it is the first cell based variable (and does not come from istream), so it just includes UTurb_ and not rhoc_ anymore. So I would have guessed that adding a new variable to parcel properties should work. At which position did you add your newVar_ in the header file? Do you have to read and write the variable? Or do you calculate it from other variables? Which error does your compiler throw? |
|
October 17, 2017, 05:00 |
|
#3 |
Member
Join Date: Jul 2011
Posts: 54
Rep Power: 15 |
Thanks for your answer!
Yes, that is also kind of my understanding of the sizeofFields_ variable. By using offsetof() you try to give the offset sizes until reaching the regarded variable. I should actually give my full constructor, since I try to add multiple variables multiple variables, which need to be read and written as well. What I have is a combination of the KinematicParcel and the CollidingParcel. Since I had to modify the KinematicParcel and the KinematicCloud, I can not use the template polymorphism between the Colliding and Kinematic classes anymore. Therefore I wanted to put all the extra properties from the Colliding class into the Kinematic class. This works perfectly in a serial run. But not in a parallel run. The error appears, once the described constructor is called, which only seems to be the case for a parallel run. My real constructor looks like this: Code:
template<class ParcelType> Foam::KinematicCollidingParcel<ParcelType>::KinematicCollidingParcel ( const Cloud<KinematicCollidingParcel<ParcelType> >& c, const polyMesh& mesh, Istream& is, bool readFields ) : ParcelType(mesh, is, readFields), oderp_(c), active_(false), typeId_(0), nParticle_(0.0), radius_(0.0), radiusGrowthRate_(0.0), d_(0.0), dTarget_(0.0), R0L_(0.0), U_(Zero), rho_(0.0), age_(0.0), tTurb_(0.0), UTurb_(Zero), pSap_(0.0), pB_(0.0), wallDist_(0.0), f_(Zero), angularMomentum_(Zero), torque_(Zero), collisionRecords_(), rhoc_(0.0), Uc_(Zero), muc_(0.0) {...} The error looks like this: Code:
[3] #1 Foam::sigFpe::sigHandler(int) at ??:? [2] #1 Foam::sigFpe::sigHandler(int) at ??:? [3] #2 ? at ??:? [2] #2 ? in "/lib/x86_64-linux-gnu/libc.so.6" [3] #3 in "/lib/x86_64-linux-gnu/libc.so.6"[2] #3 ?? at /local/OpenFOAM/peters-4.x/src/lagrangianRP/ODE/lnInclude/ODERPI.H:58 [3] #4 Foam::KinematicCollidingParcel<Foam::particle>::KinematicCollidingParcel(Foam::KinematicCollidingParcel<Foam::particle> const&) at /local/OpenFOAM/peters-4.x/src/lagrangianRP/ODE/lnInclude/ODERPI.H:58 [2] #4 Foam::KinematicCollidingParcel<Foam::particle>::KinematicCollidingParcel(Foam::KinematicCollidingParcel<Foam::particle> const&) at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/KinematicCollidingParcel.C:274 (discriminator 2) [3] #5 Foam::KinematicCollidingParcel<Foam::particle>::clone() const at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/KinematicCollidingParcel.C:274 (discriminator 2) [2] #5 Foam::KinematicCollidingParcel<Foam::particle>::clone() const at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/KinematicCollidingParcel.H:473 (discriminator 2) [3] #6 Foam::ILList<Foam::DLListBase, Foam::KinematicCollidingParcel<Foam::particle> >::operator=(Foam::ILList<Foam::DLListBase, Foam::KinematicCollidingParcel<Foam::particle> > const&) at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/KinematicCollidingParcel.H:473 (discriminator 2) [2] #6 Foam::ILList<Foam::DLListBase, Foam::KinematicCollidingParcel<Foam::particle> >::operator=(Foam::ILList<Foam::DLListBase, Foam::KinematicCollidingParcel<Foam::particle> > const&) at /local/OpenFOAM/OpenFOAM-4.x/src/OpenFOAM/lnInclude/ILList.C:146 [3] #7 Foam::InteractionLists<Foam::KinematicCollidingParcel<Foam::particle> >::receiveReferredData(Foam::PstreamBuffers&, int) at /local/OpenFOAM/OpenFOAM-4.x/src/OpenFOAM/lnInclude/ILList.C:146 [2] #7 Foam::InteractionLists<Foam::KinematicCollidingParcel<Foam::particle> >::receiveReferredData(Foam::PstreamBuffers&, int) at /local/OpenFOAM/OpenFOAM-4.x/src/OpenFOAM/lnInclude/IDLList.H:48 [3] #8 Foam::PairCollision<Foam::KinematicCollidingCloud<Foam::Cloud<Foam::KinematicCollidingParcel<Foam::particle> > > >::parcelInteraction() at /local/OpenFOAM/OpenFOAM-4.x/src/OpenFOAM/lnInclude/IDLList.H:48 [2] #8 Foam::PairCollision<Foam::KinematicCollidingCloud<Foam::Cloud<Foam::KinematicCollidingParcel<Foam::particle> > > >::parcelInteraction() at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/PairCollision.C:79 [3] #9 Foam::PairCollision<Foam::KinematicCollidingCloud<Foam::Cloud<Foam::KinematicCollidingParcel<Foam::particle> > > >::collide() at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/PairCollision.C:79 [2] #9 Foam::PairCollision<Foam::KinematicCollidingCloud<Foam::Cloud<Foam::KinematicCollidingParcel<Foam::particle> > > >::collide() at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/PairCollision.C:751 [3] #10 ? at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/KinematicCollidingCloud.C:125 [3] #11 ? at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/PairCollision.C:751 [2] #10 ? at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/KinematicCollidingCloud.C:834 [3] #12 ? at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/KinematicCollidingCloud.C:247 [3] #13 at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/KinematicCollidingCloud.C:125 [2] #11 ?? at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/KinematicCollidingCloud.C:155 [3] #14 ? at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/KinematicCollidingCloud.C:834 [2] #12 ? at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/KinematicCollidingCloud.C:783 [3] #15 ? at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/KinematicCollidingCloud.C:247 [2] #13 ? at /local/OpenFOAM/peters-4.x/src/lagrangianRP/interPhaseChangeCollidingParcelFoam/interPhaseChangeCollidingParcelFoam.C:98 [3] #16 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6" [3] #17 ? at ??:? [prop-04:06264] *** Process received signal *** [prop-04:06264] Signal: Floating point exception (8) [prop-04:06264] Signal code: (-6) [prop-04:06264] Failing at address: 0x7f100001878 [prop-04:06264] [ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x350e0) [0x7fc60d2470e0] [prop-04:06264] [ 1] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x37) [0x7fc60d247067] [prop-04:06264] [ 2] /lib/x86_64-linux-gnu/libc.so.6(+0x350e0) [0x7fc60d2470e0] [prop-04:06264] [ 3] interPhaseChangeCollidingParcelFoam() [0x4f6507] [prop-04:06264] [ 4] interPhaseChangeCollidingParcelFoam(_ZN4Foam24KinematicCollidingParcelINS_8particleEEC2ERKS2_+0x51) [0x4ed25f] [prop-04:06264] [ 5] interPhaseChangeCollidingParcelFoam(_ZNK4Foam24KinematicCollidingParcelINS_8particleEE5cloneEv+0x2f) [0x4e329f] [prop-04:06264] [ 6] interPhaseChangeCollidingParcelFoam(_ZN4Foam6ILListINS_10DLListBaseENS_24KinematicCollidingParcelINS_8particleEEEEaSERKS5_+0x55) [0x4d7a6d] [prop-04:06264] [ 7] /local/OpenFOAM/peters-4.x/platforms/linux64GccDPInt32Opt/lib/liblagrangianRPIntermediate.so(_ZN4Foam16InteractionListsINS_24KinematicCollidingParcelINS_8particleEEEE19receiveReferredDataERNS_14PstreamBuffersEi+0x265) [0x7fc615095395] [prop-04:06264] [ 8] /local/OpenFOAM/peters-4.x/platforms/linux64GccDPInt32Opt/lib/liblagrangianRPIntermediate.so(_ZN4Foam13PairCollisionINS_23KinematicCollidingCloudINS_5CloudINS_24KinematicCollidingParcelINS_8particleEEEEEEEE17parcelInteractionEv+0xe7) [0x7fc615098bd7] [prop-04:06264] [ 9] /local/OpenFOAM/peters-4.x/platforms/linux64GccDPInt32Opt/lib/liblagrangianRPIntermediate.so(_ZN4Foam13PairCollisionINS_23KinematicCollidingCloudINS_5CloudINS_24KinematicCollidingParcelINS_8particleEEEEEEEE7collideEv+0x38) [0x7fc615098ce8] [prop-04:06264] [10] interPhaseChangeCollidingParcelFoam() [0x4c4138] [prop-04:06264] [11] interPhaseChangeCollidingParcelFoam() [0x4af0b2] [prop-04:06264] [12] interPhaseChangeCollidingParcelFoam() [0x49a3dc] [prop-04:06264] [13] interPhaseChangeCollidingParcelFoam() [0x483b58] [prop-04:06264] [14] interPhaseChangeCollidingParcelFoam() [0x46b9d6] [prop-04:06264] [15] interPhaseChangeCollidingParcelFoam() [0x452b27] [prop-04:06264] [16] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7fc60d233b45] [prop-04:06264] [17] interPhaseChangeCollidingParcelFoam() [0x44c569] [prop-04:06264] *** End of error message *** at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/KinematicCollidingCloud.C:155 [2] #14 ?-------------------------------------------------------------------------- mpirun noticed that process rank 3 with PID 6264 on node prop-04 exited on signal 8 (Floating point exception). Code:
forAll(constructMap, i) { //here I can see the Pout message on the aborting processor referredParticles_[constructMap[i] = IDLList<ParticleType> ( str, typename ParticleType::iNew(cloud_, mesh_) ); } Thanks in advance! |
|
October 17, 2017, 06:52 |
|
#4 |
Member
ano
Join Date: Jan 2017
Location: Delft
Posts: 58
Rep Power: 10 |
What I am a little bit confused about is that it seems that the floating point exception happens as far as I can see in a copy constructor.
So my first uneducated guess would be: during parallel run parcels have to be copied and somehow that doesn't work, perhaps the copy constructor doesn't match the class anymore. For floating point exception we either have a division by zero or an overflow when a variable cannot be represented by the data type. Both don't seem very likely in a copy constructor. And you write that the Info statements showed you that it happens in the istream constructor. If it is due to sizeofFields, it wouldn't appear for an ASCII istream, is that correct? You seem to have compiled the code in debugging mode. Did you try gdb to see which variable throws fpe? |
|
October 17, 2017, 08:25 |
|
#5 |
Member
Join Date: Jul 2011
Posts: 54
Rep Power: 15 |
Thanks for your answer again.
I do not really know how to get the istream as ASCII. It does not depend on the writeFormat, right? Because I have set this to ASCII for all my tests already. Because of your explanation I had a look at the two different versions for sizeofFields_ now and they give different errors: version 1: Code:
template<class ParcelType> const std::size_t Foam::KinematicCollidingParcel<ParcelType>::sizeofFields_ ( offsetof(KinematicCollidingParcel<ParcelType>, rhoc_) - offsetof(KinematicCollidingParcel<ParcelType>, active_) ) Code:
at ??:? at ??:? [2] #1 Foam::sigSegv::sigHandler(int)[3] #1 Foam::sigSegv::sigHandler(int) at ??:? [3] #2 ? at ??:? [2] #2 ? in "/lib/x86_64-linux-gnu/libc.so.6" in "/lib/x86_64-linux-gnu/libc.so.6"[2] #3 [3] #3 ?? at /local/OpenFOAM/OpenFOAM-4.x/src/OpenFOAM/lnInclude/List.C:358 (discriminator 2) [3] #4 at /local/OpenFOAM/OpenFOAM-4.x/src/OpenFOAM/lnInclude/List.C:358 (discriminator 2) [2] #4 Foam::List<Foam::PairCollisionRecord<Foam::Vector<double> > >::setSize(int)Foam::List<Foam::PairCollisionRecord<Foam::Vector<double> > >::setSize(int) at /local/OpenFOAM/OpenFOAM-4.x/src/OpenFOAM/ lnInclude/List.C:334 [2] #5 Foam::Istream& Foam::operator>><Foam::PairCollisionRecord<Foam::Vector<double> > >(Foam::Istream&, Foam::List<Foam::PairCollisionRecord<Foam::Vector<double> > >&) at /local/OpenFOAM/OpenFOAM-4.x/src/ OpenFOAM/lnInclude/List.C:334 [3] #5 Foam::Istream& Foam::operator>><Foam::PairCollisionRecord<Foam::Vector<double> > >(Foam::Istream&, Foam::List<Foam::PairCollisionRecord<Foam::Vector<double> > >&) at /local/OpenFOAM/OpenFOAM-4.x/src/ OpenFOAM/lnInclude/ListIO.C:49 [2] #6 ? at /local/OpenFOAM/OpenFOAM-4.x/src/OpenFOAM/lnInclude/ListIO.C:49 [3] #6 ? at /local/OpenFOAM/OpenFOAM-4.x/src/OpenFOAM/lnInclude/DynamicList.C:59 [2] #7 ? at /local/OpenFOAM/OpenFOAM-4.x/src/OpenFOAM/lnInclude/DynamicList.C:59 [3] #7 ? at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/CollisionRecordList.C:449 and version 2: Code:
template<class ParcelType> const std::size_t Foam::KinematicCollidingParcel<ParcelType>::sizeofFields_ ( offsetof(KinematicCollidingParcel<ParcelType>, collisionRecords_) - offsetof(KinematicCollidingParcel<ParcelType>, active_) ) Code:
at ??:? [3] #1 Foam::sigFpe::sigHandler(int) at ??:? [2] #1 Foam::sigFpe::sigHandler(int) at ??:? [3] #2 ? in "/lib/x86_64-linux-gnu/libc.so.6" [3] #3 at ??:? [2] #2 ?? in "/lib/x86_64-linux-gnu/libc.so.6" [2] #3 ? at /local/OpenFOAM/peters-4.x/src/lagrangianRP/ODE/lnInclude/ODERPI.H:58 [3] #4 Foam::KinematicCollidingParcel<Foam::particle>::KinematicCollidingParcel(Foam::KinematicCollidingParcel<Foam::particle> const&) at /local/OpenFOAM/peters-4.x/src/lagrangianRP/ODE/lnInclude/ODERPI.H:58 [2] #4 Foam::KinematicCollidingParcel<Foam::particle>::KinematicCollidingParcel(Foam::KinematicCollidingParcel<Foam::particle> const&) at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/ KinematicCollidingParcel.C:274 (discriminator 2) [3] #5 Foam::KinematicCollidingParcel<Foam::particle>::clone() const at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/KinematicCollidingParcel.C:274 (discriminator 2) [2] #5 Foam::KinematicCollidingParcel<Foam::particle>::clone() const at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/KinematicCollidingParcel.H:473 (discriminator 2) [3] #6 Foam::ILList<Foam::DLListBase, Foam::KinematicCollidingParcel<Foam::particle> >::operator=(Foam::ILList<Foam::DLListBase, Foam::KinematicCollidingParcel<Foam::particle> > const&) at /local/OpenFOAM/ peters-4.x/src/lagrangianRP/intermediate/lnInclude/KinematicCollidingParcel.H:473 (discriminator 2) [2] #6 Foam::ILList<Foam::DLListBase, Foam::KinematicCollidingParcel<Foam::particle> >::operator=(Foam::ILList<Foam::DLListBase, Foam::KinematicCollidingParcel<Foam::particle> > const&) at /local/OpenFOAM/ OpenFOAM-4.x/src/OpenFOAM/lnInclude/ILList.C:146 [3] #7 Foam::InteractionLists<Foam::KinematicCollidingParcel<Foam::particle> >::receiveReferredData(Foam::PstreamBuffers&, int) at /local/OpenFOAM/OpenFOAM-4.x/src/OpenFOAM/lnInclude/ILList.C:146 [2] #7 Foam::InteractionLists<Foam::KinematicCollidingParcel<Foam::particle> >::receiveReferredData(Foam::PstreamBuffers&, int) at /local/OpenFOAM/OpenFOAM-4.x/src/OpenFOAM/lnInclude/IDLList.H:48 [3] #8 Foam::PairCollision<Foam::KinematicCollidingCloud<Foam::Cloud<Foam::KinematicCollidingParcel<Foam::particle> > > >::parcelInteraction() at /local/OpenFOAM/OpenFOAM-4.x/src/OpenFOAM/lnInclude/IDLList.H:48 [2] #8 Foam::PairCollision<Foam::KinematicCollidingCloud<Foam::Cloud<Foam::KinematicCollidingParcel<Foam::particle> > > >::parcelInteraction() at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/ lnInclude/PairCollision.C:79 [2] #9 Foam::PairCollision<Foam::KinematicCollidingCloud<Foam::Cloud<Foam::KinematicCollidingParcel<Foam::particle> > > >::collide() at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/ PairCollision.C:79 [3] #9 Foam::PairCollision<Foam::KinematicCollidingCloud<Foam::Cloud<Foam::KinematicCollidingParcel<Foam::particle> > > >::collide() at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/ PairCollision.C:751 [2] #10 ? at /local/OpenFOAM/peters-4.x/src/lagrangianRP/intermediate/lnInclude/PairCollision.C:751 This looks to me like one of them reserves the correct size for the istream and is crashing in another part of the code and one just gets the wrong size in here. I tried to work with gdb, but since it is a parallel run I don't really know how to debug properly. I tried the mpirunDebug, but I don't get any error messages in the log files of the different processors. |
|
May 24, 2018, 14:53 |
|
#6 |
Member
Joaquín Neira
Join Date: Oct 2017
Posts: 38
Rep Power: 9 |
Hi,
I had the same issue and I solved it by moving my new variable up in the constructor (new variables are vectorList and scalarList types Code:
ParcelType(mesh, is, readFields), active_(false), typeId_(0), nParticle_(0.0), d_(0.0), dTarget_(0.0), U_(Zero), rho_(0.0), age_(0.0), tTurb_(0.0), UTurb_(Zero), dtList_(), UrList_(), rhoc_(0.0), Uc_(Zero), muc_(0.0) Code:
template<class ParcelType> const std::size_t Foam::KinematicParcel<ParcelType>::sizeofFields_ ( offsetof(KinematicParcel<ParcelType>, dtList_) - offsetof(KinematicParcel<ParcelType>, active_) ); |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Post processing of Lagrangian particle field | marialhm | OpenFOAM Post-Processing | 0 | October 8, 2017 23:02 |
[swak4Foam] Validation of swak4Foam for lagrangian particle tracking | nero235 | OpenFOAM Community Contributions | 13 | March 28, 2017 06:45 |
OpenFOAM lagrangian particle tracking solver C++ developer needed | hampycalc | CFD Freelancers | 1 | May 18, 2016 09:46 |
Particle Reynolds number calculation in Lagrangian tracking? | jiejie | OpenFOAM Running, Solving & CFD | 5 | July 6, 2012 05:47 |
DPM UDF particle position using the macro P_POS(p)[i] | dm2747 | FLUENT | 0 | April 17, 2009 02:29 |