CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   error: no match for ‘operator>’ (https://www.cfd-online.com/Forums/openfoam/92894-error-no-match-operator.html)

hawkeye321 September 28, 2011 13:32

error: no match for ‘operator>’
 
Hi Guys
I want to add a if condition in the following form to my code

if (hStar > TLSTar)
{
gl = 1;
}

but when I compile it the following error is being produced
"error: no match for ‘operator>’ in ‘hStar > TLStar’"
hStar is a VolScalarField and TLStar is dimensioned scalar field.

I would appreciate if you help me fix it!

Amir September 28, 2011 16:53

Quote:

Originally Posted by mahdiiowa (Post 325952)
Hi Guys
I want to add a if condition in the following form to my code

if (hStar > TLSTar)
{
gl = 1;
}

but when I compile it the following error is being produced
"error: no match for ‘operator>’ in ‘hStar > TLStar’"
hStar is a VolScalarField and TLStar is dimensioned scalar field.

I would appreciate if you help me fix it!

They should be the same type!
try this:
(hStar.value()) > (TLSTar.value())

hawkeye321 September 28, 2011 17:19

Hi AMIR
Thanks for your comment. I tried
(hStar.value()) > (TLSTar.value())
but it gives another error

error: ‘struct Foam::volScalarField’ has no member named ‘Value’

nimasam September 28, 2011 17:22

Quote:

Originally Posted by mahdiiowa (Post 325952)
Hi Guys
I want to add a if condition in the following form to my code

if (hStar > TLSTar)
{
gl = 1;
}

but when I compile it the following error is being produced
"error: no match for ‘operator>’ in ‘hStar > TLStar’"
hStar is a VolScalarField and TLStar is dimensioned scalar field.

I would appreciate if you help me fix it!

forAll( hStar, celli){
if (hStar[celli] > TLSTar.value())
{
gl[celli] = 1.0;
}
}

gl is volScalarField ?

hawkeye321 September 28, 2011 17:24

Thanks NIMA, Yep gl is volScalarField!
I will try that right away!

hawkeye321 September 28, 2011 17:45

Nima and Amir Thanks!
The problem has been fixed and the code sounds good now!!

semaviso October 25, 2011 07:46

thanx guys, this helped. i had the same error.

semaviso October 25, 2011 09:10

error: no match for 'operator=='
 
Hi guys

I am trying solve the following:

forAll(mAbsorbed, celli)
{
if(mAbsorbed[celli] <= rhoSs.value())
{
solve(fvm::ddt(1.0-epsVoid,rhoS) == mAbsorbed[celli]);
}
}
else
{
Info<< "\nrhoS - MHydride density = " << max(rhoS).value();
Info<< " has reached saturation density of " << rhoSs.value();
Info<< " kg/m^3.\n"<< endl;
}

so that if the value of mAbsorbed (a volScalrField) exceeds or equals the value of rhoSs a dimensionedScalar the program should a statement as above.
but I get the following error:

error: no match for 'operator==' in 'Foam::fvm::ddt(const Foam::dimensionedScalar&, Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&) [with Type = double](((Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&)(& rhoS))) == mAbsorbed.Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::<anonymous>.Foam::DimensionedField <double, Foam::volMesh>::<anonymous>.Foam::Field<double>::< anonymous>.Foam::List<double>::<anonymous>.Foam::U List<T>::operator[] [with T = double](celli)'

...

please help me fix this error.

thank u.

nimasam October 25, 2011 10:42

you are going to import a strange format in openFOAM structure, it cant resolve ur data type, you are going to solve different variable from dimensionedScalar, UList and volScalarField :) its impossible in this way!

semaviso October 25, 2011 11:00

hi nimasam

Thanks, I tried it and I get:

error: 'deltatime' was not declared in this scope.

and i tried deltaTime and i get same error.

how do i declare deltatime?

nimasam October 25, 2011 11:06

hi dear Sibusiso
could you explain what you are going to solve? send ur equation here.
what are these variables ?

semaviso October 25, 2011 11:37

http://ywang.eng.uci.edu/Publication...age%20beds.pdf

from the article above. i am trying to solve these equations: equation 1, 2, 9, 10 and 11.

where:
rhoS is the solid density in equation 9
mAbsorbed is the hydrogen reaction rate (source term) from equation 10
rhoSs is the saturated solid density constant from equation 10 too.

hope this is clear enough, i really need help.

nimasam October 25, 2011 13:10

:) dear Sibusiso
let me ask more clear what variable should be solved among these variables?
rhoS , mAbsorbed or rhoSs

semaviso October 25, 2011 19:34

hello nima

rhoS is the variable to be solved in my first post.


forAll(mAbsorbed, celli)
{
if(mAbsorbed[celli] <= rhoSs.value())
{
solve(fvm::ddt(1.0-epsVoid,rhoS) == mAbsorbed[celli]);
}
}
else
{
Info<< "\nrhoS - MHydride density = " << max(rhoS).value();
Info<< " has reached saturation density of " << rhoSs.value();
Info<< " kg/m^3.\n"<< endl;
}


thank you.

nimasam October 26, 2011 04:26

dear sibusiso
why dont you combine equations 9 and 10, then finally your equation will be
A*ddt(rhoS) - B* rhoS + B*rhoSS =0
which is a linear ode and have definte solution as a function of :
rhos = f (rhoSS, time)
then implement rhos equation in your code!

semaviso October 26, 2011 05:58

1 Attachment(s)
Dear Nima

equation 9 calculates the reaction rate (Sm) which I also need to for equation 1 and 6 and need to track how fast does the source term (mAdsorbed) changes.

mAbsorbed = max(Sm) - min(Sm);

so i think i need equation 10.

just realised that I had made a mistake in the following code (bolded) instead of the source term there should be the density of the solid rhoS. sorry about that.


forAll(mAbsorbed, celli)
{
if(mAbsorbed[celli] <= rhoSs.value())
{
solve(fvm::ddt(1.0-epsVoid,rhoS) == mAbsorbed[celli]);
}
else
{
Info<< "\nrhoS - MHydride density = " << max(rhoS).value();
Info<< " has reached saturation density of " << rhoSs.value();
Info<< " kg/m^3.\n"<< endl;
}
}

I fixed it as follows:

forAll(mAbsorbed, celli)
{
if(rhoS[celli] <= rhoSs.value())
{
solve(fvm::ddt(1.0-epsVoid,rhoS) == mAbsorbed);
}
else
{
Info<< "\nrhoS - MHydride density = " << max(rhoS).value();
Info<< " has reached saturation density of " << rhoSs.value();
Info<< " kg/m^3.\n"<< endl;
}

}
and it compiles and runs but it does not get out I have to manually terminate it, please check attached txt file.

nimasam October 26, 2011 06:20

its some how obvious it iterates over ur grids so! it solves your equations on the numbers of your grids! as i said before this combination does not work for you:) you should solve rhoS manually! and implement rhoS function!

semaviso October 26, 2011 06:24

thank you Nima

let me try it

lx882211 June 3, 2016 04:27

Quote:

Originally Posted by hawkeye321 (Post 325952)
Hi Guys
I want to add a if condition in the following form to my code

if (hStar > TLSTar)
{
gl = 1;
}

but when I compile it the following error is being produced
"error: no match for ‘operator>’ in ‘hStar > TLStar’"
hStar is a VolScalarField and TLStar is dimensioned scalar field.

I would appreciate if you help me fix it!

I meet a problem in Openfoam 2.3.0, reactingFoam, i need the data of CH4 reaction rate, but i failed to autowrite it like U or Yi.

First i added this code in the CreatField.H,

volScalarField Rrate
(
IOobject
(
"Rrate",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("Rrate", dimMass/dimVolume/dimTime, 0.0)
);

Then, i added this code in YEqn,

forAll(Y, i)
{
if (Y[i].name() != "CH4")
Rrate = reaction->R(Yi);
}

After wmake, it shows

YEqn.H:26:14: error: no match for ‘operator=’ (operand types are ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ and ‘Foam::tmp<Foam::fvMatrix<double> >’)
Rrate = reaction->R(Yi);

Can you tell me how to do that? Thank you very much.

QMW March 10, 2021 03:47

no match for ‘operator<’ (operand types are ‘Foam::volScalarField {aka Foam::Geometri
 
Hi everyone
I am a beginner of openfoam.I want to add a if condition in the following form to my turbulence model code

volScalarField::Internal rek
(
this->rho_*sqrt(k_)*y_/this->nu()
);
if(rek > 10)
...

but when I compile it the following error is being produced
"no match for ‘operator<’ (operand types are ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ and ‘int’)"

I would appreciate if you help me:)


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