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

data transfer of lagrangian particle tracking in parallel

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 14, 2025, 00:15
Default data transfer of lagrangian particle tracking in parallel
  #1
New Member
 
Bill
Join Date: Jun 2017
Posts: 20
Rep Power: 9
Bill_Yang is on a distinguished road
Hello everyone,

I am confronted with an issue of data transfer of lagrangian particle tracking in parallel. My details are as follows:

1) I rewrite the 'reactingParcel' code by adding some user-defined parameters for my particle.

2) I complied the revised 'reactingParcel' and no errors.

3) i used the new solver and run it in serial. I can obtain the results i want.

4) However, when I run the solver in parallel. My results are wrong.

5) I debugged the code and finnally found that the issue is caused by the data transfer in parallel. In parallel, when particle moves to a new subdomain, we need to transfer the particle data. As for my calculation, particle tracking is relied on the new particle parameters I defined therefore I also need to properly trasfer these data. So I think I didnt properly transfer these data.

Could you help with this issue?

The following information explains how I define, read and save the new particle parameters in the "reactingParcel" source code.


6) create the member parameters and member functions of the particle parameters I need in the "reactingParcel.H", just like the in-built parameter 'mass0_' and its related member function.

7) define the member function in "reactingParcelI.H"

8) Initialize the member parameter in the constractors in "reactingParcel.C" and ""reactingParcelIO.C"".

After carefully reading the source code, I think this part codes are very important for parallel
Code:
//- Factory class to read-construct particles used for
//  parallel transfer
        class iNew
        {
            const polyMesh& mesh_;

        public:

            iNew(const polyMesh& mesh)
            :
                mesh_(mesh)
            {}

            autoPtr<ReactingParcel<ParcelType>> operator()(Istream& is) const
            {
                return autoPtr<ReactingParcel<ParcelType>>
                (
                    new ReactingParcel<ParcelType>(mesh_, is, true)
                );
            }
        };
Code:
template<class ParcelType>
Foam::ReactingParcel<ParcelType>::ReactingParcel
(
    const polyMesh& mesh,
    Istream& is,
    bool readFields
)
:
    ParcelType(mesh, is, readFields),
    mass0_(0.0),
    Y_(0)
{
    if (readFields)
    {
        DynamicList<scalar> Ymix;

        if (is.format() == IOstream::ASCII)
        {
            is >> mass0_ >> Ymix;
        }
        else
        {
            is.read(reinterpret_cast<char*>(&mass0_), sizeofFields_);
            is >> Ymix;
        }

        Y_.transfer(Ymix);
    }

    // Check state of Istream
    is.check
    (
        "ReactingParcel<ParcelType>::ReactingParcel"
        "("
            "const polyMesh&, "
            "Istream&, "
            "bool"
        ")"
    );
}
I correct the above code like below:

Code:
template<class ParcelType>
Foam::ReactingParcel<ParcelType>::ReactingParcel
(
    const polyMesh& mesh,
    Istream& is,
    bool readFields
)
:
    ParcelType(mesh, is, readFields),
    mass0_(0.0),
    Y_(0),
    Rep_(0), // my new parameter
    MR_(0.0), // my new parameter
    E_AspectRatio_(1.0), // my new parameter
    sphericity_(1.0), // my new parameter
    phaseChangeStage_(0), // my new parameter
    Tcell_(0.0), // my new parameter
    integrationSteps_(0) // my new parameter
{
    if (readFields)
    {
        DynamicList<scalar> Ymix;

        if (is.format() == IOstream::ASCII)
        {
            is >> mass0_ >> Ymix;
            Rep_ = readScalar(is); // my new parameter
            MR_ = readScalar(is); // my new parameter
            E_AspectRatio_ = readScalar(is); // my new parameter
            sphericity_ = readScalar(is); // my new parameter
            phaseChangeStage_ = readLabel(is); // my new parameter
            Tcell_ = readScalar(is); // my new parameter
            integrationSteps_ = readLabel(is); // my new parameter
        }
        else
        {
            is.read(reinterpret_cast<char*>(&mass0_), sizeofFields_);
            is >> Ymix;
        }

        Y_.transfer(Ymix);
    }

    // Check state of Istream
    is.check
    (
        "ReactingParcel<ParcelType>::ReactingParcel"
        "("
            "const polyMesh&, "
            "Istream&, "
            "bool"
        ")"
    );
}
Attached Files
File Type: c ReactingParcelIO.C (10.5 KB, 1 views)
Bill_Yang is offline   Reply With Quote

Old   January 21, 2025, 05:14
Default
  #2
New Member
 
Bill
Join Date: Jun 2017
Posts: 20
Rep Power: 9
Bill_Yang is on a distinguished road
I managed to resolve this issue. We need to stickly follow how openfoam save and write class member parameters.
Bill_Yang is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Eulerian Multiphase Model vs Lagrangian Particle Tracking ajjadhav CFX 14 December 7, 2020 17:22
Lagrangian particle tracking in mechanically agitated mono-dispersed and poly-dispers anandjjadhaviitr ANSYS 0 September 18, 2020 16:19
[OpenFOAM] How to get the coordinates of velocity data at all cells and at all times vidyadhar ParaView 9 May 20, 2020 21:06
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem Attesz OpenFOAM Meshing & Mesh Conversion 12 May 2, 2013 11:52
Check particle impaction with User Fortran Julian K. CFX 3 January 12, 2012 10:46


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