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

Implementing new viscosity model

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Mahyar Javidi

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 16, 2009, 23:03
Default Hello, I am trying to imple
  #1
New Member
 
Peter Johnston
Join Date: Mar 2009
Location: Brisbane, Queensland, Australia
Posts: 25
Rep Power: 17
prjohnston is on a distinguished road
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.
prjohnston is offline   Reply With Quote

Old   February 17, 2009, 06:20
Default Should look before I type. You
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Should look before I type. You gave a value. But the order is wrong
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   February 18, 2009, 08:14
Default Dear Bernhard, Thanks for y
  #3
New Member
 
Peter Johnston
Join Date: Mar 2009
Location: Brisbane, Queensland, Australia
Posts: 25
Rep Power: 17
prjohnston is on a distinguished road
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.
prjohnston is offline   Reply With Quote

Old   February 18, 2009, 13:19
Default Hi Petr! It says that somew
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
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
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   February 19, 2009, 02:58
Default Dear Bernhard, You were cor
  #5
New Member
 
Peter Johnston
Join Date: Mar 2009
Location: Brisbane, Queensland, Australia
Posts: 25
Rep Power: 17
prjohnston is on a distinguished road
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.
prjohnston is offline   Reply With Quote

Old   August 9, 2012, 12:15
Default
  #6
New Member
 
anonymous
Join Date: Jan 2012
Location: Canada
Posts: 24
Rep Power: 14
Mahyar Javidi is on a distinguished road
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
nvnkush likes this.
Mahyar Javidi is offline   Reply With Quote

Old   July 3, 2015, 05:26
Default dimensioned scalar troubles in viscosity model
  #7
Senior Member
 
Albrecht vBoetticher
Join Date: Aug 2010
Location: Zürich, Swizerland
Posts: 240
Rep Power: 17
vonboett is on a distinguished road
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...
vonboett 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
How to modify the viscosity model mpml OpenFOAM Running, Solving & CFD 4 October 13, 2010 08:44
Power Law Viscosity Model cpplabs OpenFOAM Running, Solving & CFD 1 February 13, 2008 09:09
best viscosity turbulent model? Greg FLUENT 2 October 5, 2007 09:59
Which SGS viscosity model is most popular in LES? leaf Main CFD Forum 1 August 1, 2006 06:04
New viscosity model henry OpenFOAM Running, Solving & CFD 2 July 29, 2005 09:57


All times are GMT -4. The time now is 16:07.