Foam::scalarField Foam::radiationCoupledBase::emissivity() const
{
    switch (method_)
    {
        case SOLIDTHERMO:
        {
            // Get the coupling information from the directMappedPatchBase
            const directMappedPatchBase& mpp =
                refCast<const directMappedPatchBase>
                (
                    patch_.patch()
                );

            const polyMesh& nbrMesh = mpp.sampleMesh();

            // Force recalculation of mapping and schedule
            const mapDistribute& distMap = mpp.map();

            const fvPatch& nbrPatch = refCast<const fvMesh>
            (
                nbrMesh
            ).boundary()[mpp.samplePolyPatch().index()];

            if (nbrMesh.foundObject<volScalarField>("emissivity"))
            {
                tmp<scalarField> temissivity
                (
                    new scalarField
                    (
                        nbrPatch.lookupPatchField<volScalarField, scalar>
                        (
                            "emissivity"
                        )
                    )
                );

                scalarField emissivity(temissivity);
                // Use direct map mapping to exchange data
                distMap.distribute(emissivity);
                //Pout << emissivity << endl;
                return emissivity;
            }
            else
            {
                return scalarField(0);
            }

        }
        break;

        case LOOKUP:
        {
            // return local value
            return emissivity_;
        }

        default:
        {
            FatalErrorIn
            (
                "radiationCoupledBase::emissivity(const scalarField&)"
            )
                << "Unimplemented method " << method_ << endl
                << "Please set 'emissivity' to one of "
                << emissivityMethodTypeNames_.toc()
                << " and 'emissivityName' to the name of the volScalar"
                << exit(FatalError);
        }
        break;
    }
    return scalarField(0);
}
void turbulentTemperatureRadiationQinCoupledMixedFvPatchScalarField::
updateCoeffs()
{
    if (updated())
    {
        return;
    }

    // Get the coupling information from the mappedPatchBase
    const mappedPatchBase& mpp = refCast<const mappedPatchBase>
    (
        patch().patch()
    );
    const polyMesh& nbrMesh = mpp.sampleMesh();
    const fvPatch& nbrPatch = refCast<const fvMesh>
    (
        nbrMesh
    ).boundary()[mpp.samplePolyPatch().index()];

    scalarField intFld = patchInternalField();

    const turbulentTemperatureRadiationQinCoupledMixedFvPatchScalarField&
        nbrField =
        refCast
        <
            const turbulentTemperatureRadiationQinCoupledMixedFvPatchScalarField
        >
        (
            nbrPatch.lookupPatchField<volScalarField, scalar>
            (
                neighbourFieldName_
            )
        );

    // Swap to obtain full local values of neighbour internal field
    scalarField nbrIntFld = nbrField.patchInternalField();
    mpp.distribute(nbrIntFld);

    // Swap to obtain full local values of neighbour K*delta
    scalarField nbrKDelta = nbrField.kappa(nbrField)*nbrPatch.deltaCoeffs();    
    
    mpp.distribute(nbrKDelta);


    //scalarField nbrConvFlux = nbrKDelta*(*this - nbrIntFld);
    scalarField nbrConvFlux = nbrKDelta*(intFld - nbrIntFld);

    scalarField nbrTotalFlux = nbrConvFlux;

    scalarList radField(nbrPatch.size(),0.0);  
    scalarField Twall(patch().size(),0.0);

    // In solid
    if(neighbourFieldRadiativeName_ != "none") //nbr Radiation Qr
    {
        radField =
            nbrPatch.lookupPatchField<volScalarField, scalar>
            (
                neighbourFieldRadiativeName_
            );

        // Swap to obtain full local values of neighbour radiative heat flux field
        mpp.distribute(radField);

            const fvMesh& mesh = patch().boundaryMesh().mesh();
            if (! (mesh.foundObject<radiation::radiationModel>("radiationProperties")))
            {
                FatalErrorIn
                (
                    "turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField::"
                    "turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField\n"
                    "(\n"
                    "    const fvPatch& p,\n"
                    "    const DimensionedField<scalar, volMesh>& iF,\n"
                    "    const dictionary& dict\n"
                    ")\n"
                )   << "\n    radiationProperties file not found in pyrolysis region\n" 
                    << exit(FatalError);
            }
            const radiation::radiationModel& radiation =
                mesh.lookupObject<radiation::radiationModel>
                (
                    "radiationProperties"
                );

            scalarField temissivity
            (
                radiation.absorptionEmission().e()().boundaryField()
                [
                    //nbrPatch.index()
                    patch().index()
                ]
            );
            

        nbrTotalFlux -= radField*temissivity;
        nbrTotalFlux += temissivity*constant::physicoChemical::sigma.value()*pow(*this,4);

        //this->refValue() = operator[];  // not used
        this->refValue() = 0.0;  // not used
        this->refGrad() = -nbrTotalFlux/kappa(*this);                
        this->valueFraction() = 0.0;
    }
    else // In fluid
    {
        Twall = nbrIntFld;

        this->refValue() = Twall;
        this->refGrad() = 0.0;   // not used
        this->valueFraction() = 1.0;
    }

    mixedFvPatchScalarField::updateCoeffs();

    if (debug)
    {
        scalar Qc = gSum(nbrConvFlux*patch().magSf());
        scalar Qr = gSum(radField*patch().magSf());
        scalar Qt = gSum(nbrTotalFlux*patch().magSf());

        Info<< patch().boundaryMesh().mesh().name() << ':'
            << patch().name() << ':'
            << this->dimensionedInternalField().name() << " -> "
            << nbrMesh.name() << ':'
            << nbrPatch.name() << ':'
            << this->dimensionedInternalField().name() << " :"
            << " heatFlux:" << Qc
            << " radiativeFlux:" << Qr
            << " totalFlux:" << Qt
            << " walltemperature "
            << " min:" << gMin(*this)
            << " max:" << gMax(*this)
            << " avg:" << gAverage(*this)
            << endl;
    }
}