CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Segmentation fault - new enthalpy equation (https://www.cfd-online.com/Forums/openfoam/79497-segmentation-fault-new-enthalpy-equation.html)

SilPaut August 25, 2010 11:55

Segmentation fault - new enthalpy equation
 
Hi every body!

I use OF1.5dev, and I changed the enthalpy equation in this form:
Code:

{
    reactingMixture& multiMix = (reactingMixture&) thermo->composition();
    PtrList<reactingMixture::reactionThermo> speciesData = multiMix.speciesData();
 
    dictionary eqnOpts = mesh.solutionDict().subDict("EquationOptions");

    bool useDiffA  = false;
    bool useDiffB  = false;
    bool useViscDissipation  = false;
    bool useTurbDissipation  = false;

    if ( eqnOpts.found("energyDiffusionA" ) )
    {
        useDiffA  = Switch(eqnOpts.lookup("energyDiffusionA"));
    }

    if ( eqnOpts.found("energyDiffusionB" ) )
    {
        useDiffB  = Switch(eqnOpts.lookup("energyDiffusionB"));
    } 

    if (useDiffA)
    {
        Info << "Calculating energy correction A" << endl;
 
        energySource *= 0.0; 

        surfaceScalarField alphaF = fvc::interpolate(turbulence->alphaEff() );
        surfaceScalarField muF = fvc::interpolate( turbulence->muEff() );
       
        volScalarField hY("hY",h);
        surfaceScalarField alphaH("alphaH", alphaF * fvc::interpolate( h) );

        for (label i = 0; i < Y.size(); i++) {
            Info << "\tCalculating differential flux for species " <<  Y[i].name() << endl;
            reactingMixture::reactionThermo& spData = speciesData[i];
            forAll(T, iCell) {
                hY[iCell] = spData.H(T[iCell] );
            } 
            forAll(T.boundaryField(), iPatch)
            {
                const fvPatchScalarField& T_patch = T.boundaryField()[iPatch];
                fvPatchScalarField& hY_patch = hY.boundaryField()[iPatch];
                forAll(T_patch, iFace) {
                    hY_patch[iFace] = spData.H(T_patch[iFace] );
                }
            }                       
            alphaH = fvc::interpolate(hY) * (muF - alphaF); 
                        // should this be multiplied prior to interpolation
            energySource += fvc::laplacian( alphaH, Y[i] );
        }
    }

    if (useDiffB)
    {

        Info << "Calculating energy correction B" << endl;

        surfaceScalarField muF = fvc::interpolate( turbulence->muEff() );
       
       
        surfaceScalarField kappaEff("kappaEff",
                fvc::interpolate( turbulence->alphaEff() * thermo->Cp() ) );

        /*
        surfaceScalarField kappaEff("kappaEff",
                fvc::interpolate( turbulence->alphaEff()) *
                fvc::interpolate( thermo->Cp() ) );
        */

        volScalarField hY("hY",h);
        surfaceScalarField muH("muH", muF * fvc::interpolate( h) );

        energySource = fvc::laplacian( kappaEff , T)
                    - fvc::laplacian( turbulence->alphaEff(), h);

        for (label i = 0; i < Y.size(); i++) {
            Info << "\tCalculating differential flux for species " <<  Y[i].name() << endl;
            reactingMixture::reactionThermo& spData = speciesData[i];
            forAll(T, iCell) {
                hY[iCell] = spData.H(T[iCell] );
            } 
            forAll(T.boundaryField(), iPatch)
            {
                const fvPatchScalarField& T_patch = T.boundaryField()[iPatch];
                fvPatchScalarField& hY_patch = hY.boundaryField()[iPatch];
                forAll(T_patch, iFace) {
                    hY_patch[iFace] = spData.H(T_patch[iFace] );
                }
            }
            muH = fvc::interpolate(hY) * muF;
                // should this be multiplied prior to interpolation                       
            energySource += fvc::laplacian( muH, Y[i] );
        }
    }
 
    } 
    solve
    (
        fvm::ddt(rho, h)
      + mvConvection->fvmDiv(phi, h)
      - fvm::laplacian(turbulence->alphaEff(), h)
    ==
        DpDt
      + energySource
    );

    thermo->correct();
}

It looks work well with reacatingFoam,

Whereas If I use the same equation in alternateReactingFoam I can wmake the solver, but i get "Segmentation fault" ERROR when I run the case.

I am new in OF and I'll be very grateful if somebody can help me to understand what this error mean and how I can make alternateReactingFoam works.

thank you very much!!


All times are GMT -4. The time now is 20:45.