主题:[讨论]一个小程序,请高手帮忙
大家好,小弟第一次发帖,希望大家支持。我要把一个速度写
进我的case里。方程是:u=ub*(z/zb)^0.256。z是纵坐标,代表高度,在0到1变化。这个方程的意思速度随着高度变化的。我把它编译出来,但是在case里却没有变化。以下是我的程序,源文件,
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "parabolicVelocityFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
parabolicVelocityFvPatchVectorField::parabolicVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF
)
:
fixedValueFvPatchVectorField(p, iF),
Ub_(2.66),
zb_(1),
n_(1, 0, 0),
z_(0, 0, 1)
{}
parabolicVelocityFvPatchVectorField::parabolicVelocityFvPatchVectorField
(
const parabolicVelocityFvPatchVectorField& ptf,
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchVectorField(ptf, p, iF, mapper),
Ub_(ptf.Ub_),
zb_(ptf.zb_),
n_(ptf.n_),
z_(ptf.z_)
{}
parabolicVelocityFvPatchVectorField::parabolicVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchVectorField(p, iF),
Ub_(readScalar(dict.lookup("Ub"))),
zb_(readScalar(dict.lookup("zb"))),
n_(dict.lookup("n")),
z_(dict.lookup("z"))
{
evaluate();
}
parabolicVelocityFvPatchVectorField::parabolicVelocityFvPatchVectorField
(
const parabolicVelocityFvPatchVectorField& fcvpvf,
const DimensionedField<vector, volMesh>& iF
)
:
fixedValueFvPatchVectorField(fcvpvf, iF),
Ub_(fcvpvf.Ub_),
zb_(fcvpvf.zb_),
n_(fcvpvf.n_),
z_(fcvpvf.z_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void parabolicVelocityFvPatchVectorField::updateCoeffs()
{
scalar coeff = Ub_* pow(z_/ zb_, 0.256);
vector n(1, 0, 0);
vectorField::operator=(n * coeff);
}
// Write
void parabolicVelocityFvPatchVectorField::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);
os.writeKeyword("n")
<< n_ << token::END_STATEMENT << nl;
os.writeKeyword("z")
<< z_ << token::END_STATEMENT << nl;
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchVectorField, parabolicVelocityFvPatchVectorField);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
头文件,
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
parabolicVelocityFvPatchVectorField
Description
Boundary condition specifies a parabolic velocity inlet profile
(fixed value), given flowrate value, flow direction n and
centre coordinate of inlet patch(assume cylinder)
SourceFiles
parabolicVelocityFvPatchVectorField.C
\*---------------------------------------------------------------------------*/
#ifndef parabolicVelocityFvPatchVectorField_H
#define parabolicVelocityFvPatchVectorField_H
#include "fvPatchFields.H"
#include "fixedValueFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class parabolicVelocityFvPatchField Declaration
\*---------------------------------------------------------------------------*/
class parabolicVelocityFvPatchVectorField
:
public fixedValueFvPatchVectorField
{
// Private data
//- Ub
scalar Ub_;
//- zb
scalar zb_;
//- Flow direction
vector n_;
//- Direction of the z-coordinate
vector z_;
public:
//- Runtime type information
TypeName("parabolicVelocity");
// Constructors
//- Construct from patch and internal field
parabolicVelocityFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&
);
//- Construct from patch, internal field and dictionary
parabolicVelocityFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const dictionary&
);
//- Construct by mapping given parabolicVelocityFvPatchVectorField
// onto a new patch
parabolicVelocityFvPatchVectorField
(
const parabolicVelocityFvPatchVectorField&,
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchVectorField> clone() const
{
return tmp<fvPatchVectorField>
(
new parabolicVelocityFvPatchVectorField(*this)
);
}
//- Construct as copy setting internal field reference
parabolicVelocityFvPatchVectorField
(
const parabolicVelocityFvPatchVectorField&,
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 parabolicVelocityFvPatchVectorField(*this, iF)
);
}
// Member functions
//- Return Ub
scalar& Ub()
{
return Ub_;
}
//- Return zb
scalar& zb()
{
return zb_;
}
vector& n()
{
return n_;
}
//- Return z direction
vector& z()
{
return z_;
}
//- Update coefficients
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
进我的case里。方程是:u=ub*(z/zb)^0.256。z是纵坐标,代表高度,在0到1变化。这个方程的意思速度随着高度变化的。我把它编译出来,但是在case里却没有变化。以下是我的程序,源文件,
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "parabolicVelocityFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
parabolicVelocityFvPatchVectorField::parabolicVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF
)
:
fixedValueFvPatchVectorField(p, iF),
Ub_(2.66),
zb_(1),
n_(1, 0, 0),
z_(0, 0, 1)
{}
parabolicVelocityFvPatchVectorField::parabolicVelocityFvPatchVectorField
(
const parabolicVelocityFvPatchVectorField& ptf,
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchVectorField(ptf, p, iF, mapper),
Ub_(ptf.Ub_),
zb_(ptf.zb_),
n_(ptf.n_),
z_(ptf.z_)
{}
parabolicVelocityFvPatchVectorField::parabolicVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchVectorField(p, iF),
Ub_(readScalar(dict.lookup("Ub"))),
zb_(readScalar(dict.lookup("zb"))),
n_(dict.lookup("n")),
z_(dict.lookup("z"))
{
evaluate();
}
parabolicVelocityFvPatchVectorField::parabolicVelocityFvPatchVectorField
(
const parabolicVelocityFvPatchVectorField& fcvpvf,
const DimensionedField<vector, volMesh>& iF
)
:
fixedValueFvPatchVectorField(fcvpvf, iF),
Ub_(fcvpvf.Ub_),
zb_(fcvpvf.zb_),
n_(fcvpvf.n_),
z_(fcvpvf.z_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void parabolicVelocityFvPatchVectorField::updateCoeffs()
{
scalar coeff = Ub_* pow(z_/ zb_, 0.256);
vector n(1, 0, 0);
vectorField::operator=(n * coeff);
}
// Write
void parabolicVelocityFvPatchVectorField::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);
os.writeKeyword("n")
<< n_ << token::END_STATEMENT << nl;
os.writeKeyword("z")
<< z_ << token::END_STATEMENT << nl;
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchVectorField, parabolicVelocityFvPatchVectorField);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
头文件,
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
parabolicVelocityFvPatchVectorField
Description
Boundary condition specifies a parabolic velocity inlet profile
(fixed value), given flowrate value, flow direction n and
centre coordinate of inlet patch(assume cylinder)
SourceFiles
parabolicVelocityFvPatchVectorField.C
\*---------------------------------------------------------------------------*/
#ifndef parabolicVelocityFvPatchVectorField_H
#define parabolicVelocityFvPatchVectorField_H
#include "fvPatchFields.H"
#include "fixedValueFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class parabolicVelocityFvPatchField Declaration
\*---------------------------------------------------------------------------*/
class parabolicVelocityFvPatchVectorField
:
public fixedValueFvPatchVectorField
{
// Private data
//- Ub
scalar Ub_;
//- zb
scalar zb_;
//- Flow direction
vector n_;
//- Direction of the z-coordinate
vector z_;
public:
//- Runtime type information
TypeName("parabolicVelocity");
// Constructors
//- Construct from patch and internal field
parabolicVelocityFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&
);
//- Construct from patch, internal field and dictionary
parabolicVelocityFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const dictionary&
);
//- Construct by mapping given parabolicVelocityFvPatchVectorField
// onto a new patch
parabolicVelocityFvPatchVectorField
(
const parabolicVelocityFvPatchVectorField&,
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchVectorField> clone() const
{
return tmp<fvPatchVectorField>
(
new parabolicVelocityFvPatchVectorField(*this)
);
}
//- Construct as copy setting internal field reference
parabolicVelocityFvPatchVectorField
(
const parabolicVelocityFvPatchVectorField&,
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 parabolicVelocityFvPatchVectorField(*this, iF)
);
}
// Member functions
//- Return Ub
scalar& Ub()
{
return Ub_;
}
//- Return zb
scalar& zb()
{
return zb_;
}
vector& n()
{
return n_;
}
//- Return z direction
vector& z()
{
return z_;
}
//- Update coefficients
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //