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

Total liquid volume fraction vs Time

Register Blogs Community New Posts Updated Threads Search

Like Tree11Likes
  • 1 Post By Pavithra
  • 2 Post By anon_q
  • 1 Post By Pavithra
  • 2 Post By anon_q
  • 1 Post By Pavithra
  • 2 Post By anon_q
  • 1 Post By Pavithra
  • 1 Post By Pavithra

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 4, 2019, 08:24
Default Total liquid volume fraction vs Time
  #1
Member
 
Join Date: Apr 2019
Location: India
Posts: 81
Rep Power: 7
Pavithra is on a distinguished road
Hello Everyone,



I am simulating melting process by modifying buoyantBoussinesqPimpleFoam. I have calculated the total liquid volume fraction as follows:


Code:
dimensionedScalar tlf = (sum(mesh.V()*lf))/(sum(mesh.V()));

where,

lf is the local liquid volume fraction.



Now, I want to write a dat/xy file to plot tlf vs time. Kindly, please guide me to achieve this.



Thank You.
Svetlana likes this.
Pavithra is offline   Reply With Quote

Old   August 4, 2019, 19:01
Default
  #2
Senior Member
 
Join Date: Mar 2018
Posts: 115
Rep Power: 8
anon_q is on a distinguished road
You can store your data tlf values in an array and save it to a file.

Code:
//Before entering the time loop decalre the hashTable
HashTable<scalar, word> tlfValues;

//Inside the time loop
word t = runTime.timeName();
tlfValues.insert(t, sum(mesh.V()*lf))/(sum(mesh.V()));
...
// Outside the time loop, save the hash table to a file
OFstream myfile("./tlfvalues");
myfile() << tlfValues;
Svetlana and Pavithra like this.

Last edited by anon_q; August 4, 2019 at 20:02.
anon_q is offline   Reply With Quote

Old   August 4, 2019, 23:13
Default
  #3
Member
 
Join Date: Apr 2019
Location: India
Posts: 81
Rep Power: 7
Pavithra is on a distinguished road
Quote:
Originally Posted by Evren Linda View Post
You can store your data tlf values in an array and save it to a file.

Code:
//Before entering the time loop decalre the hashTable
HashTable<scalar, word> tlfValues;

//Inside the time loop
word t = runTime.timeName();
tlfValues.insert(t, sum(mesh.V()*lf))/(sum(mesh.V()));
...
// Outside the time loop, save the hash table to a file
OFstream myfile("./tlfvalues");
myfile() << tlfValues;
Respected Mam,

Thank you so much for your kind help. I tried the code you provided. But, I am unable to compile after adding the code.

My solver.C file is as follows:
Code:
\*---------------------------------------------------------------------------*/

#include "fvCFD.H"
#include "fvOptions.H"
#include "pimpleControl.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
    #include "postProcess.H"

    #include "setRootCaseLists.H"
    #include "createTime.H"
    #include "createMesh.H"
    #include "createControl.H"
    #include "createFields.H"
    #include "createTimeControls.H"
    #include "CourantNo.H"
    #include "setInitialDeltaT.H"
    #include "initContinuityErrs.H"

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
  
    //Before entering the time loop decalre the hashTable
        HashTable<scalar, word> tlfValues;

    Info<< "\nStarting time loop\n" << endl;

        while (runTime.run())
        {
            #include "readTimeControls.H"
            #include "CourantNo.H"
            #include "setDeltaT.H"

            runTime++;

            Info<< "Time = " << runTime.timeName() << nl << endl;

        //update the latent heat content after inner each loop        
        volScalarField DHnew = DH;

            // --- Pressure-velocity PIMPLE corrector loop
            while (pimple.loop())
                {
                        #include "UEqn.H"
           
                        // --- Pressure corrector loop
                        while (pimple.correct())
                        {
                               #include "pEqn.H"
                        }

                    #include "TEqn.H"

                    //Inside the time loop
                    word t = runTime.timeName();
                    tlfValues.insert(t, (sum(mesh.V()*lf))/(sum(mesh.V())));
                }

        //calculate the total liquid fraction        
        dimensionedScalar tlf = (sum(mesh.V()*lf))/(sum(mesh.V()));

        runTime.write();

            Info<< nl << endl;

        //print the total liquid fraction
            Info<< "Total Liquid Fraction = " << tlf.value() << endl;

            Info<< nl << endl;

        //print the execution time
            Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s";

        Info<< nl << endl;
        
        //print the clock time
            Info<< "  ClockTime = " << runTime.elapsedClockTime() << " s";
            
        Info<< nl << endl;
        }

        // Outside the time loop, save the hash table to a file
    OFstream myfile("./tlfvalues");
    myfile() << tlfValues;

        Info<< "End\n" << endl;

        return 0;
}

// ************************************************************************* //
The error message is as follows:


Code:
meltFoam.C: In function 'int main(int, char**)':
meltFoam.C:105:63: error: no matching function for call to 'Foam::HashTable<double, Foam::word>::insert(Foam::word&, Foam::dimensioned<double>)'
         tlfValues.insert(t, (sum(mesh.V()*lf))/(sum(mesh.V())));
                                                               ^
In file included from /opt/openfoam6/src/OpenFOAM/lnInclude/HashTable.H:560:0,
                 from /opt/openfoam6/src/OpenFOAM/lnInclude/runTimeSelectionTables.H:41,
                 from /opt/openfoam6/src/OpenFOAM/lnInclude/token.H:49,
                 from /opt/openfoam6/src/OpenFOAM/lnInclude/UListIO.C:28,
                 from /opt/openfoam6/src/OpenFOAM/lnInclude/UList.C:233,
                 from /opt/openfoam6/src/OpenFOAM/lnInclude/UList.H:484,
                 from /opt/openfoam6/src/OpenFOAM/lnInclude/List.H:43,
                 from /opt/openfoam6/src/OpenFOAM/lnInclude/labelList.H:48,
                 from /opt/openfoam6/src/OpenFOAM/lnInclude/UPstream.H:42,
                 from /opt/openfoam6/src/OpenFOAM/lnInclude/Pstream.H:42,
                 from /opt/openfoam6/src/OpenFOAM/lnInclude/parRun.H:35,
                 from /opt/openfoam6/src/finiteVolume/lnInclude/fvCFD.H:4,
                 from meltFoam.C:48:
/opt/openfoam6/src/OpenFOAM/lnInclude/HashTableI.H:79:13: note: candidate: bool Foam::HashTable<T, Key, Hash>::insert(const Key&, const T&) [with T = double; Key = Foam::word; Hash = Foam::string::hash]
 inline bool Foam::HashTable<T, Key, Hash>::insert
             ^~~~
/opt/openfoam6/src/OpenFOAM/lnInclude/HashTableI.H:79:13: note:   no known conversion for argument 2 from 'Foam::dimensioned<double>' to 'const double&'
/opt/openfoam6/wmake/rules/General/transform:25: recipe for target 'Make/linux64GccDPInt32Opt/meltFoam.o' failed
make: *** [Make/linux64GccDPInt32Opt/meltFoam.o] Error 1
Kindly, please help me.

Thank You.
Svetlana likes this.
Pavithra is offline   Reply With Quote

Old   August 5, 2019, 08:26
Default
  #4
Senior Member
 
Join Date: Mar 2018
Posts: 115
Rep Power: 8
anon_q is on a distinguished road
Sorry, I forgot to call the value() method of dimensionedScalar variable tlf.
Code:
\*---------------------------------------------------------------------------*/

#include "fvCFD.H"
#include "fvOptions.H"
#include "pimpleControl.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
    #include "postProcess.H"

    #include "setRootCaseLists.H"
    #include "createTime.H"
    #include "createMesh.H"
    #include "createControl.H"
    #include "createFields.H"
    #include "createTimeControls.H"
    #include "CourantNo.H"
    #include "setInitialDeltaT.H"
    #include "initContinuityErrs.H"

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
  
    //Before entering the time loop decalre the hashTable
    HashTable<scalar, word> tlfValues;

    Info<< "\nStarting time loop\n" << endl;

        while (runTime.run())
        {
            #include "readTimeControls.H"
            #include "CourantNo.H"
            #include "setDeltaT.H"

            runTime++;

            Info<< "Time = " << runTime.timeName() << nl << endl;

        //update the latent heat content after inner each loop        
        volScalarField DHnew = DH;

            // --- Pressure-velocity PIMPLE corrector loop
            while (pimple.loop())
                {
                        #include "UEqn.H"
           
                        // --- Pressure corrector loop
                        while (pimple.correct())
                        {
                               #include "pEqn.H"
                        }

                    #include "TEqn.H"

                    //Inside the time loop
                }

	// These lines must be outside the pimple loop		
	word t = runTime.timeName();
	dimensionedScalar tlf = sum(mesh.V()*lf))/(sum(mesh.V());
        tlfValues.insert(t, tlf.value());

        runTime.write();

            Info<< nl << endl;

        //print the total liquid fraction
            Info<< "Total Liquid Fraction = " << tlf.value() << endl;

            Info<< nl << endl;

        //print the execution time
            Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s";

        Info<< nl << endl;
        
        //print the clock time
            Info<< "  ClockTime = " << runTime.elapsedClockTime() << " s";
            
        Info<< nl << endl;
        }

        // Outside the time loop, save the hash table to a file
    OFstream myfile("./tlfvalues");
    myFile() << "time\t" << "tlf" << endl; 

    // Write the tlfValues to the file sorted by time
    for (word ti : tlfValues.sortedToc())
    {
         myfile() << ti << "\t" << tlfValues[ti] << endl;
    }
   



        Info<< "End\n" << endl;

        return 0;
}

// ************************************************************************* //
I haven't tested that, but you can just try to compile it.
Svetlana and Pavithra like this.

Last edited by anon_q; August 5, 2019 at 10:18.
anon_q is offline   Reply With Quote

Old   August 5, 2019, 22:52
Default
  #5
Member
 
Join Date: Apr 2019
Location: India
Posts: 81
Rep Power: 7
Pavithra is on a distinguished road
Good morning mam,

Thank you so much. It worked perfect.

Thank You.

With Thanks,
Pavithra.
Svetlana likes this.
Pavithra is offline   Reply With Quote

Old   August 6, 2019, 12:22
Default
  #6
Senior Member
 
Join Date: Mar 2018
Posts: 115
Rep Power: 8
anon_q is on a distinguished road
Just to solve the issue of sorting, we have to change the key to scalar (double) instead of word (string).

Code:
\*---------------------------------------------------------------------------*/

#include "fvCFD.H"
#include "fvOptions.H"
#include "pimpleControl.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
    #include "postProcess.H"

    #include "setRootCaseLists.H"
    #include "createTime.H"
    #include "createMesh.H"
    #include "createControl.H"
    #include "createFields.H"
    #include "createTimeControls.H"
    #include "CourantNo.H"
    #include "setInitialDeltaT.H"
    #include "initContinuityErrs.H"

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
  
    //Before entering the time loop decalre the hashTable
    HashTable<scalar, scalar, Hash<scalar>> tlfValues;

    Info<< "\nStarting time loop\n" << endl;

        while (runTime.run())
        {
            #include "readTimeControls.H"
            #include "CourantNo.H"
            #include "setDeltaT.H"

            runTime++;

            Info<< "Time = " << runTime.timeName() << nl << endl;

        //update the latent heat content after inner each loop        
        volScalarField DHnew = DH;

            // --- Pressure-velocity PIMPLE corrector loop
            while (pimple.loop())
                {
                        #include "UEqn.H"
           
                        // --- Pressure corrector loop
                        while (pimple.correct())
                        {
                               #include "pEqn.H"
                        }

                    #include "TEqn.H"

                    //Inside the time loop
                }

	// These lines must be outside the pimple loop		
	scalar t = runTime.value();
	dimensionedScalar tlf = sum(mesh.V()*lf))/(sum(mesh.V());
        tlfValues.insert(t, tlf.value());

        runTime.write();

            Info<< nl << endl;

        //print the total liquid fraction
            Info<< "Total Liquid Fraction = " << tlf.value() << endl;

            Info<< nl << endl;

        //print the execution time
            Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s";

        Info<< nl << endl;
        
        //print the clock time
            Info<< "  ClockTime = " << runTime.elapsedClockTime() << " s";
            
        Info<< nl << endl;
        }

        // Outside the time loop, save the hash table to a file
    OFstream myfile("./tlfvalues");
    myFile() << "time\t" << "tlf" << endl; 

    // Write the tlfValues to the file sorted by time
    for (scalar ti : tlfValues.sortedToc())
    {
         myfile() << ti << "\t" << tlfValues[ti] << endl;
    }
   



        Info<< "End\n" << endl;

        return 0;
}

// ************************************************************************* //
Svetlana and Pavithra like this.

Last edited by anon_q; August 6, 2019 at 14:03.
anon_q is offline   Reply With Quote

Old   August 6, 2019, 22:25
Default
  #7
Member
 
Join Date: Apr 2019
Location: India
Posts: 81
Rep Power: 7
Pavithra is on a distinguished road
Thank you so much mam. It works perfect.
Svetlana likes this.
Pavithra is offline   Reply With Quote

Old   August 7, 2019, 08:06
Default
  #8
Member
 
Join Date: Apr 2019
Location: India
Posts: 81
Rep Power: 7
Pavithra is on a distinguished road
Hi Everyone,

I have attached the solver which I was trying to make.

The solver is based on buoyantBoussinesqPimpleFoam. The enthalpy-porosity method proposed by Voller & Brent has been employed.

This solver can be used for isothermal and non-isothermal melting.

The solvers perform adequately well for Gallium melting case and 1-D Stefan problem.

The solver is compiled and tested in OF v6.

Any advice or suggestions for improvements are welcome.

Also, please give me a direction to make this solver work in parallel. At present, this solver works well in single core but, crashes while using mpirun.

Thank You.

- Pavithra
Attached Files
File Type: gz meltingFoam.tar.gz (4.2 KB, 17 views)
File Type: gz gallium_testCase.tar.gz (3.3 KB, 12 views)
Kummi likes this.

Last edited by Pavithra; August 7, 2019 at 22:30.
Pavithra is offline   Reply With Quote

Old   August 8, 2019, 05:40
Default
  #9
Member
 
Join Date: Apr 2019
Location: India
Posts: 81
Rep Power: 7
Pavithra is on a distinguished road
Hi Everyone,

I am attaching the results of some validation cases, herewith.

I have attached the solver, cases and results. Any suggestions for improvements are welcome.

Thank You.

- Pavithra
Attached Images
File Type: jpg gallium_1200seconds.jpg (25.8 KB, 36 views)
File Type: jpg temperature.jpg (93.1 KB, 41 views)
File Type: jpg fraction.jpg (93.8 KB, 34 views)
Attached Files
File Type: gz SolverWithTestCases.tar.gz (9.3 KB, 27 views)
Pavithra is offline   Reply With Quote

Old   October 3, 2024, 16:31
Default parallel simulation
  #10
New Member
 
Adarsh Thakur
Join Date: Sep 2024
Posts: 1
Rep Power: 0
adarsh_CFD is on a distinguished road
Quote:
Originally Posted by Pavithra View Post
Hi Everyone,

I have attached the solver which I was trying to make.

The solver is based on buoyantBoussinesqPimpleFoam. The enthalpy-porosity method proposed by Voller & Brent has been employed.

This solver can be used for isothermal and non-isothermal melting.

The solvers perform adequately well for Gallium melting case and 1-D Stefan problem.

The solver is compiled and tested in OF v6.

Any advice or suggestions for improvements are welcome.

Also, please give me a direction to make this solver work in parallel. At present, this solver works well in single core but, crashes while using mpirun.

Thank You.

- Pavithra
Hii, have you resolve the issue of crashing using mpirun. If yes please let me know,

Thank You
Adarsh
adarsh_CFD is offline   Reply With Quote

Reply

Tags
global variable vs time, openfoam, postprocessing


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
[IHFOAM] The IHFOAM Thread Phicau OpenFOAM Community Contributions 392 September 8, 2023 19:10
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07:20
InterFoam negative alpha karasa03 OpenFOAM 7 December 12, 2013 04:41
Error in run Batch file saba1366 CFX 4 February 10, 2013 02:15
interDyMFoam - change in volume fraction gopala OpenFOAM Running, Solving & CFD 0 April 27, 2009 11:46


All times are GMT -4. The time now is 17:48.