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

Problem with pow and volScalarField

Register Blogs Community New Posts Updated Threads Search

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 7, 2012, 09:15
Default Problem with pow and volScalarField
  #1
New Member
 
Join Date: Jun 2010
Location: Germany
Posts: 6
Rep Power: 16
_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 10:24.
_Stefan_ is offline   Reply With Quote

Old   May 7, 2012, 10:33
Default
  #2
Senior Member
 
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19
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, 06:06
Default
  #3
New Member
 
Join Date: Jun 2010
Location: Germany
Posts: 6
Rep Power: 16
_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, 14:09
Default
  #4
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
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, 08:30
Default
  #5
New Member
 
Join Date: Jun 2010
Location: Germany
Posts: 6
Rep Power: 16
_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, 19:23
Default
  #6
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
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, 05:39
Default
  #7
New Member
 
Join Date: Jun 2010
Location: Germany
Posts: 6
Rep Power: 16
_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, 08:38
Default
  #8
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15
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, 08:45
Default
  #9
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
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, 08:49
Default
  #10
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15
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, 08:50
Default
  #11
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
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, 08:56
Default
  #12
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15
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, 09:04
Default
  #13
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
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, 09:05
Default
  #14
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15
mm.abdollahzadeh is on a distinguished road
thanks Cyprein, it works
mm.abdollahzadeh is offline   Reply With Quote

Old   August 7, 2012, 12:04
Default
  #15
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15
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

Old   April 14, 2019, 23:20
Default
  #16
Senior Member
 
Jianrui Zeng
Join Date: May 2018
Location: China
Posts: 157
Rep Power: 8
calf.Z is on a distinguished road
If want to find the minimum of fMu, 1.0 and scalar(0.5)+0.0025*this->Rt() where fMu and Rt() are tmp<volScalarField>.

fMu(const volScalarField& Rt)
tmp<volScalarField> Ry(sqrt(k_)*y_/this->nu());
return sqr(scalar(1) - exp(-0.0165*Ry))*(scalar(1) + 20.5/(Rt + SMALL));

Rt()
return sqr(k_)/(this->nu()*epsilon_);

How should I do it? Thank you.
calf.Z is offline   Reply With Quote

Reply


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
if statement for volScalarField AnjaMiehe OpenFOAM Programming & Development 2 April 24, 2012 08:01


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