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

Adding a new viscosity model

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

Reply
 
LinkBack Thread Tools Display Modes
Old   June 16, 2009, 09:12
Default Adding a new viscosity model
  #1
ICL
New Member
 
Ali Sh
Join Date: Jun 2009
Location: London
Posts: 28
Rep Power: 8
ICL is on a distinguished road
Hi everyone,
I am trying to add a new viscosity models.
1- a folder in transportModels./incompressible/viscosityModels was created, including .H, .C, and .dep files of new model.
2- updating transportModels//incompressible/lnInclude files.
3- updating transportModels/incompressible/Make files (adding new model)
4- wmake lisbo incompressible
and the following is what I receive:


transportModels]$ '/home/OpenFOAM/OpenFOAM-1.5/src/transportModels/Allwmake'
+ wmake libso incompressible
Making dependency list for source file viscosityModels/EyringRoelands/EyringRoelands.C
SOURCE=viscosityModels/EyringRoelands/EyringRoelands.C ; g++ -m64 -Dlinux64 -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -march=opteron -O3 -DNoRepository -ftemplate-depth-40 -I.. -I/home/ahajisha/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/ahajisha/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude -I/home/ahajisha/OpenFOAM/OpenFOAM-1.5/src/OSspecific/Unix/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/EyringRoelands.o
'/home/ahajisha/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libincompressibleTransportModels.so' is up to date.
+ wmake libso interfaceProperties
'/home/ahajisha/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libinterfaceProperties.so' is up to date.



Everything seems fine, but when I am trying to solve the problem with simpleFoam (EyringRoelands viscosity model) :

Unknown viscosityModel type EyringRoelands
Valid viscosityModels are :

5
(
Newtonian
CrossPowerLaw
BirdCarreau
HerschelBulkley
powerLaw
)


I would appreciate if someone can help me on this.Many thanks;
ICL is offline   Reply With Quote

Old   June 16, 2009, 09:45
Default
  #2
New Member
 
Kian Mehravaran
Join Date: Mar 2009
Location: London, U.K
Posts: 22
Rep Power: 8
kian is on a distinguished road
Have you done: addToRunTimeSelectionTable ?

Kian
kian is offline   Reply With Quote

Old   June 16, 2009, 09:50
Default
  #3
ICL
New Member
 
Ali Sh
Join Date: Jun 2009
Location: London
Posts: 28
Rep Power: 8
ICL is on a distinguished road
#include EyringRoelamds.H
#include addToRunTimeSelectionTable.H
#include surfaceFields.H
ICL is offline   Reply With Quote

Old   June 16, 2009, 12:48
Default
  #4
New Member
 
Luiz Fernando L. R. Silva
Join Date: Mar 2009
Location: Rio de Janeiro, RJ, Brazil
Posts: 10
Rep Power: 8
silva is on a distinguished road
Just including the header will not put the name of your model into the selection table.

If you used one of the previous models codes to build your own, you may have seen the declaration of the following static members:

defineTypeNameAndDebug(BirdCarreau, 0);

addToRunTimeSelectionTable
(
viscosityModel,
BirdCarreau,
dictionary
);

The last argument includes the Bird-Carreau model and make it available. You must adapt and include this constructor to your model code. Have you done it in your code?

Hoping that it may help.
Best,
Luiz F.
silva is offline   Reply With Quote

Old   June 16, 2009, 12:57
Default
  #5
ICL
New Member
 
Ali Sh
Join Date: Jun 2009
Location: London
Posts: 28
Rep Power: 8
ICL is on a distinguished road
This is the complete code:


#include "EyringRoelands.H"
#include "addToRunTimeSelectionTable.H"
#include "surfaceFields.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
namespace viscosityModels
{

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

defineTypeNameAndDebug(EyringRoelands, 0);

addToRunTimeSelectionTable
(
piezoViscous,
EyringRoelands,
dictionary
);


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

//- Calculate and return the laminar viscosity
tmp<volScalarField> EyringRoelands::calcNu() const
{
const scalar small_rate = 1e-8;
const volScalarField sr = strainRate();

// roelands
volScalarField roelands = eta0_ * exp((Foam::log(eta0_.value()) + 9.67) * (-1.0 + pow((1.0+p_/p0_), z_)));

label count = 0;
volScalarField eyring = roelands;

forAll(eyring.internalField(), cellI)
{
if (sr[cellI] > small_rate)
{
eyring.internalField()[cellI] =
tau0_.value() / sr[cellI]
* asinh(roelands[cellI]
* sr[cellI] / tau0_.value());
}
else
{
count++;
}
}
if (count > 0 )
{
Info << "EyringRoelands > Number of cells with shear-rate less than "
<< small_rate << " : " << count << endl;
}
count = 0;

forAll(eyring.boundaryField(), bfI)
{
forAll(eyring.boundaryField()[bfI], faceI)
{
if (sr.boundaryField()[bfI][faceI] > small_rate)
{
eyring.boundaryField()[bfI][faceI] =
tau0_.value()
/ sr.boundaryField()[bfI][faceI]
* asinh(roelands.boundaryField()[bfI][faceI]
* sr.boundaryField()[bfI][faceI]
/ tau0_.value());
}
else
{
count++;
}
}
}
if (count > 0 )
{
Info << "EyringRoelands > Number of boundary faces with shear-rate less than "
<< small_rate << " : " << count << endl;
}

return eyring * 1.0;
}


// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

// from components
Foam::viscosityModels::EyringRoelands::EyringRoela nds
(
const volVectorField& U,
const volScalarField& p,
const surfaceScalarField& phi,
const word& phaseName
)
:
piezoViscous(U, p, phi, phaseName),
EyringRoelandsCoeffs_
(
phaseTransportProperties_.subDict(typeName + "Coeffs")
),
z_(EyringRoelandsCoeffs_.lookup("z")),
p0_(EyringRoelandsCoeffs_.lookup("p0")),
eta0_(EyringRoelandsCoeffs_.lookup("eta0")),
tau0_(EyringRoelandsCoeffs_.lookup("tau0")),
nu_
(
IOobject
(
"nu" + phaseName,
U_.time().timeName(),
U_.db(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
calcNu()
)
{}


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

bool Foam::viscosityModels::EyringRoelands::read()
{
if (piezoViscous::read())
{
EyringRoelandsCoeffs_ =
phaseTransportProperties_.subDict(typeName + "Coeffs");

EyringRoelandsCoeffs_.lookup("z") >> z_;
EyringRoelandsCoeffs_.lookup("p0") >> p0_;
EyringRoelandsCoeffs_.lookup("eta0") >> eta0_;
EyringRoelandsCoeffs_.lookup("tau0") >> tau0_;

return true;
}
else
{
return false;
}
}


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace transportModels
} // End namespace Foam

// ************************************************** *********************** //
ICL is offline   Reply With Quote

Old   June 16, 2009, 13:21
Default
  #6
New Member
 
Luiz Fernando L. R. Silva
Join Date: Mar 2009
Location: Rio de Janeiro, RJ, Brazil
Posts: 10
Rep Power: 8
silva is on a distinguished road
Check the construction of the selection table.

addToRunTimeSelectionTable
(
piezoViscous, ----> it should be viscosityModel...
EyringRoelands,
dictionary
);

Check if it works now.
Regards,
LF
silva is offline   Reply With Quote

Old   June 16, 2009, 13:23
Default
  #7
ICL
New Member
 
Ali Sh
Join Date: Jun 2009
Location: London
Posts: 28
Rep Power: 8
ICL is on a distinguished road
I tried that before but it does not.
viscosityModels/EyringRoelands/EyringRoelands.C:48: error: ‘viscosityModel’ has not been declared
ICL is offline   Reply With Quote

Old   June 16, 2009, 13:42
Default
  #8
New Member
 
Luiz Fernando L. R. Silva
Join Date: Mar 2009
Location: Rio de Janeiro, RJ, Brazil
Posts: 10
Rep Power: 8
silva is on a distinguished road
You see, you are right... Changing only this would not be sufficient. I was about to send you another message.

I checked your code and notice that it is different from the other viscosity models. You don't use a viscosityModel but a piezoViscous instead. That is why the compiler complains that the viscosityModel is not declared. You don't use it at all.

Using your original code, your model should be in the piezoViscous selection table instead of the viscosityModel. I don't have this piezoViscous files, but you should look for its construction keywords. Is it the same as the viscosityModel?

Check this and please return that I am curious .
silva is offline   Reply With Quote

Old   June 16, 2009, 13:55
Default
  #9
ICL
New Member
 
Ali Sh
Join Date: Jun 2009
Location: London
Posts: 28
Rep Power: 8
ICL is on a distinguished road
piezoviscous is another viscosity model which was included in the same viscosity models directory.
The point is, it was written for OF 1.3. I change bot piezoviscous file and EyringRoelands to cope with OF 1.5 viscosity models but I received errors.
Here is piezoviscous.C:

#include "piezoViscous.H"
#include "volFields.H"
#include "fvc.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

defineTypeNameAndDebug(piezoViscous, 0);
defineRunTimeSelectionTable(piezoViscous, dictionary);


//- Lookup and return the phase transport properties dictionary
const dictionary& piezoViscous::lookupPhaseTransportProperties
(
const dictionary& transportProperties,
const word& phaseName
)
{
if (phaseName.size())
{
return transportProperties.subDict(phaseName);
}
else
{
return transportProperties;
}
}


// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

piezoViscous:iezoViscous
(
const volVectorField& U,
const volScalarField& p,
const surfaceScalarField& phi,
const word& phaseName
)
:
IOdictionary
(
IOobject
(
"transportProperties",
U.time().constant(),
U.db(),
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),

U_(U),
p_(p),
phi_(phi),
phaseName_(phaseName),
phaseTransportProperties_
(
lookupPhaseTransportProperties(*this, phaseName)
)
{}


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

tmp<volScalarField> piezoViscous::strainRate() const
{
return mag(fvc::grad(U_));
}


bool piezoViscous::read()
{
if (regIOobject::read())
{
phaseTransportProperties_ =
lookupPhaseTransportProperties(*this, phaseName_);

return true;
}
else
{
return false;
}
}


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// *************************************
ICL is offline   Reply With Quote

Old   June 17, 2009, 10:39
Default
  #10
ICL
New Member
 
Ali Sh
Join Date: Jun 2009
Location: London
Posts: 28
Rep Power: 8
ICL is on a distinguished road
I have changed everything to cope with new version 1.5. Now the only error I get is:

viscosityModels/piezoViscous/piezoViscous.C:49: error: expected constructor, destructor, or type conversion before ‘;’ token
make: *** [Make/linux64GccDPOpt/piezoViscous.o] Error 1


I paste line 40 to line 50 here:

namespace viscosityModels
{
defineTypeNameAndDebug(piezoViscous, 0);

addToRunTimeSelectionTable
(
viscosityModel,
piezoViscous,
dictionary
);
}


Any idea?
ICL is offline   Reply With Quote

Old   June 17, 2009, 11:49
Default errors in wmake that: no matching function for call to ‘Foam::GeometricField<Foam::T
  #11
Member
 
xianghong wu
Join Date: Mar 2009
Posts: 57
Rep Power: 8
wendywu is on a distinguished road
Hi,

I am doing modification in viscosity model.
I modified createFields.H, added createFieldViscoPlastic.H, modified icoFoam.C
after wmake, the error is:
Making dependency list for source file my_icoFoam_viscoPlastic.C
SOURCE=my_icoFoam_viscoPlastic.C ; g++ -m32 -Dlinux -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/home/xhw/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/xhw/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude -I/home/xhw/OpenFOAM/OpenFOAM-1.5/src/OSspecific/Unix/lnInclude -fPIC -pthread -c $SOURCE -o Make/linuxGccDPOpt/my_icoFoam_viscoPlastic.o
In file included from my_icoFoam_viscoPlastic.C:44:
createFields.H: In function ‘int main(int, char**)’:
createFields.H:79: error: no matching function for call to ‘Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject, Foam::tmp<Foam::GeometricField<Foam::SymmTensor<do uble>, Foam::fvPatchField, Foam::volMesh> >)’
/home/xhw/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:611: note: candidates are: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&, const Foam::wordList&) [with Type = Foam::Tensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/xhw/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:576: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&, const Foam::word&) [with Type = Foam::Tensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/xhw/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:545: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::word&, const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = Foam::Tensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/xhw/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:512: not......................

So what does it mean in the first few lines?
In file included from my_icoFoam_viscoPlastic.C:44:
createFields.H: In function ‘int main(int, char**)’:
createFields.H:79: error: no matching function for call to ‘Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject, Foam::tmp<Foam::GeometricField<Foam::SymmTensor<do uble>, Foam::fvPatchField, Foam::volMesh> >)’
/home/xhw/OpenFOAM/OpenF

Thank you for any help.

Wendy
wendywu is offline   Reply With Quote

Old   June 17, 2009, 12:51
Default error in running my own solver
  #12
Member
 
xianghong wu
Join Date: Mar 2009
Posts: 57
Rep Power: 8
wendywu is on a distinguished road
Hi, I just fixed the error in wmake, and it passed.
I now can run the solver, but it exited with errors as follows:

#0 Foam::error:rintStack(Foam::Ostream&) in "/home/xhw/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so"
#1 Foam::sigFpe::sigFpeHandler(int) in "/home/xhw/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so"
#2 Uninterpreted: [0xb8080400]
#3 Foam::divide(Foam::Field<double>&, Foam::UList<double> const&, Foam::UList<double> const&) in "/home/xhw/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so"
#4 void Foam::divide<Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) in "/home/xhw/OpenFOAM/xhw-1.5/applications/bin/linuxGccDPOpt/my_icoFoam_viscoPlastic"
#5 Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam:perator/<Foam::fvPatchField, Foam::volMesh>(Foam::tmp<Foam::GeometricField<doub le, Foam::fvPatchField, Foam::volMesh> > const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&) in "/home/xhw/OpenFOAM/xhw-1.5/applications/bin/linuxGccDPOpt/my_icoFoam_viscoPlastic"
#6 main in "/home/xhw/OpenFOAM/xhw-1.5/applications/bin/linuxGccDPOpt/my_icoFoam_viscoPlastic"
#7 __libc_start_main in "/lib/tls/i686/cmov/libc.so.6"
#8 _start in "/home/xhw/OpenFOAM/xhw-1.5/applications/bin/linuxGccDPOpt/my_icoFoam_viscoPlastic"
Floating point exception
.
I don't understand what it means.
Anybody can help me ? Thanks a lot

Wendy
wendywu is offline   Reply With Quote

Old   June 19, 2009, 12:51
Default
  #13
ICL
New Member
 
Ali Sh
Join Date: Jun 2009
Location: London
Posts: 28
Rep Power: 8
ICL is on a distinguished road
Hi,

I am correcting my question in this post. What I posted before was a code written to take pressure into account for viscosity calculation. The problem is, the new models have not been identified by solvers( simpleFoam) as a viscosityModels.
How can I add these models to the list?
Maybe, there would be another step to add pressure to the solver code.

Any idea?
ICL is offline   Reply With Quote

Old   July 9, 2009, 13:05
Default simpleFoam crashed
  #14
ICL
New Member
 
Ali Sh
Join Date: Jun 2009
Location: London
Posts: 28
Rep Power: 8
ICL is on a distinguished road
I finally managed to use new viscosity models with simpleFoam solver.
When I am trying to increase the surface velocity, for values more than 0.2 m/s, I received the following error after number of iteration.


time step continuity errors :
sum local = 0.000305875, global = -3.95803e-07, cumulative = 3.07225e-05
#0 Foam::error:rintStack(Foam::Ostream&) in "/home/ahajisha/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libOpenFOAM.so"
#1 Foam::sigFpe::sigFpeHandler(int) in "/home/ahajisha/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libOpenFOAM.so"
#2 __restore_rt at sigaction.c:0
#3 __kernel_standard at interp.c:0
#4 Foam:ow(Foam::Field<double>&, Foam::UList<double> const&, double const&) in "/home/ahajisha/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libOpenFOAM.so"
#5 Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam:ow<Foam::fvPatchField, Foam::volMesh>(Foam::tmp<Foam::GeometricField<doub le, Foam::fvPatchField, Foam::volMesh> > const&, Foam::dimensioned<double> const&) in "/home/ahajisha/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libincompressibleRASModels.so"
#6 Foam::viscosityModels::EyringRoelands::calcNu() const in "/home/ahajisha/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libincompressibleTransportModels.so"
#7 Foam::viscosityModels::EyringRoelands::correct() in "/home/ahajisha/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libincompressibleTransportModels.so"
#8 main in "/home/ahajisha/OpenFOAM/OpenFOAM-1.5/applications/bin/linux64GccDPOpt/simpleFoam"
#9 __libc_start_main in "/lib64/libc.so.6"
#10 Foam::regIOobject::readIfModified() in "/home/ahajisha/OpenFOAM/OpenFOAM-1.5/applications/bin/linux64GccDPOpt/simpleFoam"
Floating point exception



I don`t have any possible division by zero in my viscosity code and I am wondering what is the source of this problem. Is there any idea?

Thanks,
ICL is offline   Reply With Quote

Old   July 10, 2009, 10:38
Default
  #15
Member
 
xianghong wu
Join Date: Mar 2009
Posts: 57
Rep Power: 8
wendywu is on a distinguished road
When I run snappyHexMesh, it also stoped with this kind of error, I changed the mesh refinement level, it is solved. I don't know why.
I modified viscosity model based on icoFoam, it is also stoped with this kind of error, I checked and corrected one equation that may have zero on the denominator. it is still not solved.
So I am also facing the problem.
I hope you will find the answer soon.

Wendy
wendywu is offline   Reply With Quote

Old   November 3, 2012, 02:26
Default Dear ICL,
  #16
Senior Member
 
Tushar Chourushi
Join Date: Jul 2009
Location: IIT-Indore, India
Posts: 318
Blog Entries: 1
Rep Power: 8
Tushar@cfd is on a distinguished road
Are You able to add new solver to the existing viscositymodel?? which You have mentioned in the earlier thread? If yes, please let me know...
Tushar@cfd is offline   Reply With Quote

Old   January 8, 2013, 04:19
Default
  #17
New Member
 
Hossein Yahyazadeh
Join Date: Oct 2012
Posts: 9
Rep Power: 4
hossein_y62 is on a distinguished road
Hi every one,

Could anyone help me how can I make a new viscosity model or modify one of them? I have tried to do that but I cannot save it.

Thanx
hossein_y62 is offline   Reply With Quote

Reply

Tags
openfoam, viscosity

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Implementing new viscosity model prjohnston OpenFOAM Running, Solving & CFD 6 Today 04:26
Adding a Turbulence Model doug OpenFOAM Running, Solving & CFD 10 October 2, 2012 06:55
Yielding viscosity for Herschel Bulkley model Godwin FLUENT 1 December 12, 2011 06:42
Two-Phase Buoyant Flow Issue Miguel Baritto CFX 4 August 31, 2006 12:02
Casson Viscosity model as one user define function Zahra Rahmdel FLUENT 0 November 6, 2004 06:53


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