CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   How to read data into fvModels for energy source term (https://www.cfd-online.com/Forums/openfoam-solving/250420-how-read-data-into-fvmodels-energy-source-term.html)

sabrahams June 14, 2023 12:15

How to read data into fvModels for energy source term
 
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];


            };

        #};

    }



All times are GMT -4. The time now is 15:27.