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/)
-   -   Adding a new viscosity model (http://www.cfd-online.com/Forums/openfoam-solving/65480-adding-new-viscosity-model.html)

ICL June 16, 2009 09:12

Adding a new viscosity model
 
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;

kian June 16, 2009 09:45

Have you done: addToRunTimeSelectionTable ?

Kian

ICL June 16, 2009 09:50

#include EyringRoelamds.H
#include addToRunTimeSelectionTable.H
#include surfaceFields.H

silva June 16, 2009 12:48

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.

ICL June 16, 2009 12:57

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

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

silva June 16, 2009 13:21

Check the construction of the selection table.

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

Check if it works now.
Regards,
LF

ICL June 16, 2009 13:23

I tried that before but it does not.
viscosityModels/EyringRoelands/EyringRoelands.C:48: error: ‘viscosityModel’ has not been declared

silva June 16, 2009 13:42

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 :confused:.

ICL June 16, 2009 13:55

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::piezoViscous
(
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 June 17, 2009 10:39

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?

wendywu June 17, 2009 11:49

errors in wmake that: no matching function for call to ‘Foam::GeometricField<Foam::T
 
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 June 17, 2009 12:51

error in running my own solver
 
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::printStack(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::operator/<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

ICL June 19, 2009 12:51

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 July 9, 2009 13:05

simpleFoam crashed
 
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::printStack(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::pow(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::pow<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,

wendywu July 10, 2009 10:38

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

Tushar@cfd November 3, 2012 02:26

Dear ICL,
 
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...

hossein_y62 January 8, 2013 04:19

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


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