|
[Sponsors] |
reading in a field into fvOptions with type: scalarCodedSource |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 6, 2016, 13:40 |
reading in a field into fvOptions with type: scalarCodedSource
|
#1 |
Member
Join Date: Jun 2015
Posts: 30
Rep Power: 11 |
Hi,
I'm trying to add an explicit source term (Sp) to the scalarTransportFoam, say for the field T. The source Term involves the product of T with another volScalarField object, lets call it E, which actually remains constant through the simulation. I'm trying to use the type scalarCodedSource in fvOptions as in https://github.com/OpenFOAM/OpenFOAM.../CodedSource.H Since I'm using an explicit source term, T.oldTime() is used as an estimate. For E, since it remains constant during the simulations, I thought of putting it in the constant directory and read it from there, and that's where I'm having getting difficulties. Here is the code: Code:
energySource { type scalarCodedSource; active yes; scalarCodedSourceCoeffs { selectionMode all; fieldNames (T); redirectType sourceTime; codeInclude #{ #}; codeCorrect #{ #}; codeAddSup #{ const Time& time = mesh().time(); const scalarField& V = mesh_.V(); const volScalarField& Temp = mesh_.lookupObject<volScalarField>("T"); volScalarField E ( IOobject ( "E", runTime.constant(), mesh_, IOobject::MUST_READ, IOobject::NO_WRITE ), mesh_ ); scalarField& heSource = eqn.source(); heSource -=E*Temp.oldTime()*V; #}; codeSetValue #{ #}; code #{ $codeInclude $codeCorrect $codeAddSup $codeSetValue #}; } sourceTimeCoeffs { } } Q2) Following the link for the CodedSource.H, I was wondering why can I interchangeably use mesh().time() and mesh_.time() ? Thanks, Ali |
|
June 7, 2016, 22:19 |
|
#2 |
Member
Jack
Join Date: Aug 2012
Posts: 47
Rep Power: 14 |
add
Code:
const Time& time = mesh().time(); Code:
runTime.timeName() Code:
time.timeName() |
|
June 8, 2016, 06:53 |
|
#3 |
Member
Join Date: Jun 2015
Posts: 30
Rep Power: 11 |
Thanks Jack for the reply.
As I noted, field E remains constant during the simulations, and it is computed prior to running the scalarTransportFoam solver. So I prefer to read it from a different path say the constant/ directory. Giving time.timeName() as path would only work for the first time step if I include the field E in the 0/ directory. but for the later time steps in would give error since field E is non-existent. Best Ali |
|
June 10, 2016, 06:11 |
|
#4 |
Member
Join Date: Jun 2015
Posts: 30
Rep Power: 11 |
just realized time is actually of object Time. So accessing the constant directory is possible via time.constant(). So reading field E is as follows:
Code:
volScalarField E ( IOobject ( "E", time.constant(), mesh_, IOobject::MUST_READ, IOobject::NO_WRITE ), mesh_ ); |
|
June 7, 2018, 11:25 |
|
#5 |
New Member
JPeternel
Join Date: Oct 2014
Posts: 19
Rep Power: 12 |
You need to get mesh and time objects, they do not exist in every class under this names.
Maybe try to Access them through velocity field, something like: U_.mesh() instead of mesh and U_.time() instead of runTime |
|
Tags |
fvoptions, read in field |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[OpenFOAM.org] compile error in dynamicMesh and thermophysicalModels libraries | NickG | OpenFOAM Installation | 3 | December 30, 2019 01:21 |
time step continuity problem in VAWT simulation | lpz_michele | OpenFOAM Running, Solving & CFD | 5 | February 22, 2018 20:50 |
Time step continuity error | lpz_michele | OpenFOAM Running, Solving & CFD | 0 | October 12, 2015 07:05 |
''unknown radialModelType type Gidaspow'' PROBLEM WITH THE BED TUTORIAL | AndoniBM | OpenFOAM Running, Solving & CFD | 2 | March 25, 2015 19:44 |
Problem in running ICEM grid in Openfoam | Tarak | OpenFOAM | 6 | September 9, 2011 18:51 |