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

Custom viscosity model

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   November 2, 2016, 07:14
Default Custom viscosity model
  #1
Senior Member
 
Join Date: Jan 2015
Posts: 150
Rep Power: 11
Svensen is on a distinguished road
Hi, I'm trying to implement a precise viscosity model from experimental measurements.

I've created a folder "Spline" and two files "Spline.C" and "Spline.H".
I've redefined calcNu() method in the following was:


Code:
Foam::tmp<Foam::volScalarField>
Foam::viscosityModels::Spline::calcNu() const
{
    volScalarField strain = strainRate();
     volScalarField nu = strain;
     
//for each element of a field
     for (unsigned i=0; i<strain.size(); i++){
         double n = strain[i]; //get a strain-rate
    
        const double dn = 250/sizeof(visc);
        n /= dn; //scale it to match an index of array
    
/*visc array includes 2000 values of measured viscosity*/
        unsigned x1 = floor(n);
        if (x1 < 1) x1 = 0; //check minimum value
        if (x1 >= sizeof(visc)) x1 = sizeof(visc)-2; //check maximum value
        
        unsigned x2 = x1 + 1;
    
        if (x1 != x2){
            double y1 = visc[x1];
            double y2 = visc[x2];
        
            double k = y2 - y1; //linear interpolation
            double b = x2*y1 - x1*y2;
        
            nu[i] = k*n + b;
        }
        else{
            nu[i] = visc[x1];
        }
     }
    
    return nu;
}
It compiles with no error, however after start of pimpleFoam it exits with the following log:
Code:
#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigFpe::sigHandler(int) at ??:?
#2  ? in "/lib/x86_64-linux-gnu/libc.so.6"
#3  Foam::viscosityModels::Spline::calcNu() const at ??:?
#4  Foam::viscosityModels::Spline::Spline(Foam::word const&, Foam::dictionary const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&) at ??:?
#5  Foam::viscosityModel::adddictionaryConstructorToTable<Foam::viscosityModels::Spline>::New(Foam::word const&, Foam::dictionary const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&) at ??:?
#6  Foam::viscosityModel::New(Foam::word const&, Foam::dictionary const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&) at ??:?
#7  Foam::singlePhaseTransportModel::singlePhaseTransportModel(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&) at ??:?
#8  ? at ??:?
#9  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#10  ? at ??:?
What can be wrong with my code ?
Svensen is offline   Reply With Quote

 

Tags
openfoam-dev, viscosity model


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
Problem with divergence TDK FLUENT 13 December 14, 2018 06:00
New Viscosity Model - Best Practice for Temporary Values MaSch OpenFOAM Programming & Development 6 March 16, 2018 03:51
Time constant in Herschel-Bulkley viscosity model Mikel6 Main CFD Forum 0 October 17, 2016 04:52
Viscosity ratio in gamma-theta transition model based on k-w sst turb model Qiaol618 Main CFD Forum 8 June 9, 2012 06:43
How to modify the viscosity model mpml OpenFOAM Running, Solving & CFD 4 October 13, 2010 07:44


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