Problem with pow and volScalarField

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

 May 7, 2012, 08:15 Problem with pow and volScalarField #1 New Member   Join Date: Jun 2010 Location: Germany Posts: 6 Rep Power: 7 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 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 & rhoCalc = U_.mesh().lookupObject("rho_ps"); //calculation n and k volScalarField K = ka_ * rhoCalc + kb_; volScalarField N = na_ * rhoCalc + nb_; //Calculation nu tmp 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::dimensioned(const char [2], double, const Foam::dimensionSet&)’ /SimSoftware/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedType.C:107: note: candidates are: Foam::dimensioned::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::dimensioned(const Foam::word&, Foam::Istream&) [with Type = double] /SimSoftware/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedType.C:82: note: Foam::dimensioned::dimensioned(Foam::Istream &) [with Type = double] /SimSoftware/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedType.H:95: note: Foam::dimensioned::dimensioned(const Type&) [with Type = double] /SimSoftware/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedType.C:69: note: Foam::dimensioned::dimensioned(const Foam::word&, const Foam::dimensioned&) [with Type = double] /SimSoftware/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedType.C:55: note: Foam::dimensioned::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::dimensioned(const Foam::dimensioned&) Last edited by _Stefan_; May 7, 2012 at 09:24.

May 7, 2012, 09:33
#2
Senior Member

Ben K
Join Date: Feb 2010
Posts: 140
Rep Power: 10
Quote:
 Originally Posted by _Stefan_ 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

 May 8, 2012, 05:06 #3 New Member   Join Date: Jun 2010 Location: Germany Posts: 6 Rep Power: 7 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 nu = K * N1;```

 May 12, 2012, 13:09 #4 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 229 Rep Power: 9 Did you try N.value() instead of N within the exponent ?

 May 14, 2012, 07:30 #5 New Member   Join Date: Jun 2010 Location: Germany Posts: 6 Rep Power: 7 Hi Cyp, I tried it but there are the Error: error: ‘struct Foam::volScalarField’ has no member named ‘value’

 May 14, 2012, 18:23 #6 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 229 Rep Power: 9 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.

 May 15, 2012, 04:39 #7 New Member   Join Date: Jun 2010 Location: Germany Posts: 6 Rep Power: 7 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.

August 7, 2012, 07:38
#8
Senior Member

Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 149
Rep Power: 6
Quote:
 Originally Posted by _Stefan_ 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

 August 7, 2012, 07:45 #9 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 229 Rep Power: 9 Have you tried without any .value() ? Else, I suggest to do : A = c*min(0,B);

 August 7, 2012, 07:49 #10 Senior Member   mahdi abdollahzadeh Join Date: Mar 2011 Location: Covilha,Portugal Posts: 149 Rep Power: 6 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) .

August 7, 2012, 07:50
#11
Senior Member

Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 229
Rep Power: 9
Quote:
 Originally Posted by mm.abdollahzadeh 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.

 August 7, 2012, 07:56 #12 Senior Member   mahdi abdollahzadeh Join Date: Mar 2011 Location: Covilha,Portugal Posts: 149 Rep Power: 6 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&)```

 August 7, 2012, 08:04 #13 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 229 Rep Power: 9 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.

 August 7, 2012, 08:05 #14 Senior Member   mahdi abdollahzadeh Join Date: Mar 2011 Location: Covilha,Portugal Posts: 149 Rep Power: 6 thanks Cyprein, it works

August 7, 2012, 11:04
#15
Senior Member

Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 149
Rep Power: 6
Quote:
 Originally Posted by mm.abdollahzadeh 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() ).

 Thread Tools Display Modes Linear Mode

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

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

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