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

Source defined for field but never used??

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 3, 2021, 22:34
Default Source defined for field but never used??
  #1
Member
 
Jonathan Wells
Join Date: Oct 2020
Location: Indiana
Posts: 44
Rep Power: 5
jdw135 is on a distinguished road
Hello,

I've been attempting to learn how to use scalarCodedSource, and I've hit a brick wall of sorts. I am using rhoPimpleFoam for my case, and I would like to add a source to the energy equation via the fvOptions. My fvOptions code is its own file in the constant directory, and is as follows:

Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "constant";
    object      fvOptions;
}

ICM
    {
        type            scalarCodedSource;
        name            sourceTime;

        active          yes;

        scalarCodedSourceCoeffs
        {
            selectionMode   all;
            fields          (he);

            codeInclude
            #{
            #};

            codeCorrect
            #{
                Pout<< "**codeCorrect**" << endl;
            #};

            codeAddSup
            #{
                const Time& time = mesh().time();
                const volScalarField& rhoS = mesh_.lookupObject<volScalarField>("rho");
                const volVectorField& uS = mesh_.lookupObject<volVectorField>("U");
                const volScalarField& pS = mesh_.lookupObject<volScalarField>("p");
                const vectorField& C = mesh_.C();
                const scalarField& V = mesh_.V();
                scalarField& SoS = sqrt(1.4*(pS/rhoS));
                scalarField& mach = uS/SoS;
                scalarField& qq = -(pS*(1-(mach*mach))1005)/(1.4*(mach*mach)*287.058);
                scalarField& heSource = eqn.source();
                heSource -= qq;
            #};

            codeConstrain
            #{
                Pout<< "**codeSetValue**" << endl;
            #};

            // Dummy entry. Make dependent on above to trigger recompilation
            code
            #{
                $codeInclude
                $codeCorrect
                $codeAddSup
                $codeConstrain
            #};
        }
        sourceTimeCoeffs
        {
            // Dummy entry
        }
    }
Unfortunately, I can't find reliable documentation on what else to do to implement this code. I have added the following to my controlDict file based on what I've read on these forums:

Code:
ICM
  {
    type            scalarTransport;
    libs            ("libsolverFunctionObjects.so");
    field           he;
  }
I'm basing the field name on the rhoPimpleFoam solver Eeqn.h, where it calls
Code:
fvOptions(rho,he)
I keep getting the error message, "Source ICM defined for field he but never used", and prior to running I get a warning saying, "cannot find file "/afs/crc.nd.edu/user/j/jwells4/ShearLayer/OpenFoam/Rennie/processor0/0/he". Can someone please point out where I'm missing the point, and maybe tell me the full steps to implementing this kind of source? Should I be naming the field something else and supplying a 0 file for it?
jdw135 is offline   Reply With Quote

Old   March 4, 2021, 15:30
Default
  #2
Member
 
Jonathan Wells
Join Date: Oct 2020
Location: Indiana
Posts: 44
Rep Power: 5
jdw135 is on a distinguished road
Can anyone please help with this issue? There are zero actual tutorials for this and I cannot find a reason that it's not implementing the fvOption. The code is definitely reading the file.
jdw135 is offline   Reply With Quote

Old   March 4, 2021, 16:49
Default
  #3
Member
 
Jonathan Wells
Join Date: Oct 2020
Location: Indiana
Posts: 44
Rep Power: 5
jdw135 is on a distinguished road
This is the portion that is returning the error, but I'm unsure why it's not applying the source. This is from fvOption.C

Code:
void Foam::fv::option::checkApplied() const
 {
     forAll(applied_, i)
     {
         if (!applied_[i])
         {
             WarningInFunction
                 << "Source " << name_ << " defined for field "
                 << fieldNames_[i] << " but never used" << endl;
         }
     }
 }

Last edited by jdw135; March 4, 2021 at 16:50. Reason: added source of the supplied code
jdw135 is offline   Reply With Quote

Old   March 5, 2021, 03:52
Default
  #4
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,066
Rep Power: 26
Yann will become famous soon enough
Hello Jonathan,

Depending on your thermophysicalProperties setup, you can use either internal energy (e) or enthalpy (h).

There is no "he" variable and this is what the solver complains about in your first warning. In your fvOptions, just replace "he" in fields (he); with the energy variable you use in your case (h or e)

The scalarTransport function object is, I guess, useless for what you are trying to achieve here.

I don't know which OpenFOAM version you are using, but there is an example to add a source on the energy equation here : https://www.openfoam.com/documentati...ces-coded.html

I hope this helps,
Yann
Yann is offline   Reply With Quote

Old   March 5, 2021, 08:07
Default
  #5
Member
 
Jonathan Wells
Join Date: Oct 2020
Location: Indiana
Posts: 44
Rep Power: 5
jdw135 is on a distinguished road
Quote:
Originally Posted by Yann View Post
Hello Jonathan,

Depending on your thermophysicalProperties setup, you can use either internal energy (e) or enthalpy (h).

There is no "he" variable and this is what the solver complains about in your first warning. In your fvOptions, just replace "he" in fields (he); with the energy variable you use in your case (h or e)
Thanks for clarifying this. I did eventually change my case to apply the source to the h field, but I was getting a separate error so I got confused. It makes sense that the field would be my energy variable defined in thermophysicalProperties. Now, though, when I run the case, I get an error saying "Unknown variable 'WM_OPTIONS'. From looking online, it seems like this is an environment variable? I can't find much else on it, though.
jdw135 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
[OpenFOAM.com] swak4foam compiling issues on a cluster saj216 OpenFOAM Installation 5 January 17, 2023 16:05
[swak4Foam] swak4foam for OpenFOAM 4.0 mnikku OpenFOAM Community Contributions 80 May 17, 2022 08:06
[snappyHexMesh] Invalid Normals for source face to target face while making AMI? Sorabh OpenFOAM Meshing & Mesh Conversion 1 August 3, 2021 06:35
friction forces icoFoam ofslcm OpenFOAM 3 April 7, 2012 10:57
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 19:08


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