CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Implementing new viscosity model (http://www.cfd-online.com/Forums/openfoam-solving/57939-implementing-new-viscosity-model.html)

prjohnston February 16, 2009 23:03

Hello, I am trying to imple
 
Hello,

I am trying to implement a generalised power law model for blood viscosity (Ballyk et al, Biorheology, 31 (5), pp 565-586 (1994). In this model the exponent in the power law is a function of the local strain rate. My implemented calcNu() funciton is:

// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //

Foam::tmp<foam::volscalarfield>
Foam::viscosityModels::GeneralisedPowerLaw::calcNu () const
{
tmp<volscalarfield> sr(strainRate());
return ((nu0_*exp(-(scalar(1)+(sr())/a_)*exp(-b_/(sr())))+nuInf_)*pow(sr(),(nInf_-n0_*e xp(-(scalar(1)+sr()/c_)*exp(-d_/sr()))-scalar(1))));
}

Unfortunately, this fails to compile giving the following error messages:
wmake
Making dependency list for source file viscosityModels/GeneralisedPowerLaw/GeneralisedPowerLaw.C
SOURCE=viscosityModels/GeneralisedPowerLaw/GeneralisedPowerLaw.C ; g++ -m32 -Dlinux -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I.. -I/home/peter/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/peter/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude -I/home/peter/OpenFOAM/OpenFOAM-1.5/src/OSspecific/Unix/lnInclude -fPIC -pthread -c $SOURCE -o Make/linuxGccDPOpt/GeneralisedPowerLaw.o
/home/peter/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricScalarField.C: In function 'Foam::tmp<foam::geometricfield<double,> > Foam::pow(const Foam::GeometricField<double,>&, const Foam::tmp<foam::geometricfield<double,> >&) [with PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]':
viscosityModels/GeneralisedPowerLaw/GeneralisedPowerLaw.C:61: instantiated from here
/home/peter/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricScalarField.C: 220: error: no matching function for call to 'Foam::dimensioned<double>::dimensioned(const char [2], double, const Foam::dimensionSet&)'
/home/peter/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedType.C:112: note: candidates are: Foam::dimensioned<type>::dimensioned(const Foam::word&, const Foam::dimensionSet&, Foam::Istream&) [with Type = double]
/home/peter/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedType.C:98: note: Foam::dimensioned<type>::dimensioned(const Foam::word&, Foam::Istream&) [with Type = double]
/home/peter/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedType.C:85: note: Foam::dimensioned<type>::dimensioned(Foam::Istream &) [with Type = double]
/home/peter/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedType.H:95: note: Foam::dimensioned<type>::dimensioned(const Type&) [with Type = double]
/home/peter/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedType.C:73: note: Foam::dimensioned<type>::dimensioned(const Foam::word&, const Foam::dimensioned<type>&) [with Type = double]
/home/peter/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedType.C:60: note: Foam::dimensioned<type>::dimensioned(const Foam::word&, const Foam::dimensionSet&, Type) [with Type = double]
/home/peter/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedScalarFwd.H: 42: note: Foam::dimensioned<double>::dimensioned(const Foam::dimensioned<double>&)
make: *** [Make/linuxGccDPOpt/GeneralisedPowerLaw.o] Error 1


I believe the error is due to the fact that in the function pow(a,b), b must be a scalar. In my model b would be a volScalarField (I think).

Is there some way to overcome this problem? Perhaps I have misinterpreted the error messages and there is something else wrong. Any insights would be appreciated.

Thanks,

Peter.

gschaider February 17, 2009 06:20

Should look before I type. You
 
Should look before I type. You gave a value. But the order is wrong

prjohnston February 18, 2009 08:14

Dear Bernhard, Thanks for y
 
Dear Bernhard,

Thanks for your input. I found the relevant part of Doxygen, but being in the throes of learning C++, I don't really understand it. I changed by code to read:

Foam::tmp<foam::volscalarfield>
Foam::viscosityModels::GeneralisedPowerLaw::calcNu () const
{
tmp<volscalarfield> sr(strainRate());
tmp<volscalarfield> c1(nu0_*exp(-(scalar(1)+(sr())/a_)*exp(-b_/(sr())))+nuInf_);
tmp<volscalarfield> c2(nInf_-n0_*exp(-(scalar(1)+sr()/c_)*exp(-d_/sr()))-scalar(1));
return(c1()*pow(sr(),c2()));
}

All the variables nu0_, nuInf_, n0_, a_, b_, c_ and d_ are dimensionedScalars.

I still get the same error message on compilation, which I don't understand.

At the risk of sounding incredibly thick, I don't know what you mean about the order being wrong.
Any insights would be much appreciated.

Thanks again,

Peter.

gschaider February 18, 2009 13:19

Hi Petr! It says that somew
 
Hi Petr!

It says that somewhere (the file /home/peter/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricScalarField.C line 220) it tries to construct a dimensioned scalar with the arguments
const char [2], double, const Foam::dimensionSet&
but amongest the constructors the appropriate one would be
(const Foam::word&, const Foam::dimensionSet&, Type) [with Type = double]

And now comes the strange thing: that is definitly not your source and the offending line says
dimensionedScalar("1", 1.0, gsf2.dimensions())
which is in my opinion the wrong order. Now there are two options:

a) I am completly wrong (which is not unheard of)
b) you are the first person to instantiate that template and that is the reason why this typo was never found. To verify do the following: switch 1.0 and gf2.dimensions() in that file and try to recompile your stuff. If that makes the error go away then report it as a bug

Bernhard

prjohnston February 19, 2009 02:58

Dear Bernhard, You were cor
 
Dear Bernhard,

You were correct. I had to make the switch in three places. But it all works well now (having solved a few other problems along the way).

Thank you very much for your help.

Regards,

Peter.

Mahyar Javidi August 9, 2012 11:15

Hi everybody

I am trying to implement a new viscosity model (Ellis mode), which is similar to the crossPowerLaw model. The difference is, Ellis model does not have nuInf and instead of "shear rate" it has "shear stress". For nuInf I can easily drop it from the code but for implementing shear stress I have a little problem.
I think for shear stress I have to use:
<volTensorField> stressTensor=-mu*(fvc::grad(U)+(fvc::grad(U)).T());
The problem is I do not know how exactly implement these stuff in the code. Also I think because of the mu(=nu*rho), I need to define a loop for shear stress, but I don't know how to do that and where to put it in the code.
Could anyone help me with this? any idea?

Thanks

vonboett July 3, 2015 04:26

dimensioned scalar troubles in viscosity model
 
Hi all,

I have a stupid question but I can't solve it: I have a modified Herschel Bulkley viscosity law where the only difference is that the user specifies fluid properties like solid concentration and mineralogy. So, instead of reading in
tau0_(HerschelBulkleyDebrisFlowCoeffs_.lookup("tau 0")),
k_(HerschelBulkleyDebrisFlowCoeffs_.lookup("k")),
I would like to calculate tau0_ and k_, but the code then always expects
tau0_ and k_ to have no dimensions [ 0 0 0 0 0 0 0 ] and I can't find a way to
initialize them with the correct dimensions. If I read them in as dummies and
overwrite them with my calculation, it works fine, but there should be a smarter way...


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