CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

If statement in OpenFoam

Register Blogs Community New Posts Updated Threads Search

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   May 12, 2016, 01:25
Default If statement in OpenFoam
  #1
Member
 
Upuli
Join Date: Feb 2016
Posts: 68
Rep Power: 10
upuli is on a distinguished road
dear members
I want to add an if statement to an OpenFOAM solver. There's a variable gastotalmass. If this variable(gastotalmass) is not equal to 0.0 the other variables will be calculated.It is written in the programme as below.

{
if (gastotalmass=0.0)
{

volScalarField YCO
(
"YCO",
mCO/(mCO+mCO2+mCH4+mH2+mH2O+mN2+mO2)
);

}
else
{
volScalarField YCO = 0.0
}
}
but I get the following error

variables.H:31:21: error: could not convert ‘gastotalmass.Foam::GeometricField<Type, PatchField, GeoMesh>:perator= [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]((* & Foam::dimensioned<double>((* &0.0))))’ from ‘void’ to ‘bool’
variables.H:72:22: error: conversion from ‘double’ to non-scalar type ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ requested
variables.H:74:22: error: conversion from ‘double’ to non-scalar type ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ requested
variables.H:76:23: error: conversion from ‘double’ to non-scalar type ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ requested
variables.H:78:22: error: conversion from ‘double’ to non-scalar type ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ requested
variables.H:80:23: error: conversion from ‘double’ to non-scalar type ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ requested
variables.H:82:22: error: conversion from ‘double’ to non-scalar type ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ requested
variables.H:84:21: error: conversion from ‘double’ to non-scalar type ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ requested



can someone please help me to solve this.
upuli is offline   Reply With Quote

 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Frequently Asked Questions about Installing OpenFOAM wyldckat OpenFOAM Installation 3 November 14, 2023 11:58
OpenFOAM Training, London, Chicago, Munich, Sep-Oct 2015 cfd.direct OpenFOAM Announcements from Other Sources 2 August 31, 2015 13:36
How to use if statement in openFoam solver? rapierrz OpenFOAM Programming & Development 7 August 4, 2015 05:19
OpenFOAM Foundation Releases OpenFOAM v2.3.0 opencfd OpenFOAM Announcements from OpenFOAM Foundation 3 December 23, 2014 03:43
OpenFOAM Foundation releases OpenFOAM 2.2.2 opencfd OpenFOAM Announcements from ESI-OpenCFD 0 October 14, 2013 07:18


All times are GMT -4. The time now is 23:59.