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

Declaring volScalarField in viscosityModel

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 8, 2015, 10:50
Default Declaring volScalarField in viscosityModel
  #1
New Member
 
Join Date: Jun 2014
Posts: 4
Rep Power: 12
zbtlfd is on a distinguished road
Dear All,

I've been trying to implement a new volScalarField for the kinematic viscosity into the Herschel-Bulkley viscosity model. So far I've tried a few versions of initialising it and they have compiled without errors. However, the solver always crashes, when the "calcNu()" function tries to return the newly implemented viscosity field without even manipulating it (just as a test case for now). The error message is always as follows:

Code:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Reading field p

Reading field U

Reading/calculating face flux field phi

Selecting incompressible transport model HerschelBulkley
test1
#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigSegv::sigHandler(int) at ??:?
#2  
 at sigaction.c:?
#3  Foam::List<double>::List(Foam::List<double> const&) at ??:?
#4  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) at ??:?
#5  Foam::viscosityModels::HerschelBulkley::HerschelBulkley(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::adddictionaryConstructorToTable<Foam::viscosityModels::HerschelBulkley>::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::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 ??:?
#8  Foam::singlePhaseTransportModel::singlePhaseTransportModel(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&) at ??:?
#9  
 at ??:?
#10  __libc_start_main at ??:?
#11  
 at ??:?
In the HerschelBulkley.H file, I've declared the new "volScalarField kinVisc":

Code:
class HerschelBulkley
:
    public viscosityModel
{
    // Private data

        dictionary HerschelBulkleyCoeffs_;

        dimensionedScalar k_;
        dimensionedScalar n_;
        dimensionedScalar tau0_;
        dimensionedScalar nu0_;

        volScalarField nu_;
        mutable volScalarField kinVisc_;


    // Private Member Functions

        //- Calculate and return the laminar viscosity
        tmp<volScalarField> calcNu() const;
and in the constructor of the HerschelBulkley class it is defined the same as "nu_"

Code:
Foam::viscosityModels::HerschelBulkley::HerschelBulkley
(
    const word& name,
    const dictionary& viscosityProperties,
    const volVectorField& U,
    const surfaceScalarField& phi
)
:
    viscosityModel(name, viscosityProperties, U, phi),
    HerschelBulkleyCoeffs_(viscosityProperties.subDict(typeName + "Coeffs")),
    k_(HerschelBulkleyCoeffs_.lookup("k")),
    n_(HerschelBulkleyCoeffs_.lookup("n")),
    tau0_(HerschelBulkleyCoeffs_.lookup("tau0")),
    nu0_(HerschelBulkleyCoeffs_.lookup("nu0")),
    nu_
    (
        IOobject
        (
            name,
            U_.time().timeName(),
            U_.db(),
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        calcNu()
    ),
    kinVisc_
    (
        nu_
    )
{}
I've tried alternative ways of defining kinVisc without copying nu_'s properties:

Code:
    kinVisc_
    (
        IOobject
        (
            "kinVisc",    //name
            U_.time().timeName(),
            U_.db(),    //U_.mesh(),
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        U_.mesh(),
        dimensionedScalar("kinVisc", dimensionSet(0, 2, -1, 0, 0, 0, 0), 0.01)
    //dimensionSet(0, 2, -1, 0, 0, 0, 0)
    )
In the "calcNu()" function it looks like this:

Code:
Foam::tmp<Foam::volScalarField>
Foam::viscosityModels::HerschelBulkley::calcNu() const
{
    dimensionedScalar tone("tone", dimTime, 1.0);
    dimensionedScalar rtone("rtone", dimless/dimTime, 1.0);
    tmp<volScalarField> sr(strainRate());

 // return
 // (
 //     min
 //     (
 //         nu0_,
 //         (tau0_ + k_*rtone*(pow(tone*sr(), n_) - pow(tone*tau0_/nu0_, n_)))
 //        /max(sr(), dimensionedScalar("VSMALL", dimless/dimTime, VSMALL))
 //     )
 // );

    /*return
    (
        min
        (
            nu0_,
            (tau0_*(1.0-exp(-m_*tone*sr())) + k_*rtone*pow(tone*sr(), n_))
           /(max(sr(), dimensionedScalar ("VSMALL", dimless/dimTime, VSMALL)))
        )
    );*/


    Info << "test1" << endl;
    /*forAll(U_.mesh().cells(),celli)
    {
        Info << "test2" << celli << endl;
        kinVisc_[celli] = 0.01;
        Info << "test3" << celli << endl;
    }*/  
    return kinVisc_;
}
Though it compiles without errors, the codes crashes when trying to return the kinVisc_ volScalarField.

Declaring kinVisc_ as a tmp<volScalarField> didn't work either.

Could anyone help me out here and tell me how it should be done correctly?

Thank you very much and best regards,

Lukas
zbtlfd is offline   Reply With Quote

Reply


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
[openSmoke] libOpenSMOKE Tobi OpenFOAM Community Contributions 562 January 25, 2023 10:21
using chemkin JMDag2004 OpenFOAM Pre-Processing 2 March 8, 2016 23:38
make a dimensionedScalar to be volScalarField sharonyue OpenFOAM Programming & Development 4 April 2, 2014 06:44
multiplicate all elements of volScalarField with scalar to get new volScalarField maybee OpenFOAM Programming & Development 2 February 18, 2014 16:43
writing execFlowFunctionObjects immortality OpenFOAM Post-Processing 30 September 15, 2013 07:16


All times are GMT -4. The time now is 06:10.