View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002316 | OpenFOAM | Bug | public | 2016-11-02 15:22 | 2018-07-10 11:24 |
Reporter | Svensen | Assigned To | wyldckat | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | no change required | ||
Platform | GNU/Linux | OS | Ubuntu | OS Version | 14.04 |
Product Version | dev | ||||
Summary | 0002316: Custom viscosity model. Runtime crash | ||||
Description | Hi, I'm trying to implement a precise viscosity model using data from experimental measurements. I've created a folder "Spline" and two files "Spline.C" and "Spline.H". I've redefined calcNu() method as following: Foam::tmp<Foam::volScalarField> Foam::viscosityModels::Spline::calcNu() const { volScalarField strain(strainRate()); //for all elements in the field for (unsigned i=0; i<strain.size(); i++){ double n = strain[i]; const double dn = 250/sizeof(visc); n /= dn; //calc an index in array unsigned x1 = floor(n); if (x1 < 1) x1 = 0; //correct minimum value if (x1 >= sizeof(visc)) x1 = sizeof(visc)-2; //correct maximum value unsigned x2 = x1 + 1; if (x1 != x2){ double y1 = visc[x1]; //visc array contains the measured viscosity values double y2 = visc[x2]; double k = y2 - y1; //because x2-x1 = 1 double b = x2*y1 - x1*y2; //because x2-x1 = 1 strain[i] = k*n + b; } else{ strain[i] = visc[x1]; } } return dimensionedScalar("one", dimLength*dimLength, 1.0)*strain; } Compilation was OK. However, I've got a runtime error: ... Selecting incompressible transport model Spline #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 ??:? After some experiments I've just found that problem is in line "strain[i] = k*n + b;". However I still don't understand why the problem happens here. OpenFOAM documentation states that volScalarFiels is based on List, therefore a value can be assigned to individual element. Is it some issue in OpenFOAM sources ? | ||||
Tags | non-Newtonian, rheology, viscosity | ||||
|
From what I can deduce, the critical problem comes from the probable misuse of "sizeof"... but since it's not clearly stated what "visc" really is, I'm unable to diagnose the problem any further. That said, this issue looks too much like user support, for which this bug reporting platform was not designed for, as briefly explained in section "Report Issues & Fix Bugs" of the "Development" page: http://openfoam.org/dev/#layers-widget-layers-pro-call-to-action-5 I've searched for posts on the forum at CFD-Online and I see that you've posted your question there: http://www.cfd-online.com/Forums/openfoam-programming-development/179545-custom-viscosity-model.html Therefore, I'm closing this report as "no change required". If there is any conclusion at the forum thread that there is a bug related to this, we can re-open this again. |
Date Modified | Username | Field | Change |
---|---|---|---|
2016-11-02 15:22 | Svensen | New Issue | |
2016-11-02 15:22 | Svensen | Tag Attached: non-Newtonian | |
2016-11-02 15:22 | Svensen | Tag Attached: Programmer's Guide | |
2016-11-02 15:22 | Svensen | Tag Attached: rheology | |
2016-11-02 15:22 | Svensen | Tag Attached: viscosity | |
2016-11-02 23:46 | wyldckat | Assigned To | => wyldckat |
2016-11-02 23:46 | wyldckat | Status | new => closed |
2016-11-02 23:46 | wyldckat | Resolution | open => no change required |
2016-11-02 23:46 | wyldckat | Note Added: 0007087 | |
2018-07-10 11:24 | administrator | Tag Detached: Programmer's Guide |