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

// ************************************************************************* //
我是一个电脑编程盲,不知道如何下手,这关系到我能不能就业的问题,请各位高手指教,加以修改,本人不胜感激。
搜索更多相关主题的帖子: include 源文件 
2008-11-24 17:06
yang_net
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2008-8-11
收藏
得分:0 
class MyMath
{
public:
    MyMath(double z,double ub,double zb)
    {
        this->z=z;
        this->ub=ub;
        this->zb=zb;
    }

    double GetI()
    {
        if(z>450) return 0;
        else return z<=5 ? 0.31 : 0.1 * pow(z/450,-0.25);
    }

    double GetU()
    {
        return ub*pow(z/zb,0.16);
    }

    double GetK()
    {
        return 1.5*pow(GetU()*GetI(),2);
    }

    double GetE()
    {
        return pow(0.09,0.75)*pow(GetK(),1.5)/8;
    }

private:
    double z,ub,zb;
};
2008-11-25 13:21
ivanyao
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-11-21
收藏
得分:0 
谢谢
谢谢你的回答,
但是我的k,E 是要与u分开写的,意思是要有三个头文件,三个源文件,不可以合在一起写,
(我计算的需要),那要如何改呢?谢谢
2008-11-27 08:41
quqiuyu2005
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2008-11-28
收藏
得分:0 
楼主以后请注意点编码规范,看着太累了??
呵呵,所以看不下去了。
2008-11-28 18:46
快速回复:请会的帮帮忙,谢谢
数据加载中...
 
   



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

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