// Update the coefficients associated with the patch field
void nusseltFvPatchScalarField::updateCoeffs()
{
    if (updated())
    {
        return;
    }

    scalarField Tinternal = patchInternalField();

    // Lookup temperature diffusivity of the patch
    const fvPatchField<scalar>& DT =
        this->patch().lookupPatchField<volScalarField, scalar>(DTName_);

    // Calculate flux
    scalarField tempFlux = alpha_*(Tinternal - Tinf_);

    refValue() =
        neg(tempFlux)*
        min
        (
            Tinternal - tempFlux/(DT*patch().deltaCoeffs()),
            Tinf_
        )
      + pos(tempFlux)*
        max
        (
            Tinternal - tempFlux/(DT*patch().deltaCoeffs()),
            Tinf_
        );

    refGrad() = -tempFlux;
    valueFraction() = pos(tempFlux);

    mixedFvPatchScalarField::updateCoeffs();
}
inviscidWallPFvPatchScalarField::inviscidWallPFvPatchScalarField
(
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF,
    const dictionary& dict
)
:
    fixedGradientFvPatchScalarField(p, iF),
    fluxFraction_(readScalar(dict.lookup("fluxFraction")))
{
    if (dict.found("gradient"))
    {
        gradient() = scalarField("gradient", dict, p.size());
        fixedGradientFvPatchScalarField::updateCoeffs();
        fixedGradientFvPatchScalarField::evaluate();
    }
    else
    {
        fvPatchField<scalar>::operator=(patchInternalField());
        gradient() = 0.0;
    }

    if (fluxFraction_<0.0 || fluxFraction_ > 1.0)
    {
        FatalIOErrorIn
        (
            "inviscidWallPFvPatchScalarField::"
            "supersonicFreeStreamFvPatchVectorField"
            "(const fvPatch&, const scalarField&, const dictionary&)",
            dict
        )   << "    unphysical fluxFraction specified (< 0.0 or > 1.0)"
            << exit(FatalIOError);
    }

}
Foam::tmp<Foam::labelField> Foam::overlapGgiFvPatch::interfaceInternalField
(
    const unallocLabelList& internalData
) const
{
    return patchInternalField(internalData);
}
tmp<labelField> cyclicFvPatch::interfaceInternalField
(
    const unallocLabelList& internalData
) const
{
    return patchInternalField(internalData);
}
Foam::tmp<Foam::labelField> Foam::regionCoupleFvPatch::interfaceInternalField
(
    const unallocLabelList& internalData
) const
{
    return patchInternalField(internalData);
}
void
ProcessorPointPatchField
<PatchField, Mesh, PointPatch, ProcessorPointPatch, MatrixType, Type>::
evaluate
(
    const Pstream::commsTypes commsType
)
{
    if (this->isPointField())
    {
        // Get the neighbour side values
        tmp<Field<Type> > tpNeighbour = receivePointField<Type>(commsType);
        Field<Type>& tpn = tpNeighbour();

        if (doTransform())
        {
            const processorPolyPatch& ppp = procPatch_.procPolyPatch();
            const tensorField& forwardT = ppp.forwardT();

            transform(tpn, forwardT[0], tpn);
        }

        // Average over two sides
        tpn = 0.5*(patchInternalField(this->internalField()) + tpn);

        // Get internal field to insert values into
        Field<Type>& iF = const_cast<Field<Type>&>(this->internalField());

        this->setInInternalField(iF, tpn);
    }
}
Пример #7
0
tmp<Field<Type1> > pointPatchField<Type>::patchInternalField
(
    const Field<Type1>& iF
) const
{
    return patchInternalField(iF, patch().meshPoints());
}
Foam::tmp<Foam::labelField> Foam::mixingPlaneFvPatch::interfaceInternalField
(
    const unallocLabelList& internalData
) const
{
    return patchInternalField(internalData);
}
fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
(
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF,
    const dictionary& dict
)
:
    fixedGradientFvPatchScalarField(p, iF),
    UName_(dict.lookup("U")),
    phiName_(dict.lookup("phi")),
    rhoName_(dict.lookup("rho")),
    adjoint_(dict.lookup("adjoint"))
{
    if (dict.found("gradient"))
    {
        gradient() = scalarField("gradient", dict, p.size());
        fixedGradientFvPatchScalarField::updateCoeffs();
        fixedGradientFvPatchScalarField::evaluate();
    }
    else
    {
        fvPatchField<scalar>::operator=(patchInternalField());
        gradient() = 0.0;
    }
}
Пример #10
0
Foam::tmp<Foam::labelField> Foam::cyclicACMIFvPatch::interfaceInternalField
(
    const labelUList& internalData
) const
{
    return patchInternalField(internalData);
}
Foam::tmp<Foam::labelgpuField> Foam::regionCoupledFvPatch::interfaceInternalField
(
    const labelgpuList& internalData
) const
{
    return patchInternalField(internalData);
}
void Foam::mixingPlaneFvPatch::initInternalFieldTransfer
(
    const Pstream::commsTypes commsType,
    const unallocLabelList& iF
) const
{
    labelTransferBuffer_ = patchInternalField(iF);
}
smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
(
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF,
    const dictionary& dict
)
:
    mixedFvPatchScalarField(p, iF),
    accommodationCoeff_(readScalar(dict.lookup("accommodationCoeff"))),
    Twall_("Twall", dict, p.size())
{
    if
    (
        mag(accommodationCoeff_) < SMALL
        ||
        mag(accommodationCoeff_) > 2.0
    )
    {
        FatalIOErrorIn
        (
            "smoluchowskiJumpTFvPatchScalarField::"
            "smoluchowskiJumpTFvPatchScalarField"
            "("
            "    const fvPatch&,"
            "    const DimensionedField<scalar, volMesh>&,"
            "    const dictionary&"
            ")",
            dict
        )   << "unphysical accommodationCoeff_ specified"
            << "(0 < accommodationCoeff_ <= 1)" << endl
            << exit(FatalError);
    }

    if (dict.found("value"))
    {
        fvPatchField<scalar>::operator=
        (
            scalarField("value", dict, p.size())
        );
    }
    else
    {
        fvPatchField<scalar>::operator=(patchInternalField());
    }

    if (dict.found("gamma"))
    {
        gamma_ = readScalar(dict.lookup("gamma"));
    }
    else
    {
        gamma_ = 1.4;
    }

    refValue() = *this;
    refGrad() = 0.0;
    valueFraction() = 0.0;
}
nusseltFvPatchScalarField::nusseltFvPatchScalarField
(
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF,
    const dictionary& dict
)
:
    mixedFvPatchScalarField(p, iF),
    DTName_(dict.lookup("DT")),
    Tinf_(readScalar(dict.lookup("Tinf"))),
    alpha_("alpha", dict, p.size())
{
    if (dict.found("value"))
    {
        fvPatchField<scalar>::operator=
        (
            scalarField("value", dict, p.size())
        );
    }
    else
    {
        fvPatchField<scalar>::operator=(patchInternalField());
    }

    refValue() = *this;
    refGrad() = 0.0;
    valueFraction() = 0.0;

    if (Tinf_ < SMALL)
    {
        FatalIOErrorIn
        (
            "nusseltFvPatchScalarField::nusseltFvPatchScalarField\n"
            "(\n"
            "    const fvPatch&,\n"
            "    const DimensionedField<scalar, volMesh>&,\n"
            "    const dictionary&\n"
            ")",
            dict
        )   << "unphysical Tinf specified (Tinf = 0 or negative)"
            << exit(FatalError);
    }

    if (min(alpha_) < -SMALL)
    {
        FatalIOErrorIn
        (
            "nusseltFvPatchScalarField::nusseltFvPatchScalarField\n"
            "(\n"
            "    const fvPatch&,\n"
            "    const DimensionedField<scalar, volMesh>&,\n"
            "    const dictionary&\n"
            ")",
            dict
        )   << "unphysical alpha specified (alpha = 0 or negative)" << endl
            << exit(FatalError);
    }
}
void wedgeFvPatchField<scalar>::evaluate(const Pstream::commsTypes)
{
    if (!updated())
    {
        updateCoeffs();
    }

    operator==(patchInternalField());
}
void ProcessorPointPatchField
<PatchField, Mesh, PointPatch, ProcessorPointPatch, MatrixType, Type>::
initAddFieldTempl
(
    const Pstream::commsTypes commsType,
    const Field<Type2>& pField
) const
{
    sendField(patchInternalField(pField), commsType);
}
Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
(
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF,
    const dictionary& dict
)
:
    mixedFvPatchScalarField(p, iF),
    UName_(dict.lookupOrDefault<word>("U", "U")),
    rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
    psiName_(dict.lookupOrDefault<word>("psi", "thermo:psi")),
    muName_(dict.lookupOrDefault<word>("mu", "thermo:mu")),
    accommodationCoeff_(readScalar(dict.lookup("accommodationCoeff"))),
    Twall_("Twall", dict, p.size()),
    gamma_(dict.lookupOrDefault<scalar>("gamma", 1.4))
{
    if
    (
        mag(accommodationCoeff_) < SMALL
     || mag(accommodationCoeff_) > 2.0
    )
    {
        FatalIOErrorIn
        (
            "smoluchowskiJumpTFvPatchScalarField::"
            "smoluchowskiJumpTFvPatchScalarField"
            "("
            "    const fvPatch&,"
            "    const DimensionedField<scalar, volMesh>&,"
            "    const dictionary&"
            ")",
            dict
        )   << "unphysical accommodationCoeff specified"
            << "(0 < accommodationCoeff <= 1)" << endl
            << exit(FatalIOError);
    }

    if (dict.found("value"))
    {
        fvPatchField<scalar>::operator=
        (
            scalarField("value", dict, p.size())
        );
    }
    else
    {
        fvPatchField<scalar>::operator=(patchInternalField());
    }

    refValue() = *this;
    refGrad() = 0.0;
    valueFraction() = 0.0;
}
void Foam::basicSymmetryFvPatchField<Foam::scalar>::evaluate
(
    const Pstream::commsTypes
)
{
    if (!updated())
    {
        updateCoeffs();
    }

    scalargpuField::operator=(patchInternalField());
    transformFvPatchField<scalar>::evaluate();
}
geostrophicZeroFluxFvPatchScalarField::
geostrophicZeroFluxFvPatchScalarField
(
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF,
    const dictionary&
)
:
    fixedGradientFvPatchScalarField(p, iF)
{
    fvPatchField<scalar>::operator=(patchInternalField());
    gradient() = 0.0;
}
extrapolatedGradientFvPatchScalarField::
extrapolatedGradientFvPatchScalarField
(
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF,
    const dictionary& dict
)
:
    fixedGradientFvPatchScalarField(p, iF)
{
    fvPatchField<scalar>::operator=(patchInternalField());
    gradient() = 0.0;
}
buoyantPressureFvPatchScalarField::
buoyantPressureFvPatchScalarField
(
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF,
    const dictionary& dict
)
:
    fixedGradientFvPatchScalarField(p, iF),
    rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
{
    fvPatchField<scalar>::operator=(patchInternalField());
    gradient() = 0.0;
}
Foam::fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF,
    const dictionary& dict
)
:
    fixedValueFvPatchVectorField(p, iF),
    phiName_(dict.lookupOrDefault<word>("phi", "phi")),
    rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
    tau0_(dict.lookupOrDefault<vector>("tau", vector::zero))
{
    fvPatchField<vector>::operator=(patchInternalField());
}
fixedTractionFvPatchVectorField::
fixedTractionFvPatchVectorField
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF
)
:
    fixedGradientFvPatchVectorField(p, iF),
    traction_(p.size(), vector::zero),
    pressure_(p.size(), 0.0)
{
    fvPatchVectorField::operator=(patchInternalField());
    gradient() = vector::zero;
}
Foam::fluxCorrectedVelocityFvPatchVectorField::
fluxCorrectedVelocityFvPatchVectorField
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF,
    const dictionary& dict
)
:
    zeroGradientFvPatchVectorField(p, iF),
    phiName_(dict.lookupOrDefault<word>("phi", "phi")),
    rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
{
    fvPatchVectorField::operator=(patchInternalField());
}
solidTractionFreeFvPatchVectorField::
solidTractionFreeFvPatchVectorField
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF
)
:
    fixedGradientFvPatchVectorField(p, iF),
    fieldName_("undefined"),
    nonLinear_(nonLinearGeometry::OFF),
    orthotropic_(false)
{
    fvPatchVectorField::operator=(patchInternalField());
    gradient() = vector::zero;
}
fixedTractionFvPatchVectorField::
fixedTractionFvPatchVectorField
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF,
    const dictionary& dict
)
:
    fixedGradientFvPatchVectorField(p, iF),
    traction_("traction", dict, p.size()),
    pressure_("pressure", dict, p.size())
{
    fvPatchVectorField::operator=(patchInternalField());
    gradient() = vector::zero;
}
Пример #27
0
turbulentHeatFluxTemperatureFvPatchScalarField::
turbulentHeatFluxTemperatureFvPatchScalarField
(
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF,
    const dictionary& dict
)
:
    fixedGradientFvPatchScalarField(p, iF),
    heatSource_(heatSourceTypeNames_.read(dict.lookup("heatSource"))),
    q_("q", dict, p.size())
{
    fvPatchField<scalar>::operator=(patchInternalField());
    gradient() = 0.0;
}
void Foam::pressureInletOutletParSlipVelocityFvPatchVectorField::updateCoeffs()
{
    if (updated())
    {
        return;
    }

    const surfaceScalarField& phi =
        db().lookupObject<surfaceScalarField>(phiName_);

    const fvsPatchField<scalar>& phip =
        patch().patchField<surfaceScalarField, scalar>(phi);

    tmp<vectorgpuField> n = patch().nf();
    const gpuField<scalar>& magSf = patch().magSf();

    // Get the tangential component from the internalField (zero-gradient)
    vectorgpuField Ut(patchInternalField());
    Ut -= n()*(Ut & n());

    if (phi.dimensions() == dimVelocity*dimArea)
    {
        refValue() = Ut + n*phip/magSf;
    }
    else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
    {
        const fvPatchField<scalar>& rhop =
            patch().lookupPatchField<volScalarField, scalar>(rhoName_);

        refValue() = Ut + n*phip/(rhop*magSf);
    }
    else
    {
        FatalErrorIn
        (
            "pressureInletOutletParSlipVelocityFvPatchVectorField::"
            "updateCoeffs()"
        )   << "dimensions of phi are not correct" << nl
            << "    on patch " << this->patch().name()
            << " of field " << this->dimensionedInternalField().name()
            << " in file " << this->dimensionedInternalField().objectPath()
            << exit(FatalError);
    }

    valueFraction() = 1.0 - pos(phip);

    mixedFvPatchVectorField::updateCoeffs();
}
tractionDisplacementFvPatchVectorField::
tractionDisplacementFvPatchVectorField
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF
)
:
    fixedGradientFvPatchVectorField(p, iF),
    UName_("undefined"),
    rheologyName_("undefined"),
    traction_(p.size(), vector::zero),
    pressure_(p.size(), 0.0)
{
    fvPatchVectorField::operator=(patchInternalField());
    gradient() = vector::zero;
}
Foam::supersonicFreestreamFvPatchVectorField::
supersonicFreestreamFvPatchVectorField
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF
)
:
    mixedFvPatchVectorField(p, iF),
    UInf_(vector::zero),
    pInf_(0),
    TInf_(0),
    gamma_(0)
{
    refValue() = patchInternalField();
    refGrad() = vector::zero;
    valueFraction() = 1;
}