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

help needed in codedSource

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 31, 2020, 06:38
Default help needed in codedSource
  #1
Senior Member
 
KGN
Join Date: Oct 2009
Location: Chennai, India
Posts: 121
Rep Power: 17
mecbe2002 is on a distinguished road
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.



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
mecbe2002 is offline   Reply With Quote

Old   September 2, 2020, 19:11
Default
  #2
Member
 
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 6
superkelle is on a distinguished road
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.
superkelle is offline   Reply With Quote

Old   September 2, 2020, 23:28
Default
  #3
Senior Member
 
KGN
Join Date: Oct 2009
Location: Chennai, India
Posts: 121
Rep Power: 17
mecbe2002 is on a distinguished road
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
mecbe2002 is offline   Reply With Quote

Old   September 9, 2020, 08:00
Default
  #4
Member
 
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 6
superkelle is on a distinguished road
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.
superkelle is offline   Reply With Quote

Old   September 10, 2020, 07:35
Default
  #5
Senior Member
 
KGN
Join Date: Oct 2009
Location: Chennai, India
Posts: 121
Rep Power: 17
mecbe2002 is on a distinguished road
could you please elaborate your answer?
mecbe2002 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
[waves2Foam] Waves2Foam Related Topics ngj OpenFOAM Community Contributions 660 August 20, 2018 13:39
Running UDF with Supercomputer roi247 FLUENT 4 October 15, 2015 14:41
[OpenFOAM.org] OpenFOAM 2.1.1 installation on openSUSE 12.2 32 bit saturn_53 OpenFOAM Installation 13 February 1, 2015 05:17
[swak4Foam] Installing swak4Foam to OpenFOAM in mac Kaquesang OpenFOAM Community Contributions 22 January 21, 2013 12:51
compiling firefoam Farshad_Noravesh OpenFOAM 27 December 24, 2012 05:21


All times are GMT -4. The time now is 06:56.