CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   help needed in codedSource (https://www.cfd-online.com/Forums/openfoam-programming-development/229909-help-needed-codedsource.html)

mecbe2002 August 31, 2020 05:38

help needed in codedSource
 
HI all,

Objective of my work is to replace the effusion holes with source and sink terms (mass, momentum and energy). For this I found out "codedSource" fvOptions is the best way.

I need help in calculating MFR at sink location and apply the same in source and sink locations.

https://www.cfd-online.com/Forums/at...odedsource.png

Code:

massSourceEffusionHole
{
    type    scalarCodedSource;
    name    sourceTime;
    active  true;
   
    scalarCodedSourceCoeffs
    {           
       
        fields          (rho);
        selectionMode  points;
        points //sink location
        (
            (0.035 0.034 0.0)
        ); 
        codeInclude
        #{
       
        #};
       
        codeCorrect
        #{
        #};
       
        codeAddSup
        #{
            const Time& time1 = mesh().time();
            const volScalarField& rhoJet = mesh_.lookupObject<volScalarField>("rho");
            const volVectorField& velJet = mesh_.lookupObject<volVectorField>("U");
            scalarField& massSource1 = eqn.source();
            const labelList& cellIDs = cells();
       
            forAll(cellIDs, i)
            {
                label cellI = cellIDs[i];               
                massSource1[cellI] = rhoJet[cellI]*mag(velJet[cellI])*6.28319*1e-6; 
            }           
        #};
       
        codeSetValue
        #{
        #}
       
        // Dummy entry. Make dependent on above to trigger recompilation code
        #{
            $codeInclude
            $codeCorrect
            $codeAddSup
            $codeSetValue
        #};
    }
   
    sourceTimeCoeffs
    {
        $scalarCodedSourceCoeffs;   
    }
}

In the selection mode I have used "points" and specified the sink location, then calculating the MFR by getting the "rho" and "vel" at that location. I have applied the same in the sink location.

I need help in applying the MFR calculated at "sink" location to "source" location i.e. (0.0385 0.0365 0.0)


FYI
sink location (0.035 0.034 0.0)
source location (0.0385 0.0365 0.0)


Thanks
KGN

superkelle September 2, 2020 18:11

http://www.cfd-online.com/Forums/ope...at-source.html
Does that maybe help? I dont know at which point exactly your problem is.

Is the problem to find the right cells at those locations? Then you can use some of the code I posted.

mecbe2002 September 2, 2020 22:28

Thanks for the reply. I actually referred your post.


Let me explain my problem in detail.
Objective of my work is to replace small diameter pipe (dia <0.5 mm) with source and sink terms i.e. inlet of the pipe will be sink and outlet of the pipe is source.
I have to use pressure drop across the pipe to calculate the mass flow rate; for this i need to get pressure at inlet and exit of the pipe.
  • selection mode - points
  • i have specified inlet and exit of the pipe location
In the below code, inside the "forAll" loop i can access only pressure values of current point in the loop. But i need to get pressure value at some other point for MFR calculation. How to do this?


Code:

codeAddSup
#{           
    const volScalarField& rhoJet = mesh_.lookupObject<volScalarField>("rho");
    const volVectorField& velJet = mesh_.lookupObject<volVectorField>("v1");
    scalarField& massSource1 = eqn.source();
    const labelList& cellIDs = cells();
           
      forAll(cellIDs, i)
      {
          label cellSource = cellIDs[i];
         
          massSource1[cellSource] += rhoJet[cellSink]*mag(velJet[cellSink])*6.28319*1e-6;             
      }                         
#};


hope this explains my problem

superkelle September 9, 2020 07:00

Maybe you better use two new boundary patches and there use custom coded bc since you do not have a wall at inlet and outlet of this channel.

mecbe2002 September 10, 2020 06:35

could you please elaborate your answer?


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