Skip to content

How to use a SuperIdentity3D pointer to pass between two time step

OpenLB – Open Source Lattice Boltzmann Code Forums on OpenLB General Topics How to use a SuperIdentity3D pointer to pass between two time step

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1918
    steed188
    Participant

    Hi guys,
    I wonder that how to use a SuperIdentity Pointer to pass a SuperIdentity value from last collision step time to this.
    For example;


    SuperIdentity3D <T,T> * superValue; //define a global pointer ;

    main(…){
    for ( int iT = 0; iT <= converter.numTimeSteps( maxT ); ++iT ) {

    if(iT==0){
    AnalyticalConst3D<T,T> coe1( T( 2. ),T( 2. ),T( 2. ));
    SuperLatticeFfromAnalyticalF3D<T,DESCRIPTOR> coeffi1 ( coe1, sLattice );
    superValue= new SuperIdentity3D <T,T>( coeffi1 )
    }

    If (iT>0 && iT < middleT) {
    AnalyticalConst3D<T,T> coe2( T( .5 ),T( .5 ),T( .5 ));
    SuperLatticeFfromAnalyticalF3D<T,DESCRIPTOR> coeffi2 ( coe2, sLattice );
    superValue = new SuperIdentity3D <T,T> ( (*superValue) * coeffi2 );
    }
    }

    It can be compiled and run, but the result is wrong.
    When iT=0, the superValue can be assigned as ( T( 2. ),T( 2. ),T( 2. )),
    But when iT=1, the superValue can not get the last time step’s value, resulting that this time step’s result wrong.

    Did I misuse the SuperIdentity as a pointer?

    With best wishes.
    Steed188

    #2640
    mathias
    Keymaster

    Dear Steed188,

    to store data you need to use a superData or superDataF class!

    Best
    Mathias

    #2645
    steed188
    Participant

    Dear mathias,
    Thank you for your reply.
    Would you mind applying some examples that showing how to use superData class to store data?
    Thank you very much。

    steed188

    #2646
    mathias
    Keymaster

    Dear steed188,

    it is quite simple, just use the constructor
    SuperData3D(SuperF3D<T,BaseType>& rhs);
    Please, also use the dogygen docu if you need to know interfaces.

    By the way, registration for our spring school in 2018 is open!

    Best
    Mathias

    #2647
    steed188
    Participant

    Dear mathias,
    Yeah, I’ve tried SuperData3D. But it seems I did wrong.
    For example, I defined a SuperData3D named “Store_VecData” in the main function, then assume that we accumulate the velocity to it every step and then write it to VTK files.
    I did it like below.

    Code:
    void main(){
    ….
    //define a SuperData
    SuperData3D<T,T> Store_VecData ( cuboidGeometry, loadBalancer, 2, 3 );
    ….
    getResults(…,Store_VecData,…)
    }

    void getResults(…,SuperData3D<T,T>& Store_VecData,…){
    SuperLatticePhysVelocity3D<T,DESCRIPTOR>velocity_lattice( sLattice, converter );
    SuperIdentity3D<double,double> phyVelocity(velocity_lattice);

    // if iT is 1 then assign the initial value to Store_VecData;
    if (iT == 1 ){
    SuperData3D <T,T> temp_Data (phyVelocity);
    Store_VecData = temp_Data;
    }

    //Othewise I want extract SuperF from SuperData and add
    // this time ‘s value, store it to SuperData again.
    if (iT > 1){
    SuperDataF3D <T,T> last_Data ( Store_VecData );
    SuperData3D <T,T> this_Data ( last_Data + phyVelocity );
    Store_VecData = this_Data;
    }

    //write SuperData to VTKfiles
    SuperDataF3D <T,T> toVTK ( Store_VecData );
    vtmWriterTS.write( toVTK ,iT );
    }

    Well. I didn’t work. Always Segmentation fault. 😀
    Would you like point out the fault?

    By the way, thank you for noticing that the spring school. I’ll discuss it with my prof.

    steed188.

    #2650
    mathias
    Keymaster

    Dear steed188,

    your solotion is not the best in terms of efficiency but I do not see why it should not work. If you find out the problem, please let us know.

    Best
    Mathias

    #2653
    steed188
    Participant

    Dear mathias,
    Sorry for so late.
    Do you mean that my code is correct with the usage of SuperData3D and SuperDataF3D though it was not efficiency?
    That is weird that it didnt work.

    Would you like to share some idea for more efficiency terms?

    your best
    steed188

    #2655
    mathias
    Keymaster

    Come to the spring school next year and we will have some time to go through that.

    #2657
    steed188
    Participant

    Yeah. I wish i will get my professor’s permission for that. smile:)

    #2685
    steed188
    Participant

    I maybe found the problem.
    It seems that the SuperData3d can store data correctly. And I could catch cell data after I convert it into SuperDataF3D. But if I used vtmWriter.addFunctor to write the SuperDataF3D it went wrong.

    Is wright to write SuperDataF3D to vtk files? Or should I convert it to other functors?

    with best wishes,
    steed188

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.