注册 登录
编程论坛 C++ Builder

一个小程序,关于本人未来

ivanyao 发布于 2008-11-21 10:04, 1225 次点击
各位c++大侠:
我想编一个公式,如下
当z≤5 I=0.31
当5<z≤450 I=0.1*(Z/450)^-0.25
k=1.5*(u*I)^2
ε=0.09^0.75*k^1.5/8
我要把k、ε写进头文件,
之前有人把u=Ub*(z/zb)^0.16的源文件如下:
#include "boundaryUFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "surfaceFields.H"

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

namespace Foam
{

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

boundaryUFvPatchVectorField::boundaryUFvPatchVectorField
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF
)
:
    fixedValueFvPatchVectorField(p, iF),
    Ub_(6.97),
    zb_(1)
{}


boundaryUFvPatchVectorField::boundaryUFvPatchVectorField
(
    const boundaryUFvPatchVectorField& ptf,
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF,
    const fvPatchFieldMapper& mapper
)
:
    fixedValueFvPatchVectorField(ptf, p, iF, mapper),
    Ub_(ptf.Ub_),
    zb_(ptf.zb_)
{}


boundaryUFvPatchVectorField::boundaryUFvPatchVectorField
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF,
    const dictionary& dict
)
:
    fixedValueFvPatchVectorField(p, iF),
    Ub_(readScalar(dict.lookup("Ub"))),
    zb_(readScalar(dict.lookup("zb")))
{
    evaluate();
}


boundaryUFvPatchVectorField::boundaryUFvPatchVectorField
(
    const boundaryUFvPatchVectorField& fcvpvf,
    const DimensionedField<vector, volMesh>& iF
)
:
    fixedValueFvPatchVectorField(fcvpvf, iF),
    Ub_(fcvpvf.Ub_),
    zb_(fcvpvf.zb_)
{}


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

void boundaryUFvPatchVectorField::updateCoeffs()
{
    scalar coeff = Ub_* Foam::pow(patch().Cf()[2] / zb_, 0.16);

    vector n(0, 0, 1);

    vectorField::operator=(n * coeff);

}


// Write
void boundaryUFvPatchVectorField::write(Ostream& os) const
{
    fvPatchVectorField::write(os);
    os.writeKeyword("Ub")
        << Ub_ << token::END_STATEMENT << nl;
    os.writeKeyword("zb")
        << zb_ << token::END_STATEMENT << nl;
    writeEntry("value", os);
}


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

makePatchTypeField(fvPatchVectorField, boundaryUFvPatchVectorField);

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

} // End namespace Foam

// ************************************************************************* //
而头文件写成:


#ifndef parabolicVelocityFvPatchVectorField_H
#define parabolicVelocityFvPatchVectorField_H

#include "fvPatchFields.H"
#include "fixedValueFvPatchFields.H"

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

namespace Foam
{

/*---------------------------------------------------------------------------*\
              Class parabolicVelocityFvPatchField Declaration
\*---------------------------------------------------------------------------*/

class boundaryUFvPatchVectorField
:
    public fixedValueFvPatchVectorField
{
    // Private data

        //- Ub
        scalar Ub_;

        //- zb
        scalar zb_;

public:

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


    // Constructors

        //- Construct from patch and internal field
        boundaryUFvPatchVectorField
        (
            const fvPatch&,
            const DimensionedField<vector, volMesh>&
        );

        //- Construct from patch, internal field and dictionary
        boundaryUFvPatchVectorField
        (
            const fvPatch&,
            const DimensionedField<vector, volMesh>&,
            const dictionary&
        );

        //- Construct by mapping given parabolicVelocityFvPatchVectorField
        //  onto a new patch
        boundaryUFvPatchVectorField
        (
            const boundaryUFvPatchVectorField&,
            const fvPatch&,
            const DimensionedField<vector, volMesh>&,
            const fvPatchFieldMapper&
        );

        //- Construct and return a clone
        virtual tmp<fvPatchVectorField> clone() const
        {
            return tmp<fvPatchVectorField>
            (
                new boundaryUFvPatchVectorField(*this)
            );
        }

        //- Construct as copy setting internal field reference
        boundaryUFvPatchVectorField
        (
            const boundaryUFvPatchVectorField&,
            const DimensionedField<vector, volMesh>&
        );

        //- Construct and return a clone setting internal field reference
        virtual tmp<fvPatchVectorField> clone
        (
            const DimensionedField<vector, volMesh>& iF
        ) const
        {
            return tmp<fvPatchVectorField>
            (
                new boundaryUFvPatchVectorField(*this, iF)
            );
        }

    // Member functions

        //- Return Ub
        scalar& Ub()
        {
            return Ub_;
        }

        //- Return zb
        scalar& zb()
        {
            return zb_;
        }

        //- Update coefficients
        virtual void updateCoeffs();

        //- Write
        virtual void write(Ostream&) const;
};


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

} // End namespace Foam

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

#endif

// ************************************************************************* //
我是一个电脑编程盲,不知道如何下手,这关系到我能不能就业的问题,请各位高手指教,加以修改,本人不胜感激。
1 回复
#2
ivanyao2008-11-24 09:58
自己顶一下,这里没有人可以帮我吗?谢谢
1