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

foamFormatConvert corrupts origId and origProcId

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 27, 2023, 05:31
Default foamFormatConvert corrupts origId and origProcId
  #1
New Member
 
Join Date: May 2020
Posts: 29
Blog Entries: 1
Rep Power: 6
Mars409 is on a distinguished road
foamFormatConvert is an OpenFOAM utility to convert a case's simulation results btwn binary and ASCII, depending on what system/controlDict specifies for writeFormat. But in v10 it corrupts the origId and origProcId files.



The problem is fixed by adding a line to call particle::readFields(parcels):
Code:
forAll(cloudDirs, i)
            {
                fileName dir(cloud::prefix/cloudDirs[i]);

                Cloud<passiveParticle> parcels(meshPtr(), cloudDirs[i], false);

                particle::readFields(parcels); // [Bug fix] write origId and origProcId

                parcels.writeObject
                (
                    runTime.writeFormat(),
                    IOstream::currentVersion,
                    runTime.writeCompression(),
                    parcels.size()
                );
The cause of the bug is the the constructor of Cloud only picks up the positions file to build a particle list, leaving the origId and origProc lists uninitalized. particle::readFields(parcels) (a static function call) takes care of this.
Mars409 is offline   Reply With Quote

Old   December 19, 2023, 03:18
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
This has been raised as an issue
https://develop.openfoam.com/Develop.../-/issues/3051
should also be solved now in time for the OpenFOAM-v2312 release.
olesen is offline   Reply With Quote

Old   December 19, 2023, 03:33
Default
  #3
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by Mars409 View Post
foamFormatConvert is an OpenFOAM utility to convert a case's simulation results btwn binary and ASCII, depending on what system/controlDict specifies for writeFormat.

The preferred fixed code:


Code:
// OLD:     Cloud<passiveParticle> parcels(meshPtr(), cloudDirs[i], false);
// NEW     - with readFields = true
                passiveParticleCloud parcels(meshPtr(), cloudDirs[i], true);
Changing to passiveParticleCloud exposes the readFields directly.
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



All times are GMT -4. The time now is 01:51.