|
[Sponsors] |
June 17, 2014, 09:28 |
modifying the viscosity model (BirdCarreau)
|
#1 |
Senior Member
Join Date: Nov 2010
Posts: 103
Rep Power: 15 |
Hi,
I am trying to modify the BirdCarreau viscosity model. The current expression in OpenFOAM is: Code:
nuInf_ + (nu0_ - nuInf_) *pow(scalar(1) + sqr(k_*strainRate()), (n_ - 1.0)/2.0); nu0_tmdep = a/(1+b*t+c*t^2) nuInf_tmdep = exp(e+f*t+g*t^2) a,b,c,d,e,f, and g are given constants whereas t is time. I have created two volScalarFields in the .C file and deleted reading of nu0_ and nuInf_ everywhere in the .H file. Code:
Foam::tmp<Foam::volScalarField> Foam::viscosityModels::ModifiedBirdCarreau::calcNu() const { volScalarField nu0_tmdep ( scalar(84.455311)/(scalar(1)-scalar(0.0309746)*runTime.value()+scalar(0.00024088)*sqr(runTime.value())) ); volScalarField nuInf_tmdep ( Foam::exp(scalar(12.022048)-scalar(0.629963)*runTime.value()+scalar(0.00898332)*sqr(runTime.value())) ); return nuInf_tmdep + (nu0_tmdep - nuInf_tmdep) *pow(scalar(1) + sqr(k_*strainRate()), (n_ - 1.0)/2.0); } ModifiedBirdCarreau/ModifiedBirdCarreau.C: In member function ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::viscosityModels::ModifiedBirdCarreau::calcNu () const’: ModifiedBirdCarreau/ModifiedBirdCarreau.C:55:54: error: ‘runTime’ was not declared in this scope ModifiedBirdCarreau/ModifiedBirdCarreau.C: In constructor ‘Foam::viscosityModels::ModifiedBirdCarreau::Modif iedBirdCarreau(const Foam::word&, const Foam::dictionary&, const volVectorField&, const surfaceScalarField&)’: ModifiedBirdCarreau/ModifiedBirdCarreau.C:104:5: error: no matching function for call to ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField()’ I would be really thankful if someone can give me some pieces of advice and I must say I am kind of new in OpenFOAM territory, so I might have done something pretty silly! Cheers! |
|
June 17, 2014, 10:41 |
|
#2 |
Senior Member
|
Hi,
you can try Code:
U_.time().timeOutputValue() |
|
June 18, 2014, 02:31 |
|
#3 |
Senior Member
Join Date: Nov 2010
Posts: 103
Rep Power: 15 |
Hi Alexey,
Thanks a lot for your help. Now I've got access to the runTime. But it's still complaining about: In member function ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::viscosityModels::ModifiedBirdCarreau::calcNu () const’: ModifiedBirdCarreau/ModifiedBirdCarreau.C:59:6: error: no matching function for call to ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(double)’ I am not really sure, where it is coming from! any suggestions would be appreciated. Cheers! |
|
June 18, 2014, 02:45 |
|
#4 |
Senior Member
|
Hi,
it's just trying to say that it can't construct volScalarField from double. Why would you like to use volScalarField for nu0_tmdep instead of dimensionedScalar? I can see that this value depends on time, but I don't see the dependence of coordinate. So I think this Code:
volScalarField nu0_tmdep ( scalar(84.455311)/(scalar(1)-scalar(0.0309746)*runTime.value()+scalar(0.00024088)*sqr(runTime.value())) ); Code:
dimensionedScalar nu0_tmdep("nu0", <dimensions of nu0_tmdep>, scalar(84.455311)/(scalar(1) -scalar(0.0309746)*runTime.value() + scalar(0.00024088)*sqr(runTime.value()))) |
|
June 18, 2014, 03:24 |
|
#5 |
Senior Member
Join Date: Nov 2010
Posts: 103
Rep Power: 15 |
Thank you so much Alexey for the speedy answer. I created it as a dimensionedScalar in the constructor and no compilation error.
You've just made my day! cheers! |
|
March 16, 2015, 10:06 |
Adding Time
|
#6 |
New Member
Stefan
Join Date: Mar 2015
Location: Bavaria
Posts: 7
Rep Power: 11 |
Hey,
I didn't want to open a new thread since I think that my problem has a lot to do with the problem of the thread opener's. i'm trying to modify a viscosity model (newtonian, but i guess it doesn't matter). What I want to do is, make the viscosity time dependent. So I wrote a simple equation which describes this relation: Viscosity = nu * ( 1 + nu / 700 * Time ) and implemented it in the following source code (see green lines!) (Voelkl is the Name of my ViscosityModel) Code:
#include "Voelkl.H" #include "addToRunTimeSelectionTable.H" #include "surfaceFields.H" //extern Foam::Time runTime; // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { namespace viscosityModels { defineTypeNameAndDebug(Voelkl, 0); addToRunTimeSelectionTable(viscosityModel,Voelkl,dictionary); } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::viscosityModels::Voelkl::Voelkl ( const word& name, const dictionary& viscosityProperties, const volVectorField& U, const surfaceScalarField& phi ) : viscosityModel(name, viscosityProperties, U, phi), nu0_("nu", dimensionSet(0, 2, -1, 0, 0), viscosityProperties_.lookup("nu")), nu_ ( IOobject ( name, U_.time().timeName(), U_.db(), IOobject::NO_READ, IOobject::AUTO_WRITE ), U_.mesh(), nu0_* ( 1 + nu0_ / 700 * runTime.value() ) // nu0_* ( 1 + nu0_ / 700 * U_.time()timeOutputValue() ) ) {} // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // bool Foam::viscosityModels::Voelkl::read ( const dictionary& viscosityProperties ) { viscosityModel::read(viscosityProperties); viscosityProperties_.lookup("nu") >> nu0_; nu_ = nu0_; return true; } // ************************************************************************* // Among these tries were adding Code:
#include "createTime.H" Code:
deve@deve:~/OpenFOAM/deve-2.3.1/applications/viscosityModels/Voelkl$ wmake wmakeLnInclude: linking include files to ./lnInclude Making dependency list for source file Voelkl.C SOURCE=Voelkl.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam231/src/transportModels/incompressible/lnInclude/ -I/opt/openfoam231/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/openfoam231/src/OpenFOAM/lnInclude -I/opt/openfoam231/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/Voelkl.o In file included from Voelkl.C:29:0: /opt/openfoam231/src/OpenFOAM/lnInclude/createTime.H:5:5: error: ‘Info’ in namespace ‘Foam’ does not name a type Foam::Info<< "Create time\n" << Foam::endl; ^ /opt/openfoam231/src/OpenFOAM/lnInclude/createTime.H:7:53: error: ‘args’ was not declared in this scope Foam::Time runTime(Foam::Time::controlDictName, args); ^ make: *** [Make/linux64GccDPOpt/Voelkl.o] Fehler 1 Code:
// // createTime.H // ~~~~~~~~~~~~ Foam::Info<< "Create time\n" << Foam::endl; Foam::Time runTime(Foam::Time::controlDictName, args); Does anyone have a clue what the problem is? Thanks in advance Deve Edit: I was able to find a solution to my problem; send PM for further information Last edited by deve; March 24, 2015 at 04:44. Reason: resolved |
|
February 10, 2016, 09:59 |
|
#7 |
New Member
Jeferson Souza
Join Date: Jan 2012
Location: Brazil
Posts: 19
Rep Power: 14 |
Hi deve,
I'm having the same problem. I can not access runTime() variable from my viscosity model. How did you solve the problem? Thanks. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problem with divergence | TDK | FLUENT | 13 | December 14, 2018 06:00 |
Viscosity model - Compressible flow | Aurelien Thinat | OpenFOAM Programming & Development | 3 | March 6, 2018 07:08 |
coefficient of power-Law viscosity Model in OpenFOAM | Daniel_Khazaei | OpenFOAM Running, Solving & CFD | 6 | April 5, 2016 04:23 |
Validity of Sutherland's viscosity model for high-T gases | tatu | Main CFD Forum | 1 | March 6, 2013 12:00 |
Power - Law Viscosity Model for Polymers | NickolasPl | OpenFOAM | 2 | August 12, 2011 08:26 |