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

Problem adding a source term in interfoam's alphaEqn.H

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Quentin
  • 1 Post By Quentin

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 18, 2014, 07:34
Default Problem adding a source term in interfoam's alphaEqn.H
  #1
New Member
 
Quentin Coispeau
Join Date: Nov 2013
Posts: 17
Rep Power: 13
Quentin is on a distinguished road
Hi foamers,
Related to this thread concerning "numerical ventilation" with interFoam, i'n now trying to add a source term to the alpha equation in interFoam.

As I don't perfectly understand how to handle implicit/explicit source term and how it is treated in MULES::correct and MULES::explicitsolve, i try to impelment my source term totally explicitely.

My source term S would have this form (with d an arbitrary distance from the wall, y the distance from the cell center to the wall, n an arbitrary number of iterations and \alpha the water phase fraction of the considered cell) :


if y < d
if \alpha < 0.5 //mostly air in the cell / above interface
S= -  \frac{\alpha}{n} //i'm removing water from the cell
else //mosty water in the cell /under interface
S=   \frac{1 - \alpha }{n} //i'm adding water to the cell
else
S= 0


I try to implement this in interFoam solver :
  1. calculating the wall distance in createField.H
    Code:
    Info<< "Calculating wall distance field" <<endl;
        volScalarField y = wallDist(mesh).y();
  2. creating the source terms in alphaEqn.H
    Code:
    //Creating Source Terms
        volScalarField::DimensionedInternalField Su
        (
            IOobject
            (
                "Su",
                runTime.timeName(),
                mesh
            ),
        mesh,
            dimensionedScalar("Su", dimensionSet(0,0,-1,0,0,0,0), scalar(0.0))
        );
    
        
        volScalarField::DimensionedInternalField Source
        (
            IOobject
            (
                "Source",
                runTime.timeName(),
                mesh
            ),
        mesh,
            dimensionedScalar("Source", dimensionSet(0,0,-1,0,0,0,0), scalar(0.0))
        );
  3. evaluating the source term in alphaEqn.H ; as i want to getan only explicitly handled source term, i let Su to 0.
    Code:
    //evaluating Source Term
        forAll( mesh.C(), celli)
        {
            if(y[celli] <= 0.02) 
            {
                if(alpha1[celli] > 0.5) 
                {
                    Source[celli] = ( 1.0 - alpha1[celli])/10.0;
                }
                else
                {
                    Source[celli] = - alpha1[celli]/10.0;
                }
            }
            else
            {
                Source[celli] = 0.0;
            }
        }
  4. adding the source term the equation
    Code:
    fvScalarMatrix alpha1Eqn
            (
                #ifdef LTSSOLVE
                fv::localEulerDdtScheme<scalar>(mesh, rDeltaT.name()).fvmDdt(alpha1)
                #else
                fv::EulerDdtScheme<scalar>(mesh).fvmDdt(alpha1)
                #endif
              + fv::gaussConvectionScheme<scalar>
                (
                    mesh,
                    phi,
                    upwind<scalar>(mesh, phi)
                ).fvmDiv(phi, alpha1)
              ==
                Source
            );
        
            alpha1Eqn.solve();
  5. adding the source terms in MULES::correct and MULES::explicitSolve (I don't understand how it is working, so i just copied the function calls of interPhaseChangeFoam ...). there are three call of those MULES fonction in the code, i just quote the first one of them :
    Code:
    volScalarField alpha10(alpha1);
                #ifdef LTSSOLVE
                MULES::LTScorrect
                (
                    geometricOneField(),
                    alpha1,
                    tphiAlpha(),
                    tphiAlphaCorr0(),
                    Source,
                    (-Su*alpha10)(),
                    1,
                    0
                );
                #else
                MULES::correct
                (
                    geometricOneField(),
                    alpha1,
                    tphiAlpha(),
                    tphiAlphaCorr0(),
                    Source,
                    (-Su*alpha10)(),
                    1,
                    0
                );
                #endif
This is compiling correctly ; but it seems that there is no difference between this solver and the classic LTSInterFoam one. I changed a bit my code to be able to see my Source term in paraview and it is calculated.


I don't know where I am wrong - in fact if I do I would not ask fo some help.


Any Idea would be very welcome.

I read quite a lot of threads on this forum related to the source term, but didn't get any more clue concerning my implementation.
Mano2903 likes this.
Quentin is offline   Reply With Quote

Old   July 30, 2014, 06:33
Default solved
  #2
New Member
 
Quentin Coispeau
Join Date: Nov 2013
Posts: 17
Rep Power: 13
Quentin is on a distinguished road
Solution here.
Mano2903 likes this.

Last edited by wyldckat; August 4, 2014 at 12:29. Reason: fixed partially broken link
Quentin 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
[swak4Foam] funkyDoCalc with OF2.3 massflow NiFl OpenFOAM Community Contributions 14 November 25, 2020 04:30
momentum source term zwdi FLUENT 14 June 27, 2017 16:40
OpenFOAM without MPI kokizzu OpenFOAM Installation 4 May 26, 2014 10:17
Adding an energy source term to a phase with reactions lxlxlxt Fluent Multiphase 0 February 10, 2014 21:42
[swak4Foam] build problem swak4Foam OF 2.2.0 mcathela OpenFOAM Community Contributions 14 April 23, 2013 14:59


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