|
[Sponsors] |
November 2, 2016, 07:14 |
Custom viscosity model
|
#1 |
Senior Member
Join Date: Jan 2015
Posts: 150
Rep Power: 11 |
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; } 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 ??:? |
|
Tags |
openfoam-dev, viscosity model |
|
|
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 |