|
[Sponsors] |
May 8, 2015, 10:50 |
Declaring volScalarField in viscosityModel
|
#1 |
New Member
Join Date: Jun 2014
Posts: 4
Rep Power: 12 |
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 ??:? 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; 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_ ) {} 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) ) 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_; } 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 |
|
|
|
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 |