|
[Sponsors] |
Scalar Transport Equation with a source term using functionObjects and fvOptions |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 3, 2021, 15:50 |
Scalar Transport Equation with a source term using functionObjects and fvOptions
|
#1 |
Member
Mohammad M F
Join Date: Jan 2016
Location: Washington DC, USA
Posts: 43
Rep Power: 10 |
Hey all;
I want to run simpleFoam on a simple converging pipe (laminar and Newtonian) and at the same time add a scalar transport equation with a constant source term in the controlDict. Note that the scalar transport field is called D (which I set to be dimensionless), with zero diffusion (so it is a pure convection problem), and the source term is intended to be applied at the entire domain (all the cells generate the same constant source value). Also note that for future steps, I need to have a source term which is a function of another field variable (say for example source = sqrt(U)/3 at each cell), but for now I need to start with a simple case of a constant source to get things started. Here is my function object section along with the fvOption in my controlDict: Code:
functions { DTransport { type scalarTransport; libs ("solverFunctionObjects.so"); resetOnStartUp no; field D; schemesField U; fvOptions { fixedSource { type scalarFixedValueConstraint; enabled true; scalarFixedValueConstraintCoeffs { selectionMode all; volumeMode specific; fieldValues { D 1; } } } } } } Code:
dimensions [0 0 0 0 0 0 0]; internalField uniform 0; boundaryField { inlet { type fixedValue; value uniform 0; } outlet { type zeroGradient; } wall { type zeroGradient; } } Selecting finite volume options type scalarFixedValueConstraint Source: fixedSource - selecting all cells - selected 60152 cell(s) with volume 2.174888003341e-06 When simulation is complete, I get a D file in each time folder, which is basically the same as the D file in 0 folder, except that Code:
internalField uniform 1; But then, I get another file called phi in each time folder, which is a surfaceScalarField with the unit of [0 3 -1 0 0 0 0], which I don't know anything about. Can anyone help me find out what this phi is? Also, what steps should I take to have a more complicated source term (e.g. that is a function of a field variable)? Thanks |
|
March 5, 2021, 14:15 |
|
#2 |
Member
Mohammad M F
Join Date: Jan 2016
Location: Washington DC, USA
Posts: 43
Rep Power: 10 |
Ok, I have made some progress on applying a coded type source term to my scalar transport equation through fvOptions in controlDict.
For example, below I added a source term to my scalar transport eqn which is in the form of a constant value times magnitude of velocity and it complies just fine. Code:
functions { dTransport { type scalarTransport; libs ("solverFunctionObjects"); resetOnStartUp no; field dDamage; schemesField U; fvOptions { dSource { type scalarCodedSource; name sourceTime; scalarCodedSourceCoeffs { selectionMode all; volumeMode specific; fields (dDamage); name sourceName; codeInclude #{ #include "fvCFD.H" #include "fvc.H" #}; codeCorrect #{ #}; codeAddSup #{ const scalarField& V = mesh_.V(); //const vectorField& C = mesh_.C(); const volVectorField& U = mesh().lookupObject<volVectorField>("U"); const volScalarField& Ux = U.component(0); const volScalarField& Uy = U.component(1); const volScalarField& Uz = U.component(2); scalarField& source = eqn.source(); source = 0.001*Foam::mag(U)*V; #}; codeConstrain #{ Pout<< "**codeConstrain**"<< endl; #}; } } } } } Anyone here to help? |
|
March 8, 2021, 19:12 |
|
#3 |
Member
Mohammad M F
Join Date: Jan 2016
Location: Washington DC, USA
Posts: 43
Rep Power: 10 |
For those interested in a solution, follow the discussion here:
scalarCodedSource - source term - field/s |
|
|
|