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

Can't call member function from extended Turbulence Model

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 21, 2013, 09:42
Default Can't call member function from extended Turbulence Model
  #1
New Member
 
Join Date: Jan 2012
Location: Germay - Stuttgart
Posts: 21
Rep Power: 0
HaZe is on a distinguished road
Hi Foamers!
I'm using OF-1.5-dev (I'm bound to) and I've made a extended k-Epsilon-Model (kEpsilonDetailed) with fields for the individual terms of k and Epsilon. Now I'd like to call some new functions from this model out of my solver for calculating an average of a cell set.

This works for the values of k and epsilon but not for my new functions. Could anyone help me accessing these functions.

The file writeOutputSets.H is called within my solver:
Code:
scalar vSet = 0.0;
scalar kk = 0.0;
scalar kDiss = 0.0;
scalar epseps = 0.0;

if(mesh.cellZones().findZoneID("cylinderOutputCells") > -1)
{

    const labelList& cylinderOutputAddressing =
                    mesh.cellZones()[mesh.cellZones().findZoneID("cylinderOutputCells")];
    

    forAll(cylinderOutputAddressing, i)
    {

        kk += (turbulence->k())()[cylinderOutputAddressing[i]]*mesh.V()[cylinderOutputAddressing[i]];
        epseps += (turbulence->epsilon())()[cylinderOutputAddressing[i]]*mesh.V()[cylinderOutputAddressing[i]];
        kDiff += (turbulence->kDiffusion())()[cylinderOutputAddressing[i]]*mesh.V()[cylinderOutputAddressing[i]];
        vSet += mesh.V()[cylinderOutputAddressing[i]];
}
    meanData << runTime.theta() << tab << vSet << tab << kk/vSet << tab << epseps/vSet << tab << kDiff/vSet << endl;
The green lines for getting the value of k and epsilon are working but the red one isn't.

Compiling the solver produces the error:
Code:
In file included from simpleCFMEngineDyMFoam.C:248:
writeOutputSets.H:43: error: ‘class Foam::compressible::RASModel’ has no member named ‘kDiffusion’
I've already read some threads how to access member functions in the forum and also that I should add the member functions to the RASModel (in a Chalmers Presentation) but I didn't understand it completely because of my missing C++ skills. This is part of my master thesis and unfortunately I don't have the time to get into the C++ to deep. So it would be great if anyone could help me with this.

At last here's the extended Turbulence Model. The lines which have to do with the wanted function are colored blue. Of course I will do it for all k and Epsilon terms but as they are working the same way it should be sufficient to just do a proof of concept with kDiffusion.

kEpsilonDetailed.C
Code:
#include "kEpsilonDetailed.H"
#include "addToRunTimeSelectionTable.H"
#include "wallFvPatch.H"

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

namespace Foam
{
namespace compressible
{
namespace RASModels
{

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

defineTypeNameAndDebug(kEpsilonDetailed, 0);
addToRunTimeSelectionTable(RASModel, kEpsilonDetailed, dictionary);

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

kEpsilonDetailed::kEpsilonDetailed
(
    const volScalarField& rho,
    const volVectorField& U,
    const surfaceScalarField& phi,
    basicThermo& thermophysicalModel
)
:
    RASModel(typeName, rho, U, phi, thermophysicalModel),

    Cmu_
    (
        dimensioned<scalar>::lookupOrAddToDict
        (
            "Cmu",
            coeffDict_,
            0.09
        )
    ),
    C1_
    (
        dimensioned<scalar>::lookupOrAddToDict
        (
            "C1",
            coeffDict_,
            1.44
        )
    ),
    C2_
    (
        dimensioned<scalar>::lookupOrAddToDict
        (
            "C2",
            coeffDict_,
            1.92
        )
    ),
    C3_
    (
        dimensioned<scalar>::lookupOrAddToDict
        (
            "C3",
            coeffDict_,
            -0.33
        )
    ),
    alphak_
    (
        dimensioned<scalar>::lookupOrAddToDict
        (
            "alphak",
            coeffDict_,
            1.0
        )
    ),
    alphaEps_
    (
        dimensioned<scalar>::lookupOrAddToDict
        (
            "alphaEps",
            coeffDict_,
            0.76923
        )
    ),
    alphah_
    (
        dimensioned<scalar>::lookupOrAddToDict
        (
            "alphah",
            coeffDict_,
            1.0
        )
    ),

    k_
    (
        IOobject
        (
            "k",
            runTime_.timeName(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh_
    ),

    epsilon_
    (
        IOobject
        (
            "epsilon",
            runTime_.timeName(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh_
    ),

    mut_
    (
        IOobject
        (
            "mut",
            runTime_.timeName(),
            mesh_,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        ),
        Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_)
    ),

    kDiffusion_
    (
        IOobject
        (
            "kDiffusion",
            runTime_.timeName(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
    mesh_
    ),

    kProduction_
    (
        IOobject
        (
            "kProduction",
            runTime_.timeName(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
    mesh_
    ),

    kTimeDerivative_
    (
        IOobject
        (
            "kTimeDerivative",
            runTime_.timeName(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
    mesh_
    ),

    kConvection_
    (
        IOobject
        (
            "kConvection",
            runTime_.timeName(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
    mesh_
    ),

    kCompVolWork_
    (
        IOobject
        (
            "kCompVolWork",
            runTime_.timeName(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
    mesh_
    ),

    kDissipation_
    (
        IOobject
        (
            "kDissipation",
            runTime_.timeName(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
    mesh_
    ),

    EpsilonDiffusion_
    (
        IOobject
        (
            "EpsilonDiffusion",
            runTime_.timeName(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
    mesh_
    ),

    EpsilonShear_
    (
        IOobject
        (
            "EpsilonShear",
            runTime_.timeName(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
    mesh_
    ),

    EpsilonTimeDerivative_
    (
        IOobject
        (
            "EpsilonTimeDerivative",
            runTime_.timeName(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
    mesh_
    ),

    EpsilonConvection_
    (
        IOobject
        (
            "EpsilonConvection",
            runTime_.timeName(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
    mesh_
    ),

    EpsilonCompVolWork_
    (
        IOobject
        (
            "EpsilonCompVolWork",
            runTime_.timeName(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
    mesh_
    ),

    EpsilonDilatation_
    (
        IOobject
        (
            "EpsilonDilatation",
            runTime_.timeName(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
    mesh_
    ),

    EpsilonIsotropicTurbulence_
    (
        IOobject
        (
            "EpsilonIsotropicTurbulence",
            runTime_.timeName(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
    mesh_
    )

{
//haze Details
    kProduction_ = kProduction();
    kDiffusion_ = kDiffusion();
    kTimeDerivative_ = kTimeDerivative();
    kConvection_ = kConvection();
    kCompVolWork_ = kCompVolWork();
    kDissipation_ = kDissipation();

    EpsilonShear_ = EpsilonShear();
    EpsilonDiffusion_ = EpsilonDiffusion();
    EpsilonTimeDerivative_ = EpsilonTimeDerivative();
    EpsilonConvection_ = EpsilonConvection();
    EpsilonCompVolWork_ = EpsilonCompVolWork();
    EpsilonDilatation_ = EpsilonDilatation();
    EpsilonIsotropicTurbulence_ = EpsilonIsotropicTurbulence();
//    Details end

#   include "wallViscosityI.H"

    printCoeffs();
}


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

tmp<volSymmTensorField> kEpsilonDetailed::R() const
{
    return tmp<volSymmTensorField>
    (
        new volSymmTensorField
        (
            IOobject
            (
                "R",
                runTime_.timeName(),
                mesh_,
                IOobject::NO_READ,
                IOobject::AUTO_WRITE
            ),
            ((2.0/3.0)*I)*k_ - (mut_/rho_)*dev(twoSymm(fvc::grad(U_))),
            k_.boundaryField().types()
        )
    );
}

tmp<volSymmTensorField> kEpsilonDetailed::devRhoReff() const
{
    return tmp<volSymmTensorField>
    (
        new volSymmTensorField
        (
            IOobject
            (
                "devRhoReff",
                runTime_.timeName(),
                mesh_,
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
           -muEff()*dev(twoSymm(fvc::grad(U_)))
        )
    );
}

//haze
tmp<volScalarField> kEpsilonDetailed::kDiffusion() const
{
    return
    (
            -fvc::laplacian(DkEff(), k_)
    );
}
tmp<volScalarField> kEpsilonDetailed::kProduction() const
{
    return
    (
         mut_*(fvc::grad(U_) && dev(twoSymm(fvc::grad(U_))))
    );
}
tmp<volScalarField> kEpsilonDetailed::kTimeDerivative() const
{
    return
    (
         fvc::ddt(rho_, k_)
    );
}
tmp<volScalarField> kEpsilonDetailed::kConvection() const
{
    return
    (
         fvc::div(phi_, k_)
    );
}

tmp<volScalarField> kEpsilonDetailed::kCompVolWork() const
{
    return
    (
        (2.0/3.0)*rho_*(fvc::div(phi_/fvc::interpolate(rho_)))*k_
    );
}
tmp<volScalarField> kEpsilonDetailed::kDissipation() const
{
    return
    (
         rho_*epsilon_/k_*k_
    );
}

//Epsilon terms
tmp<volScalarField> kEpsilonDetailed::EpsilonDiffusion() const
{
    return
    (
            -fvc::laplacian(DepsilonEff(), epsilon_)
    );
}
tmp<volScalarField> kEpsilonDetailed::EpsilonShear() const
{
    return
    (
         C1_*(mut_*(fvc::grad(U_) && dev(twoSymm(fvc::grad(U_)))))*epsilon_/k_
    );
}
tmp<volScalarField> kEpsilonDetailed::EpsilonTimeDerivative() const
{
    return
    (
         fvc::ddt(rho_, epsilon_)
    );
}
tmp<volScalarField> kEpsilonDetailed::EpsilonConvection() const
{
    return
    (
         fvc::div(phi_, epsilon_)
    );
}

tmp<volScalarField> kEpsilonDetailed::EpsilonCompVolWork() const
{
    return
    (
        (2.0/3.0)*C1_*rho_*(fvc::div(phi_/fvc::interpolate(rho_)))*epsilon_
    );
}
tmp<volScalarField> kEpsilonDetailed::EpsilonDilatation() const
{
    return
    (
         C3_*rho_*(fvc::div(phi_/fvc::interpolate(rho_)))*epsilon_
    );
}
tmp<volScalarField> kEpsilonDetailed::EpsilonIsotropicTurbulence() const
{
    return
    (
         C2_*rho_*sqr(epsilon_)/k_
    );
}

//haze ende

tmp<fvVectorMatrix> kEpsilonDetailed::divDevRhoReff(volVectorField& U) const
{
    return
    (
      - fvm::laplacian(muEff(), U)
      - fvc::div(muEff()*dev2(fvc::grad(U)().T()))
    );
}

bool kEpsilonDetailed::read()
{
    if (RASModel::read())
    {
        Cmu_.readIfPresent(coeffDict_);
        C1_.readIfPresent(coeffDict_);
        C2_.readIfPresent(coeffDict_);
        C3_.readIfPresent(coeffDict_);
        alphak_.readIfPresent(coeffDict_);
        alphaEps_.readIfPresent(coeffDict_);
        alphah_.readIfPresent(coeffDict_);

        return true;
    }
    else
    {
        return false;
    }
}


void kEpsilonDetailed::correct()
{
    // Bound in case of topological change.  Signalling currently not available
    // HJ, 22/Aug/2007
    bound(k_, k0_);
    bound(epsilon_, epsilon0_);

    if (!turbulence_)
    {
        // Re-calculate viscosity
        mut_ = rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
#       include "wallViscosityI.H"
        return;
    }

    RASModel::correct();

    volScalarField divU = fvc::div(phi_/fvc::interpolate(rho_));

    if (mesh_.moving())
    {
        divU += fvc::div(mesh_.phi());
    }

    tmp<volTensorField> tgradU = fvc::grad(U_);
    volScalarField G = mut_*(tgradU() && dev(twoSymm(tgradU())));
    tgradU.clear();

#   include "wallFunctionsI.H"

    // Dissipation equation
    tmp<fvScalarMatrix> epsEqn
    (
        fvm::ddt(rho_, epsilon_)
      + fvm::div(phi_, epsilon_)
      - fvm::laplacian(DepsilonEff(), epsilon_)
     ==
        C1_*G*epsilon_/k_
      - fvm::SuSp(((2.0/3.0)*C1_ + C3_)*rho_*divU, epsilon_)
      - fvm::Sp(C2_*rho_*epsilon_/k_, epsilon_)
    );

#   include "wallDissipationI.H"

    epsEqn().relax();

    solve(epsEqn);
    bound(epsilon_, epsilon0_);


    // Turbulent kinetic energy equation

    tmp<fvScalarMatrix> kEqn
    (
        fvm::ddt(rho_, k_)
      + fvm::div(phi_, k_)
      - fvm::laplacian(DkEff(), k_)
     ==
        G
      - fvm::SuSp((2.0/3.0)*rho_*divU, k_)
      - fvm::Sp(rho_*epsilon_/k_, k_)
    );

    kEqn().relax();
    solve(kEqn);
    bound(k_, k0_);


    // Re-calculate viscosity
    mut_ = rho_*Cmu_*sqr(k_)/epsilon_;

#   include "wallViscosityI.H"

// Haze Details
    kDiffusion_ = kDiffusion();
    kProduction_ = kProduction();
    kTimeDerivative_ = kTimeDerivative();
    kConvection_ = kConvection();
    kCompVolWork_ = kCompVolWork();
    kDissipation_ = kDissipation();

    EpsilonShear_ = EpsilonShear();
    EpsilonDiffusion_ = EpsilonDiffusion();
    EpsilonTimeDerivative_ = EpsilonTimeDerivative();
    EpsilonConvection_ = EpsilonConvection();
    EpsilonCompVolWork_ = EpsilonCompVolWork();
    EpsilonDilatation_ = EpsilonDilatation();
    EpsilonIsotropicTurbulence_ = EpsilonIsotropicTurbulence();

// Details end

}


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

} // End namespace RASModels
} // End namespace compressible
} // End namespace Foam
kEpsilonDetailed.H
Code:
#ifndef compressiblekEpsilon_H
#define compressiblekEpsilon_H

#include "RASModel.H"

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

namespace Foam
{
namespace compressible
{
namespace RASModels
{

/*---------------------------------------------------------------------------*\
                           Class kEpsilonDetailed Declaration
\*---------------------------------------------------------------------------*/

class kEpsilonDetailed
:
    public RASModel
{
    // Private data

        // Model coefficients

//            dimensionedScalar Cmu;
            dimensionedScalar Cmu_;
            dimensionedScalar C1_;
            dimensionedScalar C2_;
            dimensionedScalar C3_;
            dimensionedScalar alphak_;
            dimensionedScalar alphaEps_;
            dimensionedScalar alphah_;

        // Fields

            volScalarField k_;
            volScalarField epsilon_;
            volScalarField mut_;
//Haze add
        volScalarField kDiffusion_;
        volScalarField kProduction_;
        volScalarField kTimeDerivative_;
        volScalarField kConvection_;
        volScalarField kCompVolWork_;
        volScalarField kDissipation_;

        volScalarField EpsilonDiffusion_;
        volScalarField EpsilonShear_;
        volScalarField EpsilonTimeDerivative_;
        volScalarField EpsilonConvection_;
        volScalarField EpsilonCompVolWork_;
        volScalarField EpsilonDilatation_;
        volScalarField EpsilonIsotropicTurbulence_;
//End Haze

public:

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

    // Constructors

        //- from components
        kEpsilonDetailed
        (
            const volScalarField& rho,
            const volVectorField& U,
            const surfaceScalarField& phi,
            basicThermo& thermophysicalModel
        );


    // Destructor

        ~kEpsilonDetailed()
        {}


    // Member Functions

        //- Return the turbulence viscosity
        tmp<volScalarField> mut() const
        {
            return mut_;
        }

        //- Return the effective diffusivity for k
        tmp<volScalarField> DkEff() const
        {
            return tmp<volScalarField>
            (
                new volScalarField("DkEff", alphak_*mut_ + mu())
            );
        }

        //- Return the effective diffusivity for epsilon
        tmp<volScalarField> DepsilonEff() const
        {
            return tmp<volScalarField>
            (
                new volScalarField("DepsilonEff", alphaEps_*mut_ + mu())
            );
        }

        //- Return the effective turbulent thermal diffusivity
        tmp<volScalarField> alphaEff() const
        {
            return tmp<volScalarField>
            (
                new volScalarField("alphaEff", alphah_*mut_ + alpha())
            );
        }

        //- Return the turbulence kinetic energy
        tmp<volScalarField> k() const
        {
            return k_;
        }

        //- Return the turbulence kinetic energy dissipation rate
        tmp<volScalarField> epsilon() const
        {
            return epsilon_;
        }
//k Epsilon Details by HaZE 23.9.2013

    //- Return the kinetic energy diffusion
        tmp<volScalarField> kDiffusion() const;

    //- Return the kinetic energy Production
        tmp<volScalarField> kProduction() const;

    //- Return the kinetic energy Time Derivative
        tmp<volScalarField> kTimeDerivative() const;

    //- Return the kinetic energy Convection
        tmp<volScalarField> kConvection() const;

    //- Return the kinetic energy Production from compressible Work
        tmp<volScalarField> kCompVolWork() const;

    //- Return the kinetic energy Dissipation
        tmp<volScalarField> kDissipation() const;



    //- Return the dissipation diffusion
        tmp<volScalarField> EpsilonDiffusion() const;

    //- Return the dissipation Production from shear
        tmp<volScalarField> EpsilonShear() const;

    //- Return the dissipation Time Derivative
        tmp<volScalarField> EpsilonTimeDerivative() const;

    //- Return the dissipation Convection
        tmp<volScalarField> EpsilonConvection() const;

    //- Return the dissipation Source from compressible work
        tmp<volScalarField> EpsilonCompVolWork() const;

    //- Return the dissipation Source from Dilatation
        tmp<volScalarField> EpsilonDilatation() const;

    //- Return the dissipation Source from isotropic Turbulence
        tmp<volScalarField> EpsilonIsotropicTurbulence() const;

//Details end
        //- Return the Reynolds stress tensor
        tmp<volSymmTensorField> R() const;

        //- Return the effective stress tensor including the laminar stress
        tmp<volSymmTensorField> devRhoReff() const;

        //- Return the source term for the momentum equation
        tmp<fvVectorMatrix> divDevRhoReff(volVectorField& U) const;

        //- Solve the turbulence equations and correct the turbulence viscosity
        void correct();

        //- Read turbulenceProperties dictionary
        bool read();
};


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

} // End namespace RASModels
} // End namespace compressible
} // End namespace Foam

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

#endif
HaZe is offline   Reply With Quote

Old   November 21, 2013, 13:21
Default
  #2
New Member
 
Join Date: Jan 2012
Location: Germay - Stuttgart
Posts: 21
Rep Power: 0
HaZe is on a distinguished road
Ok, I made out I have to add a virtual member function in the class the turbulence model is derived from.

So I added:
Code:
virtual tmp<volScalarField> kDiffusion() const = 0;
in the member functions of RASModel.H

Then the following comiling error occurs:
Code:
In file included from laminar/laminar.H:40,
                 from laminar/laminar.C:27:
lnInclude/RASModel.H: In static member function ‘static Foam::autoPtr<Foam::compressible::RASModel> Foam::compressible::RASModel::adddictionaryConstructorToTable<RASModelType>::New(const Foam::volScalarField&, const Foam::volVectorField&, const Foam::surfaceScalarField&, Foam::basicThermo&) [with RASModelType = Foam::compressible::RASModels::laminar]’:
lnInclude/RASModel.H:150:   instantiated from ‘Foam::compressible::RASModel::adddictionaryConstructorToTable<RASModelType>::adddictionaryConstructorToTable(const Foam::word&) [with RASModelType = Foam::compressible::RASModels::laminar]’
laminar/laminar.C:42:   instantiated from here
lnInclude/RASModel.H:138: error: cannot allocate an object of abstract type ‘Foam::compressible::RASModels::laminar’
laminar/laminar.H:58: note:   because the following virtual functions are pure within ‘Foam::compressible::RASModels::laminar’:
lnInclude/RASModel.H:279: note:     virtual Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::compressible::RASModel::kDiffusion() const
In file included from kEpsilon/kEpsilon.H:54,
                 from kEpsilon/kEpsilon.C:27:
lnInclude/RASModel.H: In static member function ‘static Foam::autoPtr<Foam::compressible::RASModel> Foam::compressible::RASModel::adddictionaryConstructorToTable<RASModelType>::New(const Foam::volScalarField&, const Foam::volVectorField&, const Foam::surfaceScalarField&, Foam::basicThermo&) [with RASModelType = Foam::compressible::RASModels::kEpsilon]’:
lnInclude/RASModel.H:150:   instantiated from ‘Foam::compressible::RASModel::adddictionaryConstructorToTable<RASModelType>::adddictionaryConstructorToTable(const Foam::word&) [with RASModelType = Foam::compressible::RASModels::kEpsilon]’
kEpsilon/kEpsilon.C:43:   instantiated from here
lnInclude/RASModel.H:138: error: cannot allocate an object of abstract type ‘Foam::compressible::RASModels::kEpsilon’
kEpsilon/kEpsilon.H:72: note:   because the following virtual functions are pure within ‘Foam::compressible::RASModels::kEpsilon’:
lnInclude/RASModel.H:279: note:     virtual Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::compressible::RASModel::kDiffusion() const
SOURCE=kEpsilonDetailed/kEpsilonDetailed.C ;  g++ -m64 -Dlinux64 -DDP -DFOAM_DEV_REVISION_NUMBER=1861 -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3  -DNoRepository -ftemplate-depth-40 -I/home/haze/OpenFOAM/OpenFOAM-1.5-dev/src/finiteVolume/lnInclude -I/home/haze/OpenFOAM/OpenFOAM-1.5-dev/src/meshTools/lnInclude -I/home/haze/OpenFOAM/OpenFOAM-1.5-dev/src/thermophysicalModels/basic/lnInclude -IlnInclude -I. -I/home/haze/OpenFOAM/OpenFOAM-1.5-dev/src/OpenFOAM/lnInclude -I/home/haze/OpenFOAM/OpenFOAM-1.5-dev/src/OSspecific/Unix/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/kEpsilonDetailed.o
If I understand it correctly in all other models than mine is the implementation of this virtual function missing. Is it possible to fob all models at once or do I have to add an "empty" kDiffusion() function to all turbulence models? Or am I running into a dead end?
HaZe is offline   Reply With Quote

Old   November 25, 2013, 05:47
Default
  #3
New Member
 
Join Date: Jan 2012
Location: Germay - Stuttgart
Posts: 21
Rep Power: 0
HaZe is on a distinguished road
One step further I made a workaround through commenting out all other models than mine in Make/files.

Code:
/* RAS turbulence models */
RASModel/RASModel.C
RASModel/newRASModel.C
kEpsilonDetailed/kEpsilonDetailed.C
/*laminar/laminar.C
kEpsilon/kEpsilon.C
RNGkEpsilon/RNGkEpsilon.C
LaunderSharmaKE/LaunderSharmaKE.C
LRR/LRR.C
LaunderGibsonRSTM/LaunderGibsonRSTM.C
realizableKE/realizableKE.C
SpalartAllmaras/SpalartAllmaras.C
kOmegaSST/kOmegaSST.C
kOmegaSST_LowRe/kOmegaSST_LowRe.C
*/
/* Wall functions */
wallFunctions/mutWallFunctions/mutStandardRoughWallFunction/mutStandardRoughWallFunctionFvPatchScalarField.C

/* Patch fields */
derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C
derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C

LIB = $(FOAM_LIBBIN)/libcompressibleRASModels
Now it's at least compiling without errors.

But now I'm getting a Segmentation Fault while running the solver:
Code:
0x00007ffff768f87f in Foam::tmp<Foam::GeometricField<Foam::outerProduct<Foam::Vector<double>, Foam::Vector<double> >::type, Foam::fvPatchField, Foam::volMesh> > Foam::fvc::grad<Foam::Vector<double> >(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) () from /home/haze/OpenFOAM/OpenFOAM-1.5-dev/lib/linux64GccDPOpt/libcompressibleRASModels.so
Anyone any ideas what's the matter? I can't believe there's no one who doesn't know any hints for me. Come on people, here's someone who'd like to go further but can't without assistance.
HaZe is offline   Reply With Quote

Old   November 26, 2013, 03:08
Default
  #4
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22
Bernhard is on a distinguished road
I am wondering why you want to add another member function to the model. Of course this would be the neat way to do it, but as you are changing your solver anyhow, and as far as I can tell, you are not looking for high portability and re-usage of code, can't you, in your solver, put
Code:
 volScalarField kDiffusion=-fvc::laplacian(turbulence->DkEff(), k);
and work with that?
Bernhard is offline   Reply With Quote

Old   November 26, 2013, 04:54
Default
  #5
New Member
 
Join Date: Jan 2012
Location: Germay - Stuttgart
Posts: 21
Rep Power: 0
HaZe is on a distinguished road
Quote:
Originally Posted by Bernhard View Post
I am wondering why you want to add another member function to the model. Of course this would be the neat way to do it, but as you are changing your solver anyhow, and as far as I can tell, you are not looking for high portability and re-usage of code, can't you, in your solver, put
Code:
 volScalarField kDiffusion=-fvc::laplacian(turbulence->DkEff(), k);
and work with that?
Changing the solver and the turbulence model results of the two steps I made. At first I added all terms of k and epsilon as fields to the turbulence lib - just because I needed this fields and wanted to share my code with the community.
Next step was averaging this fields because this averaged values will be used in developing a 1-d turbulence model (as far as this makes sense). And plainly and simply because there were already averaging functions in the solver, I wanted to add the averaging process of my new fields there, too.

The first step is working well. But then I had this problems with looking up the values of kDiffusion etc. out of the turbulence model code to use it in the averaging process.
Unfortunately I can't use neither swak4foam nor a functionobject as you can read here [1]. This is the reason I used the averaging code in my solver.

So if there's any method to let my extended turbulence model untouched and independently look up the newly calculated fields (kDiffusion, etc.) for using them somewhere else, it would be the best way to do.

I'm definitely just to unexperienced in C++ to overview this all and now I'm stuck. But what I can say is I really learned a lot of the C++/OF-programming and would like to learn a lot more.

To calculate the single terms of k and epsilon directly in my solver didn't come to my mind. And as I would like to give an example for all community members how to add a new field of the turbulence model to it, it would be great to have my two tasks independent. But as a last resort I will follow your recommendation and calculate everything in the solver.

[1] http://www.cfd-online.com/Forums/ope...olaverage.html
HaZe is offline   Reply With Quote

Old   November 26, 2013, 05:11
Default
  #6
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22
Bernhard is on a distinguished road
You also might find this link useful: http://sourceforge.net/projects/open...thrinKissling/ It explains some basics about the structure with derived models, and how the communication with the base class should work. With the RASModel you have to be careful, as it again inherits some things from turbulenceModel.
Bernhard is offline   Reply With Quote

Old   December 2, 2013, 05:38
Default
  #7
New Member
 
Join Date: Jan 2012
Location: Germay - Stuttgart
Posts: 21
Rep Power: 0
HaZe is on a distinguished road
Quote:
Originally Posted by Bernhard View Post
... but as you are changing your solver anyhow, and as far as I can tell, you are not looking for high portability and re-usage of code, can't you, in your solver, put
Code:
 volScalarField kDiffusion=-fvc::laplacian(turbulence->DkEff(), k);
and work with that?
Hi again. After some other failed experiments I came back to your solution. It isn't working either. And this is because - guess what - DkEff() is not a member of RASModel. :-/

Code:
writeOutputSets.H:25: error: ‘class Foam::compressible::RASModel’ has no member named ‘DkEff’
I read the suggestend presentation and a lot other programming presentations of previous OF workshops, too. But none of them could answer my specific problem.
HaZe is offline   Reply With Quote

Reply

Tags
member function, turbulence model


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
[Other] mesh airfoil NACA0012 anand_30 OpenFOAM Meshing & Mesh Conversion 13 March 7, 2022 18:22
[blockMesh] non-orthogonal faces and incorrect orientation? nennbs OpenFOAM Meshing & Mesh Conversion 7 April 17, 2013 06:42
Centrifugal Pump and Turbulence Model Michiel CFX 12 January 25, 2010 04:20
Problem with compile the setParabolicInlet ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 21:50
[OpenFOAM] LibvtkFoamso fred ParaView 2 November 18, 2005 20:01


All times are GMT -4. The time now is 18:04.