|
[Sponsors] |
August 2, 2018, 03:52 |
conditional operator in source term
|
#1 |
New Member
Join Date: Aug 2018
Posts: 18
Rep Power: 8 |
Hi,all
I use OF2.3.1, coding wall condensation model of H2O gas, in rhoReactingBuoyantFoam. In YEqn.H, I add Mass source term in YiEqnMatrix. But compile does'nt pass. I intend to reduce H2O Mass from near wall cell, not considering water liquid phase. In Yeqn.H, judgeing species H2O or Others, decide mass source term field value "Mass_source" or Zero value. but zero value does not recieved. "Mass_source" is volScalarField. << Yeqn.H source Code >> fvScalarMatrix YiEqn ( fvm::ddt(rho, Yi) + mvConvection->fvmDiv(phi, Yi) - fvm::laplacian(turbulence->muEff(), Yi) == reaction->R(Yi) + fvOptions(rho, Yi) + (Yi.name() == "H2O" ? Mass_source :0.0 ) ); << Compile Error >> YEqn.H:32:48: error: no match for ternary ‘operator?:’ (operand types are ‘bool’, ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’, and ‘double’) + (Yi.name() == "H2O" ? Mass_sou :0.0 ) So I'm programing beginner, I don't know what I shoud do. Can anyone help me? best regard. (sorry for bad english ...) |
|
August 7, 2018, 21:53 |
|
#2 |
Senior Member
|
Hi,
"Mass_source" is volScalarField, but 0.0 is just a double. The operator "?" needs two values with the same type (or implicit type conversion exists). OpenFOAM have zero class. I'm not sure it works here or not. Defining volScalarField with zero value or using if statement before the creation of fvScalarMatrix YiEqn may work, i guess... It may not be elegant code... |
|
August 8, 2018, 02:45 |
|
#3 |
New Member
Join Date: Aug 2018
Posts: 18
Rep Power: 8 |
Hello,snak.
Thank you for reply. I thought there was a simpler way, but I know there wasn't. it was nice to know that. So I write if statement before YiEqn, and it works. OF is so complex... nago |
|
May 30, 2019, 02:13 |
|
#4 | |
Member
Vivek
Join Date: Mar 2018
Location: India
Posts: 54
Rep Power: 8 |
Quote:
I am also getting the same error when using the ternary operator. Can you share us how did you implement if statement before fvSclarMatrix to achieve mass_source condition Thanks, Vivek S |
||
Tags |
openfoam 2.3.1 |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Source Term due to evaporation in energy transport equation | styleworker | OpenFOAM Programming & Development | 3 | September 7, 2022 04:09 |
[OpenFOAM.org] Patches to compile OpenFOAM 2.2 on Mac OS X | gschaider | OpenFOAM Installation | 136 | October 10, 2017 18:25 |
polynomial BC | srv537 | OpenFOAM Pre-Processing | 4 | December 3, 2016 10:07 |
"parabolicVelocity" in OpenFoam 2.1.0 ? | sawyer86 | OpenFOAM Running, Solving & CFD | 21 | February 7, 2012 12:44 |
DxFoam reader update | hjasak | OpenFOAM Post-Processing | 69 | April 24, 2008 02:24 |