CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Implementing a new viscosity model (https://www.cfd-online.com/Forums/openfoam-programming-development/169778-implementing-new-viscosity-model.html)

yy205001 April 17, 2016 09:42

Implementing a new viscosity model
 
Hello,

I am doing a project about pipe flow with non newtonian fluid. Apart from the default viscosity model of OpenFOAM, I want to use Quemada model (not in OpenFOAM). The Quemada file contains: Quemada.C, Quemada.H and Quemada.dep.

So my question is after I move the Quemada file into viscosityModels directory, what will be the next step?

Really appreciated any help!

Bentley.

NightWing April 18, 2016 01:38

Not really been good at this. But i feel that u should make necessary changes in the files/options folders and then introduce these headers in the .C file and then you have to wmake the solver and see if it complies without any error foremost. you could also search in the forum. I guess the below is smthng relating to adding a new viscosity model

Cheers!


http://www.cfd-online.com/Forums/ope...ity-model.html

yy205001 May 1, 2016 04:38

update progress
 
Hi all,

I am still unable to build the Quemada viscosity model into my library. And I got some errors as following. Any help will be appreciated!

Cheers.

Code:

wmake: 'Make' directory does not exist in /opt/openfoam30/src/transportModels/incompressible/viscosityModels/Quemada
    Searching up directories tree for Make directory
    Found target directory  ./../..
/opt/openfoam30/src/transportModels/incompressible
g++ -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3  -DNoRepository -ftemplate-depth-100 -I.. -I../twoPhaseMixture/lnInclude -I/opt/openfoam30/src/finiteVolume/lnInclude -I/opt/openfoam30/src/meshTools/lnInclude -IlnInclude -I. -I/opt/openfoam30/src/OpenFOAM/lnInclude -I/opt/openfoam30/src/OSspecific/POSIX/lnInclude  -fPIC -c viscosityModels/Quemada/Quemada.C -o /opt/openfoam30/platforms/linux64GccDPInt32Opt/src/transportModels/incompressible/viscosityModels/Quemada/Quemada.o
In file included from /opt/openfoam30/src/OpenFOAM/lnInclude/token.H:49:0,
                from /opt/openfoam30/src/OpenFOAM/lnInclude/UILListIO.C:28,
                from /opt/openfoam30/src/OpenFOAM/lnInclude/UILList.C:92,
                from /opt/openfoam30/src/OpenFOAM/lnInclude/UILList.H:383,
                from /opt/openfoam30/src/OpenFOAM/lnInclude/ILList.H:39,
                from /opt/openfoam30/src/OpenFOAM/lnInclude/IDLList.H:35,
                from /opt/openfoam30/src/OpenFOAM/lnInclude/entry.H:45,
                from /opt/openfoam30/src/OpenFOAM/lnInclude/dictionary.H:53,
                from lnInclude/viscosityModel.H:50,
                from viscosityModels/Quemada/Quemada.H:38,
                from viscosityModels/Quemada/Quemada.C:26:
lnInclude/viscosityModel.H: In instantiation of ‘static Foam::autoPtr<Foam::viscosityModel> Foam::viscosityModel::adddictionaryConstructorToTable<viscosityModelType>::New(const Foam::word&, const Foam::dictionary&, const volVectorField&, const surfaceScalarField&) [with viscosityModelType = Foam::viscosityModels::Quemada; Foam::volVectorField = Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>; Foam::surfaceScalarField = Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh>]’:
lnInclude/viscosityModel.H:96:9:  required from ‘Foam::viscosityModel::adddictionaryConstructorToTable<viscosityModelType>::adddictionaryConstructorToTable(const Foam::word&) [with viscosityModelType = Foam::viscosityModels::Quemada]’
viscosityModels/Quemada/Quemada.C:37:5:  required from here
/opt/openfoam30/src/OpenFOAM/lnInclude/runTimeSelectionTables.H:76:66: error: cannot allocate an object of abstract type ‘Foam::viscosityModels::Quemada’
            return autoPtr< baseType >(new baseType##Type parList);          \
                                                                  ^
lnInclude/viscosityModel.H:96:9: note: in expansion of macro ‘declareRunTimeSelectionTable’
        declareRunTimeSelectionTable
        ^
In file included from viscosityModels/Quemada/Quemada.C:26:0:
viscosityModels/Quemada/Quemada.H:53:7: note:  because the following virtual functions are pure within ‘Foam::viscosityModels::Quemada’:
 class Quemada
      ^
In file included from viscosityModels/Quemada/Quemada.H:38:0,
                from viscosityModels/Quemada/Quemada.C:26:
lnInclude/viscosityModel.H:155:34: note:        virtual Foam::tmp<Foam::Field<double> > Foam::viscosityModel::nu(Foam::label) const
        virtual tmp<scalarField> nu(const label patchi) const = 0;
                                  ^
In file included from /opt/openfoam30/src/OpenFOAM/lnInclude/token.H:49:0,
                from /opt/openfoam30/src/OpenFOAM/lnInclude/UILListIO.C:28,
                from /opt/openfoam30/src/OpenFOAM/lnInclude/UILList.C:92,
                from /opt/openfoam30/src/OpenFOAM/lnInclude/UILList.H:383,
                from /opt/openfoam30/src/OpenFOAM/lnInclude/ILList.H:39,
                from /opt/openfoam30/src/OpenFOAM/lnInclude/IDLList.H:35,
                from /opt/openfoam30/src/OpenFOAM/lnInclude/entry.H:45,
                from /opt/openfoam30/src/OpenFOAM/lnInclude/dictionary.H:53,
                from lnInclude/viscosityModel.H:50,
                from viscosityModels/Quemada/Quemada.H:38,
                from viscosityModels/Quemada/Quemada.C:26:
lnInclude/viscosityModel.H: In static member function ‘static Foam::autoPtr<Foam::viscosityModel> Foam::viscosityModel::adddictionaryConstructorToTable<viscosityModelType>::New(const Foam::word&, const Foam::dictionary&, const volVectorField&, const surfaceScalarField&) [with viscosityModelType = Foam::viscosityModels::Quemada; Foam::volVectorField = Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>; Foam::surfaceScalarField = Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh>]’:
/opt/openfoam30/src/OpenFOAM/lnInclude/runTimeSelectionTables.H:77:9: warning: control reaches end of non-void function [-Wreturn-type]
        }                                                                    \
        ^
lnInclude/viscosityModel.H:96:9: note: in expansion of macro ‘declareRunTimeSelectionTable’
        declareRunTimeSelectionTable
        ^
make: *** [/opt/openfoam30/platforms/linux64GccDPInt32Opt/src/transportModels/incompressible/viscosityModels/Quemada/Quemada.o] Error 1


TobM May 2, 2016 02:27

What model did you copy to change into your new model?

kmooney May 3, 2016 13:28

Can you post your .H file? It looks like you might not have a nu() function defined in your new class which is required as nu is a virtual function in its base class.

Scram_1 August 10, 2016 18:17

Hello everyone,
I have created a new Viscosity Model in OpenFOAM 3.0.1 based on the link given by Nightwing in post #2. I'm able to compile without any error but I'm not able to see the new model in the Viscosity Model selection table i.e. when I type transportModel bananas in the transportProperties file in the Constant directory, it is showing me the default 5 viscosity models and not the new model that I had just compiled.
Any help is greatly appreciated.
Thanks!!

TobM August 11, 2016 02:08

Have you included the new library in the controlDict file under libs( "yourlibraryhere.so" ); ?

Scram_1 August 11, 2016 17:14

Hey TobM,
Yes I have included it in my controlDict file.
Edit: I just found out why it wasn't showing. Basically, I have a groovy BC inlet condition for my case setup and in groovy BC also you use libs ("libgroovyBC.so" "libsgroovyStandardBCs.so"). So, in my controlDict, I had libs("libusertempModel.so"); libs("libgroovyBC.so" "libsgroovyStandardBCs.so"). When I clubbed both of these together into one libs statement as in libs(" libgroovyBC.so" "libsgroovyStandardBCs.so" "libusertempModel.so"), it started showing the new viscosity model in the selection table. This wasn't the case in OpenFOAM 2.3 x where I could have 2 separate libs statements, one for the groovy BC and one for the viscosity model. In OpenFOAM 3.0.1, however, clubbing the 2 together gives you the desired result.

TemC February 28, 2017 09:15

2 Attachment(s)
Hi foamers,

I'am working with simpleFoam, and I have implemented a new Herschel-Bulkley viscosity model integrating the Papanastasiou regularization.

- I have created a new folder "RegHerschelBulkley" in "src/transportModels/incompressible/viscosityModels" ;

- I have copied my files "RegHerschelBulkley.C", "REgHerschelBulkley.H" and "REgHerschelBulkley.C.dep" into that new folder ;

- I have modified "src/transportModels/incompressible/Make/files" by adding the new viscosity model ;

- I used the command "wclean" into "src/transportModels/incompressible/" ;

- And when I use the command "./Allwmake" into "src/transportModels/", I got the message in the first attachment (which I must admit, I don't really understand...)

Now when I try to launch a simulation using my new viscosity model, I got the error message in the second attachment.

Can somebody suggest me some adjustments to make? Did I miss something?

Any help would be well appreciated.

I hope that you will find a couple of minutes to give me an answer.

Thanks in advance, and have a nice week.

Regards.

MSF March 1, 2017 04:19

Hi TemC,

I think your first mistake was not to work in your user-folder but instead in the openFOAM installation. A good guide for modifying transport models can be found here:
http://www.tfd.chalmers.se/~hani/kur...nFoam%20v2.pdf

Best,

Moritz

TemC March 1, 2017 06:03

Good morning Moritz,

Thank you very much for your reply.

Regards.


All times are GMT -4. The time now is 11:43.