|
[Sponsors] |
March 3, 2021, 22:34 |
Source defined for field but never used??
|
#1 |
Member
Jonathan Wells
Join Date: Oct 2020
Location: Indiana
Posts: 44
Rep Power: 5 |
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 } } Code:
ICM { type scalarTransport; libs ("libsolverFunctionObjects.so"); field he; } Code:
fvOptions(rho,he) |
|
March 4, 2021, 15:30 |
|
#2 |
Member
Jonathan Wells
Join Date: Oct 2020
Location: Indiana
Posts: 44
Rep Power: 5 |
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.
|
|
March 4, 2021, 16:49 |
|
#3 |
Member
Jonathan Wells
Join Date: Oct 2020
Location: Indiana
Posts: 44
Rep Power: 5 |
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 |
|
March 5, 2021, 03:52 |
|
#4 |
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,066
Rep Power: 26 |
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 |
|
March 5, 2021, 08:07 |
|
#5 | |
Member
Jonathan Wells
Join Date: Oct 2020
Location: Indiana
Posts: 44
Rep Power: 5 |
Quote:
|
||
|
|
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 |