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

How to read data into fvModels for energy source term

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 14, 2023, 13:15
Default How to read data into fvModels for energy source term
  #1
New Member
 
S Abrahams
Join Date: Mar 2022
Location: UK
Posts: 15
Rep Power: 4
sabrahams is on a distinguished road
I'm using compressibleInterFoam with OF9. I have defined an energy source term in fvModels using codeAddRhoSup. I'd like my source term to be time dependent, interpolated from external data. How can I read my data into codeAddRhoSup in fvModels so that I can use it in my source term?

To give more detail, I have data with a list of times and a list of values e.g.
Code:
tData = (1 2 3 4 5)
 PData = (8 9 10 11 12)
I'd like to read these two lists in (I can convert the data to a suitable format). I'd then like to interpolate such that I have a value of P at the current time. I think I can handle the interpolation but I can't work out how to read this data in. I also tried to define the lists directly inside codeAddRhoSup in fvModels but I can't work out the correct syntax for this.

Can anyone help me to read in the data? Or as an alternative, how can I define the lists inside the fvModels file?

Here's my fvModels file
Code:
energySource
    {
        type        coded;
        selectionMode    all; 
        field         T;

        codeAddRhoSup
        #{
            Pout<< "**codeAddRhoSup**" << endl;
        
            

            scalar P = FUNCTION OF TIME INTERPOLATED FROM DATA;
            

            const volScalarField& alpha = mesh().
                lookupObject<volScalarField>("alpha.water"); //alpha field
            const scalarField& V = mesh().V(); //cell volumes
            scalar time = mesh().time().value(); //time without dimensions
                
            scalarField& heSource = eqn.source();    // heat eqn source term
            
            forAll(V, i)
            {
                heSource[i] -= P*V[i]*alpha[i];


            };

        #};

    }
sabrahams is offline   Reply With Quote

Reply

Tags
data, energy source term, fvmodels, interpolation data, source term


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
CFD by anderson, chp 10.... supersonic flow over flat plate varunjain89 Main CFD Forum 18 May 11, 2018 08:31
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem Attesz OpenFOAM Meshing & Mesh Conversion 12 May 2, 2013 11:52
[swak4Foam] funkySetFields compilation error tayo OpenFOAM Community Contributions 39 December 3, 2012 06:18
Problem in running ICEM grid in Openfoam Tarak OpenFOAM 6 September 9, 2011 18:51
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08


All times are GMT -4. The time now is 12:24.