|
[Sponsors] |
August 24, 2010, 10:10 |
Programming issues
|
#1 |
Senior Member
Vesselin Krastev
Join Date: Jan 2010
Location: University of Tor Vergata, Rome
Posts: 368
Rep Power: 20 |
Hi everybody, I have some compiling problems which are very probably due to my lack of knowledge in programming inside the OpenFOAM/C++ frame...however, I'm trying to compile a .C source file which contains the following piece of code:
tmp<volScalarField> kOmegaSI::kiKappa() const { return (1/(pow(omega_,3.0)))*((fvc::grad(k_))&(fvc::grad(ome ga_))); } tmp<volScalarField> kOmegaSI::fBetaStar() const { { if (kiKappa() > scalar(0.0)) { return ((scalar(680.0)+sqr(kiKappa()))/(scalar(400.0)+sqr(kiKappa()))); } else { return scalar(1.0); } } } and this is the error message after runninng the wmake utility kOmegaSI/kOmegaSI.C:56: error: no match for ‘operator>’ in ‘Foam::incompressible::RASModels::kOmegaSI::kiKapp a() const() > 0.0’ kOmegaSI/kOmegaSI.C:60: error: conversion from ‘double’ to non-scalar type ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ requested Line 56 is: if (kiKappa() > scalar(0.0)) { Line 60 is: return scalar(1.0); Can someone please give me some help about it? Thank you in advance PS - What I'm trying to do is to implement the revised version of Wilcox's k-omega turbulence model. For the definition of the correction-functions of the closure coefficients (such as fBetaStar) I've took some inspiration from the Launder-Sharma Low-Re k-epsilon model source code. |
|
August 24, 2010, 12:41 |
|
#2 |
Senior Member
Vesselin Krastev
Join Date: Jan 2010
Location: University of Tor Vergata, Rome
Posts: 368
Rep Power: 20 |
Any replies? I could post more information if necessary...
|
|
August 24, 2010, 12:50 |
|
#3 |
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29 |
kiKappa seems to be a tmp<volScalarField>
so what does it mean when you write kiKappa() > 0? Thats what it tells you on the line: kOmegaSI/kOmegaSI.C:56: error: no match for ‘operator>’ in ‘Foam::incompressible::RASModels::kOmegaSI::kiKapp a() const() > 0.0’ Does it mean that every element of kiKappa should be larger than zero? what about the ones that are not? you cant compare fields to a scalar, its like you have a vector a=(1, 2, 3) and you write a > 0. What does that mean?...nothing. You have to rethink your code there. |
|
August 24, 2010, 13:36 |
|
#4 | |
Senior Member
Vesselin Krastev
Join Date: Jan 2010
Location: University of Tor Vergata, Rome
Posts: 368
Rep Power: 20 |
Quote:
As you have noticed, I've made some conceptual mistakes, so I will really appreciate if you could give me some advices about how to correct the code...anyway, thank you once again |
||
August 24, 2010, 21:21 |
|
#5 |
Senior Member
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 18 |
try kiKappa.value() > 0.
I am not sure it will work or not |
|
August 25, 2010, 03:34 |
|
#6 |
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29 |
I havent compiled this, so it probably wont work, but you have to do it
something like this. you probably dont have access to runTime and mesh, so you need to replace runTime_ and mesh_ with the appropriate equivalents and set the correct dimension in dimensionSet Code:
tmp<volScalarField> kOmegaSI::fBetaStar() const { tmp<volScalarField> tBeta ( new volScalarField ( IOobject ( "fBetaStar", runTime_.timeName(), mesh_, IOobject::NO_READ, IOobject::NO_WRITE ), mesh_, dimensionedScalar("one", dimensionSet(0, 0, 0, 0, 0), 1.0) ) ); forAll(tBeta(), i) { if (kiKappa()[i] > 0) { tBeta()[i] = .... } } return tBeta; } |
|
August 25, 2010, 05:56 |
|
#7 |
Senior Member
Vesselin Krastev
Join Date: Jan 2010
Location: University of Tor Vergata, Rome
Posts: 368
Rep Power: 20 |
||
August 25, 2010, 05:57 |
|
#8 | |
Senior Member
Vesselin Krastev
Join Date: Jan 2010
Location: University of Tor Vergata, Rome
Posts: 368
Rep Power: 20 |
Quote:
|
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
A book for a beginner wanting to learn programming | frank | Main CFD Forum | 9 | May 13, 2014 00:15 |
OpenFoam programming | prapanj | OpenFOAM | 10 | March 18, 2010 08:23 |
Programming for CFD | atmcfd | Main CFD Forum | 7 | September 9, 2009 02:48 |
Programming in OpenFOAM | vinu | OpenFOAM | 2 | July 11, 2009 11:16 |
new CFD Programming Forum | Thinker | Main CFD Forum | 14 | November 19, 2002 17:03 |