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

Adding new member function to GidaspowErgunWenYu.C of dragModel

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 21, 2017, 05:23
Default Adding new member function to GidaspowErgunWenYu.C of dragModel
  #1
New Member
 
kian
Join Date: Jan 2014
Posts: 4
Rep Power: 12
kiang is on a distinguished road
Hi all foamers,
I added a new memberfunction to "GidaspowErgunWenYu", thin at the first in dragModel.H (Kp is the new member function)

#ifndef dragModel_H
#define dragModel_H

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#include "dictionary.H"
#include "phaseModel.H"
#include "runTimeSelectionTables.H"

namespace Foam
{

/*---------------------------------------------------------------------------*\
Class dragModel Declaration
\*---------------------------------------------------------------------------*/

class dragModel
{
protected:

// Protected data

const dictionary& interfaceDict_;
const volScalarField& alpha_;
const phaseModel& phasea_;
const phaseModel& phaseb_;


public:

//- Runtime type information
TypeName("dragModel");


// Declare runtime construction

declareRunTimeSelectionTable
(
autoPtr,
dragModel,
dictionary,
(
const dictionary& interfaceDict,
const volScalarField& alpha,
const phaseModel& phasea,
const phaseModel& phaseb
),
(interfaceDict, alpha, phasea, phaseb)
);


// Constructors

dragModel
(
const dictionary& interfaceDict,
const volScalarField& alpha,
const phaseModel& phasea,
const phaseModel& phaseb
);


//- Destructor
virtual ~dragModel();


// Selectors

static autoPtr<dragModel> New
(
const dictionary& interfaceDict,
const volScalarField& alpha,
const phaseModel& phasea,
const phaseModel& phaseb
);


// Member Functions

//- the dragfunction K used in the momentum eq.
// ddt(alpha*rhoa*Ua) + ... = ... alpha*beta*K*(Ua-Ub)
// ddt(beta*rhob*Ub) + ... = ... alpha*beta*K*(Ub-Ua)
// ********************************** NB ! *****************************
// for numerical reasons alpha and beta has been
// extracted from the dragFunction K,
// so you MUST divide K by alpha*beta when implemnting the drag function
// ********************************** NB ! *****************************
virtual tmp<volScalarField> K(const volScalarField& Ur) const = 0;
virtual tmp<volScalarField> Kp(const volScalarField& Ur) const = 0;
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************** *********************** //
Then I defined it in GidaspowErgunWenYu.H like this:
#ifndef GidaspowErgunWenYu_H
#define GidaspowErgunWenYu_H

#include "dragModel.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

/*---------------------------------------------------------------------------*\
Class GidaspowErgunWenYu Declaration
\*---------------------------------------------------------------------------*/

class GidaspowErgunWenYu
:
public dragModel
{

public:

//- Runtime type information
TypeName("GidaspowErgunWenYu");


// Constructors

//- Construct from components
GidaspowErgunWenYu
(
const dictionary& interfaceDict,
const volScalarField& alpha,
const phaseModel& phasea,
const phaseModel& phaseb
);


//- Destructor
virtual ~GidaspowErgunWenYu();


// Member Functions

tmp<volScalarField> K(const volScalarField& Ur) const;
tmp<volScalarField> Kp(const volScalarField& Ur) const;
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************** *********************** //
and finally in GidaspowErgunWenYu.C like this:

#include "GidaspowErgunWenYu.H"
#include "addToRunTimeSelectionTable.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

namespace Foam
{
defineTypeNameAndDebug(GidaspowErgunWenYu, 0);

addToRunTimeSelectionTable
(
dragModel,
GidaspowErgunWenYu,
dictionary
);
}


// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

Foam::GidaspowErgunWenYu::GidaspowErgunWenYu
(
const dictionary& interfaceDict,
const volScalarField& alpha,
const phaseModel& phasea,
const phaseModel& phaseb
)
:
dragModel(interfaceDict, alpha, phasea, phaseb)
{}


// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

Foam::GidaspowErgunWenYu::~GidaspowErgunWenYu()
{}


// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

Foam::tmp<Foam::volScalarField> Foam::GidaspowErgunWenYu::K
(
const volScalarField& Ur
) const
{
volScalarField beta = max(scalar(1) - alpha_, scalar(1.0e-6));

volScalarField bp = pow(beta, -2.65);
volScalarField Re = max(beta*Ur*phasea_.d()/phaseb_.nu(), scalar(1.0e-12));

volScalarField Cds = 24.0*(1.0 + 0.15*pow(Re, 0.687))/Re;

forAll(Re, celli)
{
if(Re[celli] > 1000.0)
{
Cds[celli] = 0.44;
}
}

// Wen and Yu (1966)
// modified in May 17, 2012, by C.Z.
tmp<volScalarField> tKWenYu = (0.75*Cds*phaseb_.rho()*Ur*bp/phasea_.d());
volScalarField& KWenYu = tKWenYu();

// Ergun
forAll (beta, cellj)
{
if (beta[cellj] < 0.8)
{
KWenYu[cellj] =
150.0*alpha_[cellj]*phaseb_.nu().value()*phaseb_.rho().value()
/sqr(beta[cellj]*phasea_.d().value())
+ 1.75*phaseb_.rho().value()*Ur[cellj]
/(beta[cellj]*phasea_.d().value());
}
}

return tKWenYu;

}

// ************************************************** *********************** //
///////////////////////////////////////////////////////////////////
Foam::tmp<Foam::volScalarField> Foam::GidaspowErgunWenYu::Kp
(
const volScalarField& Ur
) const
{
volScalarField beta = max(scalar(1) - alpha_, scalar(1.0e-6));

volScalarField bp = pow(beta, -2.65);
volScalarField Re = max(beta*Ur*phasea_.d()/phaseb_.nu(), scalar(1.0e-12));
volScalarField Cdsp = -24*(1+0.15*1.687*pow(Re, 0.687));

forAll(Re, celli)
{
if(Re[celli] > 1000.0)
{

Cdsp[celli] = -2*0.44;

}

}

// Wen and Yu (1966)
// modified in May 17, 2012, by C.Z.

tmp<volScalarField> tKWenYup = (0.75*Cdsp*phaseb_.nu()*phaseb_.rho()*Ur*bp/pow(phasea_.d(),2));
volScalarField& KWenYup = tKWenYup();

// Ergun
forAll (beta, cellj)
{
if (beta[cellj] < 0.8)
{

KWenYup[cellj] =
-1*150.0*alpha_[cellj]*phaseb_.nu().value()*phaseb_.rho().value()
/sqr(beta[cellj]*phasea_.d().value())
-2* 1.75*phaseb_.rho().value()*Ur[cellj]
/(beta[cellj]*phasea_.d().value());
}
}

return tKWenYup;
}
The question:
the solver is compiled successfully but when I use it for a test case I give following error:
#0 Foam::error:rintStack(Foam::Ostream&) at ??:?
#1 Foam::sigSegv::sigHandler(int) at ??:?
#2 in "/lib/x86_64-linux-gnu/libc.so.6"
#3 vtable for __cxxabiv1::__si_class_type_info in "/usr/lib/x86_64-linux-gnu/libstdc++.so.6"
Segmentation fault (core dumped)
The reason for this error:
in creatFields.H:
autoPtr<dragModel> draga = dragModel::New
(
interfacialProperties,
alpha,
phasea,
phaseb
);
volScalarField Kp
(
IOobject
(
"Kp",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
draga->Kp(mag(Ub-U1))
);
However it works only for first member function:
volScalarField K
(
IOobject
(
"K",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
draga->K(mag(Ub-Ua))
);
Any idea how it does not work for Kp but works for K?
kiang 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
Adding a new member function to SingleStepCombustion tatu OpenFOAM Programming & Development 1 January 8, 2014 23:54
[swak4Foam] installation problem with version 0.2.3 Claudio87 OpenFOAM Community Contributions 9 May 8, 2013 10:20
[blockMesh] error message with modeling a cube with a hold at the center hsingtzu OpenFOAM Meshing & Mesh Conversion 2 March 14, 2012 09:56
Adding a new member function in src/../turbulenceModel grandgo OpenFOAM Programming & Development 3 May 10, 2011 10:25
Droplet Evaporation Christian Main CFD Forum 2 February 27, 2007 06:27


All times are GMT -4. The time now is 01:56.