|
[Sponsors] |
how to put if statement in between volScalarField and dimensionedScalar |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 21, 2021, 13:46 |
how to put if statement in between volScalarField and dimensionedScalar
|
#1 |
New Member
Sourav Hossain
Join Date: Mar 2019
Posts: 25
Rep Power: 7 |
Hi Foamers,
I have to put a if statement in between a volScalarField and dimensionedScalar. The part of the code is : ////////////////////////////////////////////////////////////// volScalarField y = mesh.C().component(vector::Y); volScalarField u = ustar*(((1.0-Y0)/(Y0-Foam::log(Y0)-1.0))*Foam::log(y)/(h*Y0))); if(y >= Y0*h && y <= h ) { u = ustar*(((1.0-Y0)/(Y0-Foam::log(Y0)-1.0))*Foam::log(y/(h*Y0))); } else { u = 0.0; } dimensionedScalar Y0 ( transportProperties.lookup("Y0") ); dimensionedScalar h ( transportProperties.lookup("h") ); ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// After running the code I'm getting this error : .C:82:24: error: no match for ‘operator<=’ (operand types are ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ and ‘Foam::dimensionedScalar {aka Foam::dimensioned<double>}’) if(y >= Y0*h && y <= h ) Last edited by sourav8016; August 21, 2021 at 13:50. Reason: previous one was incomplete |
|
August 23, 2021, 05:06 |
|
#2 |
Senior Member
Join Date: Dec 2019
Location: Cologne, Germany
Posts: 369
Rep Power: 8 |
Quote:
so you are getting a dimension error. if you want to ignore it, which i do not recommend, you can just grab the values from both sides and compare the values. but the better way would be to fix the dimensions. |
|
August 23, 2021, 06:24 |
|
#3 | |
New Member
Sourav Hossain
Join Date: Mar 2019
Posts: 25
Rep Power: 7 |
Quote:
forAll(mesh.C(), i) { if((y[i] >= Y0.value()*h.value()) && (y[i] <= h.value()) ) { u[i] = ustar.value()*(((1.0-Y0.value())/(Y0.value()-Foam::log(Y0.value())-1.0))*Foam::log(y[i]/(h.value()*Y0.value()))); } else { u[i] = 0.0; } } |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to change a dimensionedScalar into volScalarField | purnp2 | OpenFOAM Programming & Development | 3 | May 31, 2019 17:37 |
changing a volScalarField to a dimensionedScalar | wschosta | OpenFOAM Running, Solving & CFD | 5 | May 6, 2015 11:20 |
make a dimensionedScalar to be volScalarField | sharonyue | OpenFOAM Programming & Development | 4 | April 2, 2014 06:44 |
dimensionedScalar + volScalarField is evaluated elementwisely ? | tianyikillua | OpenFOAM Programming & Development | 1 | March 30, 2012 04:12 |
Confused about how OF handles operation between volScalarField and dimensionedScalar | Edy | OpenFOAM | 3 | September 30, 2010 11:07 |