|
[Sponsors] |
May 7, 2012, 09:15 |
Problem with pow and volScalarField
|
#1 |
New Member
Join Date: Jun 2010
Location: Germany
Posts: 6
Rep Power: 16 |
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.); 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. |
|
May 7, 2012, 10:33 |
|
#2 |
Senior Member
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19 |
||
May 8, 2012, 06:06 |
|
#3 |
New Member
Join Date: Jun 2010
Location: Germany
Posts: 6
Rep Power: 16 |
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; |
|
May 12, 2012, 14:09 |
|
#4 |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
Did you try N.value() instead of N within the exponent ?
|
|
May 14, 2012, 08:30 |
|
#5 |
New Member
Join Date: Jun 2010
Location: Germany
Posts: 6
Rep Power: 16 |
Hi Cyp,
I tried it but there are the Error: error: ‘struct Foam::volScalarField’ has no member named ‘value’ |
|
May 14, 2012, 19:23 |
|
#6 |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
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 |
|
May 15, 2012, 05:39 |
|
#7 |
New Member
Join Date: Jun 2010
Location: Germany
Posts: 6
Rep Power: 16 |
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()); |
|
August 7, 2012, 08:38 |
|
#8 | |
Senior Member
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15 |
Quote:
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, 08:45 |
|
#9 |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
Have you tried without any .value() ?
Else, I suggest to do : A = c*min(0,B); |
|
August 7, 2012, 08:49 |
|
#10 |
Senior Member
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15 |
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, 08:50 |
|
#11 | |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
Quote:
|
||
August 7, 2012, 08:56 |
|
#12 |
Senior Member
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15 |
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, 09:04 |
|
#13 |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
Althought it is not very elegant, the following snippet should works:
Code:
forAll(A, cellI) { A[cellI] = min(0,c.value()*B[cellI]); } |
|
August 7, 2012, 09:05 |
|
#14 |
Senior Member
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15 |
thanks Cyprein, it works
|
|
August 7, 2012, 12:04 |
|
#15 | |
Senior Member
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15 |
Quote:
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() ). |
||
April 14, 2019, 23:20 |
|
#16 |
Senior Member
Jianrui Zeng
Join Date: May 2018
Location: China
Posts: 157
Rep Power: 8 |
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. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
if statement for volScalarField | AnjaMiehe | OpenFOAM Programming & Development | 2 | April 24, 2012 08:01 |