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

Parallel: FOAM FATAL IO ERROR: compound has already been transferred from token

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 25, 2023, 02:05
Default Parallel: FOAM FATAL IO ERROR: compound has already been transferred from token
  #1
New Member
 
Xiangjie Wang
Join Date: Jul 2019
Posts: 26
Rep Power: 7
XJ_Wang is on a distinguished road
Hi foamers:

I developed an inlet boundary condition for velocity, but can not run it in parallel.

In 0/U, I defined my inlet as:
Code:
inlet
    {
         type            DSRFGVelocity;
         M              600;
         N              100;
        uref            22.5091;
        alpha           0.1538;
        zref            1.3860;
        inflowPar       pkqomega;
        value           uniform (0 0 0);

    }
Then with a good mesh, I run:
Code:
decomposePar
mpirun -np xx renumberMesh -overwrite -parallel
It shows the error message:
Code:
[1] --> FOAM FATAL IO ERROR:
[1] compound has already been transferred from token
    on line 33 the empty compound of type List<vector>
[1]
[1] file: /ddnA/work/xxxx/DSRFGinflow/processor1/0/U.boundaryField.inlet.value at line 33.
[1]
[1]     From function Foam::token::compound& Foam::token::transferCompoundToken(const Foam::Istream&)
[1]     in file lnInclude/token.C at line 99.
[1]
FOAM parallel run aborting
Then I go to the file in processor1/0/U,

It is:
Code:
 inlet
    {
        type            DSRFGVelocity;
        M               600;
        N               100;
        zref            1.386;
        alpha           0.1538;
        uref            22.5091;
        inflowPar       pkqomega;
        value           nonuniform List<vector>   // this is line 33
1086
(
(29.289282 3.8500723 -1.4503862)
(29.288161 3.8519444 -1.450854)
(29.287024 3.8538043 -1.4513087)

My updateCoeffs() function in my source code looks like:
Code:
void Foam::DSRFGVelocityFvPatchVectorField::updateCoeffs()
{
    if (this->updated())
    {
        return;
    }
    if (curTimeIndex_ != this->db().time().timeIndex())
    {


    xxxxxxxxxx some calculation procedure

    this->operator==(Utotal);
    curTimeIndex_ = this->db().time().timeIndex();
    }
    fixedValueFvPatchVectorField::updateCoeffs();
}

Can anyone help me with this?
XJ_Wang is offline   Reply With Quote

Old   March 27, 2023, 04:10
Default
  #2
New Member
 
Sergey Lesnik
Join Date: Mar 2015
Posts: 14
Rep Power: 11
serles is on a distinguished road
Something is wrong with the I/O. During reading of fields from the disk, OpenFOAM constructs a dictionary from the file (processor1/0/U in your case), where the Lists are stored as compoundToken (since dictionary is able to work only with tokens). In the next step, this dictionary is supplied to the GeometricField constructor, whereby the List is transferred (not read from disk because it's already in memory) to the GeometricField instance.

I assume you didn't change the source code of renumberMesh. So the problem should be somewhere within the reading operations of your boundary condition. Can you provide the related members like "read" or "operator>>" from you BC?
serles is offline   Reply With Quote

Old   March 27, 2023, 22:16
Default
  #3
New Member
 
Xiangjie Wang
Join Date: Jul 2019
Posts: 26
Rep Power: 7
XJ_Wang is on a distinguished road
Hi Sergey ,

Thanks for your reply. To be honest, I did not see any "read" members in my source code. Below is my updateCoeffs() member function:
Code:
void Foam::DSRFGVelocityFvPatchVectorField::updateCoeffs()
{
    if (this->updated())
    {
        return;
    }
    if (curTimeIndex_ != this->db().time().timeIndex())
{
    scalar time = this->db().time().value();
	vectorField& U = *this;
    vectorField Uavg(patch().size(),vector::zero);
    vectorField Uprim(patch().size(),vector::zero);
    //vectorField Utotal(patch().size(),vector::zero);
    scalar kx=0.;
        scalar vx=0.;
        scalar vy = 0.;
        scalar vz = 0.;
    forAll(patch().Cf(),faceI)
    {
        scalar zcell=patch().Cf()[faceI][2];
        Uavg[faceI][0]=uref_*pow(zcell/zref_,alpha_);
    }
    


    forAll(patch().Cf(),faceI)
    {
        kx=0.;
        vx=0.;
        vy=0.;
        vz=0.;

        
        forAll(allK_,ki)
        {
            kx=patch().Cf()[faceI][0]*allK_[ki][0]/Ls_[ki][0]+patch().Cf()[faceI][1]*allK_[ki][1]/Ls_[ki][1]+patch().Cf()[faceI][2]*allK_[ki][2]/Ls_[ki][2]+omega_[ki]*time;
            vx+=allP_[ki][0]*sin(kx)+allQ_[ki][0]*cos(kx);
            vy+=allP_[ki][1]*sin(kx)+allQ_[ki][1]*cos(kx);
            vz+=allP_[ki][2]*sin(kx)+allQ_[ki][2]*cos(kx);
        }

        Uprim[faceI][0]=vx;
        Uprim[faceI][1]=vy;
        Uprim[faceI][2]=vz;
            



    }
U=Uavg+Uprim;

curTimeIndex_ = this->db().time().timeIndex();
}
    fixedValueFvPatchVectorField::updateCoeffs();
}
I am also not sure of the autoMap and rmap member function. I just claimed the function but don't know how to use them. My code can run in single processor.
Code:
void Foam::DSRFGVelocityFvPatchVectorField::autoMap
(
    const fvPatchFieldMapper& m
)
{
    fixedValueFvPatchVectorField::autoMap(m);
   
    
}


void Foam::DSRFGVelocityFvPatchVectorField::rmap
(
    const fvPatchField& ptf,
    const labelList& addr
)
{
    fixedValueFvPatchVectorField::rmap(ptf, addr);

    const DSRFGVelocityFvPatchVectorField& tiptf =
        refCast<const DSRFGVelocityFvPatchVectorField>(ptf);
      
}

Thank you very much!!!


Quote:
Originally Posted by serles View Post
Something is wrong with the I/O. During reading of fields from the disk, OpenFOAM constructs a dictionary from the file (processor1/0/U in your case), where the Lists are stored as compoundToken (since dictionary is able to work only with tokens). In the next step, this dictionary is supplied to the GeometricField constructor, whereby the List is transferred (not read from disk because it's already in memory) to the GeometricField instance.

I assume you didn't change the source code of renumberMesh. So the problem should be somewhere within the reading operations of your boundary condition. Can you provide the related members like "read" or "operator>>" from you BC?
XJ_Wang is offline   Reply With Quote

Old   March 29, 2023, 04:09
Default
  #4
New Member
 
Sergey Lesnik
Join Date: Mar 2015
Posts: 14
Rep Power: 11
serles is on a distinguished road
Quote:
To be honest, I did not see any "read" members in my source code.
OK, then I assume you construct your BC with a dictionary, don't you? Anyway, can you provide the constructor you use?


What class do you inherit from?
serles is offline   Reply With Quote

Old   March 29, 2023, 12:06
Default
  #5
New Member
 
Xiangjie Wang
Join Date: Jul 2019
Posts: 26
Rep Power: 7
XJ_Wang is on a distinguished road
Thank you very much Sergey!!!

You are correct! There is something wrong with my constructor. My BC inherits from fixedValue class and I used 'foamNewBC -f -v' to generate the templates of my BC dictionary. I am using Openfoam V6, but I modified my code according to a code from Openfoam v2112 so I changed my constructor. There is nothing wrong when I compiled my library but it just can not work well. Now I changed my constructor and it works!


A personal experience: I did not find too many similar problems in this forum, which means my problem is unusual and I might make something wrong at the first step.
XJ_Wang is offline   Reply With Quote

Old   March 30, 2023, 05:21
Default
  #6
New Member
 
Sergey Lesnik
Join Date: Mar 2015
Posts: 14
Rep Power: 11
serles is on a distinguished road
You're welcome
serles 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
[snappyHexMesh] snappyHexMesh error "Cannot determine normal vector from patches." lethu OpenFOAM Meshing & Mesh Conversion 1 June 3, 2020 08:49
"Failed Starting Thread 0" ebringley OpenFOAM Running, Solving & CFD 2 April 26, 2019 06:45
decomposePar is missing a library whk1992 OpenFOAM Pre-Processing 8 March 7, 2015 08:53
[snappyHexMesh] Problem with Sanpper, surface still Rough Zephiro88 OpenFOAM Meshing & Mesh Conversion 7 November 5, 2014 13:05
[Gmsh] Import gmsh msh to Foam adorean OpenFOAM Meshing & Mesh Conversion 24 April 27, 2005 09:19


All times are GMT -4. The time now is 08:38.