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

Lagrangian particle face IDs wrongly printed

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 27, 2018, 16:09
Default Lagrangian particle face IDs wrongly printed
  #1
Member
 
Join Date: Oct 2015
Posts: 63
Rep Power: 10
Scram_1 is on a distinguished road
Hi,
I'm doing some Lagrangian particle tracking simulations for which I'm using icoUncoupledKinematicParcelFoam. When I look at the files generated within each time step folder at the end of the simulation, the 'positions' file has the position of the parcel and also the cell IDs. I want to change the code a bit to print out the face IDs instead of the cell IDs. I managed to do this by changing the particleIO.C file in src/lagrangian/basic/particle. Now, when I use > 1 processor, i.e. I run a parallel case, the reconstructed folders contain the 'positions' file in the Lagrangian folder but now instead of the face IDs being printed beside the particle positions, '-1' gets printed for all the particles. However, in the 'positions' file inside each processor folder, I can see the face IDs of particles being printed correctly. I don't know why the reconstructed case folder is not able to print these. I've attached my modified particleIO.C file below.

Code:
#include "particle.H"
#include "IOstreams.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

Foam::string Foam::particle::propertyList_  = Foam::particle::propertyList();
Foam::string Foam::particle::propertyTypes_ = Foam::particle::propertyTypes();

const std::size_t Foam::particle::sizeofPosition_
(
    offsetof(particle, facei_) - offsetof(particle, position_)
);

const std::size_t Foam::particle::sizeofFields
(
    sizeof(particle) - offsetof(particle, position_)
);


// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

Foam::particle::particle(const polyMesh& mesh, Istream& is, bool readFields)
:
    mesh_(mesh),
    position_(),
    celli_(-1),
    facei_(-1),
    stepFraction_(0.0),
    tetFacei_(-1),
    tetPti_(-1),
    origProc_(Pstream::myProcNo()),
    origId_(-1)
{
    if (is.format() == IOstream::ASCII)
    {
        is  >> position_ >> facei_;

        if (readFields)
        {
            is  >> facei_
                >> stepFraction_
                >> tetFacei_
                >> tetPti_
                >> origProc_
                >> origId_;
        }
    }
    else
    {
        if (readFields)
        {
            is.read(reinterpret_cast<char*>(&position_), sizeofFields);
        }
        else
        {
            is.read(reinterpret_cast<char*>(&position_), sizeofPosition_);
        }
    }

    // Check state of Istream
    is.check(FUNCTION_NAME);
}


void Foam::particle::writePosition(Ostream& os) const
{
    if (os.format() == IOstream::ASCII)
    {
        os  << position_ << token::SPACE << facei_ ;
    }
    else
    {
        os.write(reinterpret_cast<const char*>(&position_), sizeofPosition_);
    }

    // Check state of Ostream
    os.check(FUNCTION_NAME);
}


Foam::Ostream& Foam::operator<<(Ostream& os, const particle& p)
{
    if (os.format() == IOstream::ASCII)
    {
        os  << p.position_
            << token::SPACE << p.celli_
            << token::SPACE << p.facei_
            << token::SPACE << p.stepFraction_
            << token::SPACE << p.tetFacei_
            << token::SPACE << p.tetPti_
            << token::SPACE << p.origProc_
            << token::SPACE << p.origId_;
    }
    else
    {
        os.write
        (
            reinterpret_cast<const char*>(&p.position_),
            particle::sizeofFields
        );
    }

    return os;
}


// ************************************************************************* //
The particle positions and face IDs inside processor 1 folder is shown below.
(Only a few particle positions and face IDs are shown below for brevity)
Code:
(
(-0.001918232865 -0.002251041706 0.004467126053) -1
(0.001497556868 -0.002574867247 0.003103300752) -1
(0.001515351194 -0.002588116818 4.202558253e-05) 146613
(-0.001183838869 -0.002734988904 0.003129143429) -1
(-0.00287581985 -0.0006375774439 0.00465495688) -1
(0.0008197242898 -0.002883032753 0.0002544101809) 142108
(-0.002801806174 -0.0009609295494 0.003555561927) -1
(-0.002827043845 -0.0009907898813 9.971039645e-05) 142068
(-0.0004006887624 -0.002950641738 0.00333011665) -1
(-0.001155982476 -0.002762901972 0.001563768784) 145565
(-0.00209560257 -0.002098639602 0.004079087052) -1
(0.001702999671 -0.002467776191 9.921843668e-05) 142113
And here is the reconstructed case with -1 being printed instead of the face IDs
Code:
(
(0.001503063296 -0.002432560028 0.009707915638) -1
(-0.001488287737 -0.002425862592 0.01028831296) -1
(-0.001613665466 -0.002351394638 0.01007192092) -1
(0.002273814785 -0.001745515031 0.009180543596) -1
(0.0006383612319 -0.002784751294 0.01002237924) -1
(0.002282777511 -0.001734923566 0.009138315696) -1
(0.002224614027 -0.001807140708 0.009203291626) -1
(0.0006227818597 -0.002791883515 0.009895327087) -1
(0.001862071026 -0.002166846251 0.009715677211) -1
(0.001459660893 -0.002460366998 0.009635536246) -1
(0.001888048648 -0.002144299877 0.009675871161) -1
(0.001871450245 -0.002160270873 0.009639408655) -1
(0.002254906134 -0.001772654796 0.009098633124) -1
(0.00154276372 -0.00241127332 0.009628450194) -1
(-0.001597582009 -0.002364443428 0.0100017453) -1
(0.001445232902 -0.002470776606 0.00957249016) -1
(-0.001493946214 -0.002425353115 0.01014971087) -1
(-0.001745678363 -0.002248147321 0.01035737724) -1
(0.001332290771 -0.002531094927 0.009757621791) -1
(-0.0008148733303 -0.002732127004 0.01022249142) -1
(-0.001762640206 -0.002234234694 0.01037401675) -1
(0.001750882135 -0.002261121501 0.009598710578) -1
(0.001576125126 -0.002389037127 0.009674199296) -1
(0.0004683611948 -0.002815714577 0.01005009407) -1
(5.060516259e-05 -0.002850537259 0.01025520226) -1
(-0.002772284988 0.0006477009081 0.009738074612) -1
All the particles have -1 listed as their face ID in the reconstructed folder. Is this some problem with reconstructPar or do I have to make some other changes to get it to work properly in parallel? With cell IDs (which is what OF prints beside the particle positions by default) even the reconstructed folder prints the correct cell ID.
Any help is greatly appreciated.

Best,
Scram_1
Scram_1 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
[blockMesh] Internal walls of zero thickness anger OpenFOAM Meshing & Mesh Conversion 23 February 6, 2020 18:25
[swak4Foam] Validation of swak4Foam for lagrangian particle tracking nero235 OpenFOAM Community Contributions 13 March 28, 2017 05:45
[blockMesh] BlockMesh FOAM warning gaottino OpenFOAM Meshing & Mesh Conversion 7 July 19, 2010 14:11
[blockMesh] BlockMeshmergePatchPairs hjasak OpenFOAM Meshing & Mesh Conversion 11 August 15, 2008 07:36
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 11:55


All times are GMT -4. The time now is 15:24.