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

Problem with pow and volScalarField

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree3Likes
  • 1 Post By Cyp
  • 1 Post By _Stefan_
  • 1 Post By Cyp

Reply
 
LinkBack Thread Tools Display Modes
Old   May 7, 2012, 08:15
Default Problem with pow and volScalarField
  #1
New Member
 
Join Date: Jun 2010
Location: Germany
Posts: 6
Rep Power: 7
_Stefan_ is on a distinguished road
Hi,

I want to implement an new Order to Calculate the Viscosity nu.

Ostwald Waele Potential Function

tau = k * strain rate ^n

k and n are model Parameter and depend on rho
k=a*rho+b
n=c*rho+d

I got a, b, c, d from some experiments.

The equation for the rotation rheometer:

nu = tau / strain rate

What I have done:
Code:
//read strain rate
    tmp<volScalarField> sr(strainRate());

//Parameter 
    dimensionedScalar ka_("ka_",dimensionSet(0,2,-1,0,0,0,0), 0.1202); 
    dimensionedScalar kb_("kb_",dimensionSet(1,-1,-1,0,0,0,0), 24.912); 
 
    dimensionedScalar na_("na_",dimensionSet(-1,3,0,0,0,0,0), 0.0005); 
    dimensionedScalar nb_("nb_",dimensionSet(0,0,0,0,0,0,0), 0.2246);

//read ScalarFeldes rho_ps 
    const tmp <volScalarField> & rhoCalc = U_.mesh().lookupObject<volScalarField>("rho_ps");

//calculation n and k 
    volScalarField K = ka_ * rhoCalc + kb_; 
    volScalarField N = na_ * rhoCalc + nb_;

//Calculation nu
    tmp <volScalarField> nu = K * Foam::pow(max(tone * sr(),VSMALL),N-1.);
tone is only a dimensioned scalar with 1[s] to make sr() dimensionless.

My Problem is that it did not compile.
If I change N in the pow function to an dimensioned scalar it works fine.
Is it possible that, Foam:ow (volScalarField, volScalarField) does not work?

Here the error massage:

/SimSoftware/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricScalarField.C:189: error: no matching function for call to ‘Foam::dimensioned<double>::dimensioned(const char [2], double, const Foam::dimensionSet&)’
/SimSoftware/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedType.C:107: note: candidates are: Foam::dimensioned<Type>::dimensioned(const Foam::word&, const Foam::dimensionSet&, Foam::Istream&) [with Type = double]
/SimSoftware/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedType.C:94: note: Foam::dimensioned<Type>::dimensioned(const Foam::word&, Foam::Istream&) [with Type = double]
/SimSoftware/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedType.C:82: note: Foam::dimensioned<Type>::dimensioned(Foam::Istream &) [with Type = double]
/SimSoftware/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedType.H:95: note: Foam::dimensioned<Type>::dimensioned(const Type&) [with Type = double]
/SimSoftware/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedType.C:69: note: Foam::dimensioned<Type>::dimensioned(const Foam::word&, const Foam::dimensioned<Type>&) [with Type = double]
/SimSoftware/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedType.C:55: note: Foam::dimensioned<Type>::dimensioned(const Foam::word&, const Foam::dimensionSet&, Type) [with Type = double]
/SimSoftware/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedScalarFwd.H:42: note: Foam::dimensioned<double>::dimensioned(const Foam::dimensioned<double>&)

Last edited by _Stefan_; May 7, 2012 at 09:24.
_Stefan_ is offline   Reply With Quote

Old   May 7, 2012, 09:33
Default
  #2
Senior Member
 
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 10
benk is on a distinguished road
Quote:
Originally Posted by _Stefan_ View Post
Is it possible that, Foam:ow (volScalarField, volScalarField) does not work?
I'm not sure about the answer to your question, but my first instinct would be to do this sort of operation within a forAll loop
benk is offline   Reply With Quote

Old   May 8, 2012, 05:06
Default
  #3
New Member
 
Join Date: Jun 2010
Location: Germany
Posts: 6
Rep Power: 7
_Stefan_ is on a distinguished road
Thank you,

I think it is not the best way but it works:

Code:
    Info << "calculate min strainrate" << endl; 
    volScalarField sr1 = max(sr()*tone,VSMALL);//[-] 

 
    Info << "forAll loop" << endl; 
    forAll(sr1, cellI)  
    { 
        N1[cellI] = Foam::pow(sr1[cellI],N[cellI]-1); 
    }

    tmp <volScalarField> nu =     K * N1;
_Stefan_ is offline   Reply With Quote

Old   May 12, 2012, 13:09
Default
  #4
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 229
Rep Power: 9
Cyp is on a distinguished road
Did you try N.value() instead of N within the exponent ?
Cyp is offline   Reply With Quote

Old   May 14, 2012, 07:30
Default
  #5
New Member
 
Join Date: Jun 2010
Location: Germany
Posts: 6
Rep Power: 7
_Stefan_ is on a distinguished road
Hi Cyp,

I tried it but there are the Error:

error: ‘struct Foam::volScalarField’ has no member named ‘value’
_Stefan_ is offline   Reply With Quote

Old   May 14, 2012, 18:23
Default
  #6
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 229
Rep Power: 9
Cyp is on a distinguished road
Yes, sorry, .value is valid if N is a dimensionedScalar.

in your case, if you already have declared A, B and C as volScalarField, you can performed :

Code:
A.internalField() = Foam::pow(B.internalField(),C.internalField());

The operation does not include the operation upon BC.

Best,
Cyp
mm.abdollahzadeh likes this.
Cyp is offline   Reply With Quote

Old   May 15, 2012, 04:39
Default
  #7
New Member
 
Join Date: Jun 2010
Location: Germany
Posts: 6
Rep Power: 7
_Stefan_ is on a distinguished road
Thanks, Cyp that is what I need. I also need the calculation on the boundary so I added:

Code:
A.internalField() = Foam::pow(B.internalField(),C.internalField());
A.boundaryField() = Foam::pow(B.boundaryField(),C.boundaryField());
And it works fine!
mm.abdollahzadeh likes this.
_Stefan_ is offline   Reply With Quote

Old   August 7, 2012, 07:38
Default
  #8
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 149
Rep Power: 6
mm.abdollahzadeh is on a distinguished road
Quote:
Originally Posted by _Stefan_ View Post
Thanks, Cyp that is what I need. I also need the calculation on the boundary so I added:

Code:
A.internalField() = Foam::pow(B.internalField(),C.internalField());
A.boundaryField() = Foam::pow(B.boundaryField(),C.boundaryField());
And it works fine!
Hi Stefan and Cyprien

I want to calculate the following relation.

A=min(0,c*B);

Which A and B are Volscalerfield and c diminesedscaler.
for the c i have used .value().

But I am receiving Eror when I have the B in the min function.
I have tried your suggestion but it does not work.

Could you help me?

Best
Mahdi
mm.abdollahzadeh is offline   Reply With Quote

Old   August 7, 2012, 07:45
Default
  #9
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 229
Rep Power: 9
Cyp is on a distinguished road
Have you tried without any .value() ?

Else, I suggest to do :

A = c*min(0,B);
Cyp is offline   Reply With Quote

Old   August 7, 2012, 07:49
Default
  #10
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 149
Rep Power: 6
mm.abdollahzadeh is on a distinguished road
Yes I have tried, even for the follwing equations if I remove the .value() it is giving error.

A=min(0,c.value());
A.internalField()=min(0,c.value());
A.boundaryField()=min(0,c.value());

which is working because I removed the B. (but when I am adding the B it gives Error) .
mm.abdollahzadeh is offline   Reply With Quote

Old   August 7, 2012, 07:50
Default
  #11
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 229
Rep Power: 9
Cyp is on a distinguished road
Quote:
Originally Posted by mm.abdollahzadeh View Post
Yes I have tried, even for the follwing equations if I remove the .value() it is giving error.

A=min(0,c.value());
A.internalField()=min(0,c.value());
A.boundaryField()=min(0,c.value());

which is working because I removed the B. (but when I am adding the B it gives Error) .
see my edited post.
Cyp is offline   Reply With Quote

Old   August 7, 2012, 07:56
Default
  #12
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 149
Rep Power: 6
mm.abdollahzadeh is on a distinguished road
Thanks again ,,, I think the problem is not related the "c" .

the error is :

Code:
error: no matching function for call to 'min(int, Foam::volScalarField&)'
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/label.H:213:1: note: candidates are: char Foam::min(char, char)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/label.H:214:1: note:                 short int Foam::min(short int, short int)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/label.H:215:1: note:                 int Foam::min(int, int)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/label.H:216:1: note:                 long int Foam::min(long int, long int)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/label.H:217:1: note:                 long long int Foam::min(long long int, long long int)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/label.H:219:1: note:                 unsigned char Foam::min(unsigned char, unsigned char)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/label.H:220:1: note:                 short unsigned int Foam::min(short unsigned int, short unsigned int)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/label.H:221:1: note:                 unsigned int Foam::min(unsigned int, unsigned int)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/label.H:222:1: note:                 long unsigned int Foam::min(long unsigned int, long unsigned int)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/label.H:223:1: note:                 long long unsigned int Foam::min(long long unsigned int, long long unsigned int)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/label.H:225:1: note:                 long int Foam::min(int, long int)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/label.H:226:1: note:                 long long int Foam::min(int, long long int)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/label.H:227:1: note:                 long long int Foam::min(long long int, int)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/doubleFloat.H:78:1: note:                 double Foam::min(double, double)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/doubleFloat.H:79:1: note:                 double Foam::min(double, float)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/doubleFloat.H:80:1: note:                 double Foam::min(float, double)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/doubleFloat.H:81:1: note:                 float Foam::min(float, float)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/doubleFloat.H:82:1: note:                 double Foam::min(double, int)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/doubleFloat.H:83:1: note:                 double Foam::min(int, double)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/doubleFloat.H:84:1: note:                 double Foam::min(double, long int)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/doubleFloat.H:85:1: note:                 double Foam::min(long int, double)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/doubleFloat.H:86:1: note:                 float Foam::min(float, int)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/doubleFloat.H:87:1: note:                 float Foam::min(int, float)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/doubleFloat.H:88:1: note:                 float Foam::min(float, long int)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/doubleFloat.H:89:1: note:                 float Foam::min(long int, float)
/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude/dimensionSet.H:214:29: note:                 Foam::dimensionSet Foam::min(const Foam::dimensionSet&, const Foam::dimensionSet&)
mm.abdollahzadeh is offline   Reply With Quote

Old   August 7, 2012, 08:04
Default
  #13
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 229
Rep Power: 9
Cyp is on a distinguished road
Althought it is not very elegant, the following snippet should works:


Code:
    forAll(A, cellI)
    {
       A[cellI] = min(0,c.value()*B[cellI]);
    }
mm.abdollahzadeh likes this.
Cyp is offline   Reply With Quote

Old   August 7, 2012, 08:05
Default
  #14
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 149
Rep Power: 6
mm.abdollahzadeh is on a distinguished road
thanks Cyprein, it works
mm.abdollahzadeh is offline   Reply With Quote

Old   August 7, 2012, 11:04
Default
  #15
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 149
Rep Power: 6
mm.abdollahzadeh is on a distinguished road
Quote:
Originally Posted by mm.abdollahzadeh View Post
Yes I have tried, even for the follwing equations if I remove the .value() it is giving error.

A=min(0,c.value());
A.internalField()=min(0,c.value());
A.boundaryField()=min(0,c.value());

which is working because I removed the B. (but when I am adding the B it gives Error) .
Dear Cyprein

I have done it with internalfield. the problem was to replace 0 with scalar(0) but there is one problem.

A.dimensionedInternalField()=min(scalar(0),B.dimen sionedInternalField()); A.boundaryField()=min(scalar(0),B.boundaryField()) ;

the above equation are compiling. but when I am replacing the dimensionedInternalField() with InternalField() it gives the error.???? ( and there is no dimensionedboundaryField() ).
mm.abdollahzadeh is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
if statement for volScalarField AnjaMiehe OpenFOAM Programming & Development 2 April 24, 2012 07:01


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