| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1219 人关注过本帖
标题:一个小程序,关于本人未来
只看楼主 加入收藏
ivanyao
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-11-21
收藏
 问题点数:0 回复次数:1 
一个小程序,关于本人未来
各位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

// ************************************************************************* //
我是一个电脑编程盲,不知道如何下手,这关系到我能不能就业的问题,请各位高手指教,加以修改,本人不胜感激。
搜索更多相关主题的帖子: 源文件 
2008-11-21 10:04
ivanyao
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-11-21
收藏
得分:0 
自己顶一下,这里没有人可以帮我吗?谢谢
2008-11-24 09:58
快速回复:一个小程序,关于本人未来
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015147 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved