fireFoam createFields.H文件中创建场编译,输出多组分混合物各成分的质量流率,没有效果......



  • 在fireFoam求解器源程序的createfields.H文件中,根据phi(总质量通量)和Yi(多组分的质量分数),希望创建各组分的通量场,值为phi*Yi,进行如下添加后(标记黄色),编译正常通过,但求解结果文件中并没有发现创建好的通量场,希望各位大神能给与指导,不胜感激。

    autoPtr<combustionModels::psiCombustionModel> combustion
    (
        combustionModels::psiCombustionModel::New
        (
            mesh
        )
    );
    
    Info<< "Reading thermophysical properties\n" << endl;
    
    psiReactionThermo& thermo = combustion->thermo();
    thermo.validate(args.executable(), "h", "e");
    
    SLGThermo slgThermo(mesh, thermo);
    
    basicMultiComponentMixture& composition = thermo.composition();
    PtrList<volScalarField>& Y = composition.Y();
    
    
    const word inertSpecie(thermo.lookup("inertSpecie"));
    
    Info<< "Creating field rho\n" << endl;
    volScalarField rho
    (
        IOobject
        (
            "rho",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        thermo.rho()
    );
    
    volScalarField& p = thermo.p();
    const volScalarField& T = thermo.T();
    const volScalarField& psi = thermo.psi();
    
    Info<< "\nReading field U\n" << endl;
    volVectorField U
    (
        IOobject
        (
            "U",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );
    
    #include "compressibleCreatePhi.H"
    
    Info<< "Creating turbulence model\n" << endl;
    autoPtr<compressible::turbulenceModel> turbulence
    (
        compressible::turbulenceModel::New
        (
            rho,
            U,
            phi,
            thermo
        )
    );
    
    // Set the turbulence into the combustion model
    combustion->setTurbulence(turbulence());
    
    volScalarField dQ
    (
        IOobject
        (
            "dQ",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        mesh,
        dimensionedScalar("dQ", dimEnergy/dimTime, 0.0)
    );
    
    
    Info<< "Creating field dpdt\n" << endl;
    volScalarField dpdt
    (
        IOobject
        (
            "dpdt",
            runTime.timeName(),
            mesh
        ),
        mesh,
        dimensionedScalar("dpdt", p.dimensions()/dimTime, 0)
    );
    
    Info<< "Creating field kinetic energy K\n" << endl;
    volScalarField K("K", 0.5*magSqr(U));
    
    
    #include "readGravitationalAcceleration.H"
    #include "readhRef.H"
    #include "gh.H"
    
    
    volScalarField p_rgh
    (
        IOobject
        (
            "p_rgh",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );
    
    // Force p_rgh to be consistent with p
    p_rgh = p - rho*gh;
    
    mesh.setFluxRequired(p_rgh.name());
    
    multivariateSurfaceInterpolationScheme<scalar>::fieldTable fields;
    
    forAll(Y, i)
    {
        fields.add(Y[i]);
    }
    fields.add(thermo.he());
    
    %(#fffc99)[PtrList<surfaceScalarField> Ysf;
    forAll(Ysf, i)
    {
        surfaceScalarField Ycf
        (
        IOobject
        (
            IOobject::groupName("Ycf",Y[i].name()),
            runTime.timeName(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::AUTO_WRITE
        ),
        fvc::interpolate(Y[i])*phi
       );
       Info<< "Ycf is\n" << Ycf << endl;
    }]
    
    IOdictionary additionalControlsDict
    (
        IOobject
        (
            "additionalControls",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::NO_WRITE
        )
    );
    
    Switch solvePrimaryRegion
    (
        additionalControlsDict.lookup("solvePrimaryRegion")
    );
    
    


  • @alvin 抱歉,新添加的代码未能正常黄色标记显示,加入的代码为

    PtrList<surfaceScalarField> Ysf;
    forAll(Ysf, i)
    {
    surfaceScalarField Ycf
    (
    IOobject
    (
    IOobject::groupName(“Ycf”,Y[i].name()),
    runTime.timeName(),
    mesh,
    IOobject::READ_IF_PRESENT,
    IOobject::AUTO_WRITE
    ),
    fvc::interpolate(Y[i])*phi
    );
    Info<< “Ycf is\n” << Ycf << endl;
    }
    

  • 网格教授 OpenFOAM教授 管理员

    但求解结果文件中并没有发现创建好的通量场

    你强制写一下看看?field.write();