大佬们,题目就是问题。这方法应该不是codeStream。
问题:
在照着例子设置好之后添加的include “DataEntry.H” 编译的时候直接报出没有那个文件或目录导致不能编译;不添加include “DataEntry.H” 报出DataEntry was not declared in this scope。 还有一个就是 “new” has not been declared 。
按道理这里书上的例子来做不会出现这种错误,我没有想明白如何解决,请教大佬。
第一个是parabolicInletVelocityFvPatchVectorField.C
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "parabolicInletVelocityFvPatchVectorField.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "surfaceFields.H"
#include "mathematicalConstants.H"
//#include "DataEntry.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::parabolicInletVelocityFvPatchVectorField::
parabolicInletVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF
)
:
//fixedValueFvPatchField<vector>(p, iF),
//origin_(Zero),
//axis_(Zero),
//axialVelocity_(),
//radialVelocity_(),
//rpm_()
fixedValueFvPatchField<vector>(p, iF),
b_(),
a1_(),
a2_(),
a3_()
{}
Foam::parabolicInletVelocityFvPatchVectorField::
parabolicInletVelocityFvPatchVectorField
(
const parabolicInletVelocityFvPatchVectorField& ptf,
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
//fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
//origin_(ptf.origin_),
//axis_(ptf.axis_),
//axialVelocity_(ptf.axialVelocity_, false),
//radialVelocity_(ptf.radialVelocity_, false),
//rpm_(ptf.rpm_, false)
fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
b_(ptf.b_().clone().ptr()),
a1_(ptf.a1_().clone().ptr()),
a2_(ptf.a2_().clone().ptr()),
a3_(ptf.a3_().clone().ptr())
{}
Foam::parabolicInletVelocityFvPatchVectorField::
parabolicInletVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const dictionary& dict
)
:
//fixedValueFvPatchField<vector>(p, iF, dict),
//origin_(dict.lookup("origin")),
//axis_(dict.lookup("axis")),
//axialVelocity_(Function1<scalar>::New("axialVelocity", dict)),
//radialVelocity_(Function1<scalar>::New("radialVelocity", dict)),
//rpm_(Function1<scalar>::New("rpm", dict))
fixedValueFvPatchField<vector>(p, iF, dict),
b_(DataEntry<scalar>::New("b",dict)),
a1_(DataEntry<scalar>::New("a1",dict)),
a2_(DataEntry<scalar>::New("a2",dict)),
a3_(DataEntry<scalar>::New("a3",dict))
{}
Foam::parabolicInletVelocityFvPatchVectorField::
parabolicInletVelocityFvPatchVectorField
(
const parabolicInletVelocityFvPatchVectorField& ptf
)
:
//fixedValueFvPatchField<vector>(ptf),
//origin_(ptf.origin_),
//axis_(ptf.axis_),
//axialVelocity_(ptf.axialVelocity_, false),
//radialVelocity_(ptf.radialVelocity_, false),
//rpm_(ptf.rpm_, false)
fixedValueFvPatchField<vector>(ptf),
b_(ptf.b_().clone().ptr()),
a1_(ptf.a1_().clone().ptr()),
a2_(ptf.a2_().clone().ptr()),
a3_(ptf.a3_().clone().ptr())
{}
Foam::parabolicInletVelocityFvPatchVectorField::
parabolicInletVelocityFvPatchVectorField
(
const parabolicInletVelocityFvPatchVectorField& ptf,
const DimensionedField<vector, volMesh>& iF
)
:
//fixedValueFvPatchField<vector>(ptf, iF),
//origin_(ptf.origin_),
//axis_(ptf.axis_),
//axialVelocity_(ptf.axialVelocity_, false),
//radialVelocity_(ptf.radialVelocity_, false),
//rpm_(ptf.rpm_, false)
fixedValueFvPatchField<vector>(ptf, iF),
b_(ptf.b_().clone().ptr()),
a1_(ptf.a1_().clone().ptr()),
a2_(ptf.a2_().clone().ptr()),
a3_(ptf.a3_().clone().ptr())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::parabolicInletVelocityFvPatchVectorField::updateCoeffs()
{
if (updated())
{
return;
}
//const scalar t = this->db().time().timeOutputValue();
//const scalar axialVelocity = axialVelocity_->value(t);
//const scalar radialVelocity = radialVelocity_->value(t);
//const scalar rpm = rpm_->value(t);
//const vector axisHat = axis_/mag(axis_);
//const vectorField r(patch().Cf() - origin_);
//const vectorField d(r - (axisHat & r)*axisHat);
//tmp<vectorField> tangVel
//(
//(rpm*constant::mathematical::pi/30.0)*(axisHat) ^ d
//);
const scalar t = this->db().time().timeOutputValue();
const scalar b = b_->value(t);
const scalar a1 = a1_->value(t);
const scalar a2 = a2_->value(t);
const scalar a3 = a3_->value(t);
scalarField ux=a1*sqr(patch().Cf().component(vector::Y)()-b)+a2*(patch().Cf().component(vector::Y)()-b)+a3;
//operator==(tangVel + axisHat*axialVelocity + radialVelocity*d/mag(d));
operator==(vector(1,0,0)*ux);
fixedValueFvPatchField<vector>::updateCoeffs();
}
void Foam::parabolicInletVelocityFvPatchVectorField::write(Ostream& os) const
{
fvPatchField<vector>::write(os);
//writeEntry(os, "origin", origin_);
//writeEntry(os, "axis", axis_);
//writeEntry(os, axialVelocity_());
//writeEntry(os, radialVelocity_());
//writeEntry(os, rpm_());
//writeEntry(os, "value", *this);
b_->writeData(os);
a1_->writeData(os);
a2_->writeData(os);
a3_->writeData(os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchVectorField,
parabolicInletVelocityFvPatchVectorField
);
}
// ************************************************************************* //
第二个是parabolicInletVelocityFvPatchVectorField.H
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
Foam::parabolicInletVelocityFvPatchVectorField
Description
This boundary condition describes an inlet vector boundary condition in
cylindrical co-ordinates given a central axis, central point, rpm, axial
and radial velocity.
//parabolicInletVelocity
Usage
\table
Property | Description | Required | Default value
axis | axis of rotation | yes |
origin | origin of rotation | yes |
axialVelocity | axial velocity profile [m/s] | yes |
radialVelocity | radial velocity profile [m/s] | yes |
rpm | rotational speed (revolutions per minute) | yes|
\endtable
Example of the boundary condition specification:
\verbatim
<patchName>
{
type parabolicInletVelocity;
axis (0 0 1);
origin (0 0 0);
axialVelocity constant 30;
radialVelocity constant -10;
rpm constant 100;
}
\endverbatim
Note
The \c axialVelocity, \c radialVelocity and \c rpm entries are Function1
types, able to describe time varying functions. The example above gives
the usage for supplying constant values.
See also
Foam::fixedValueFvPatchField
Foam::Function1s
SourceFiles
parabolicInletVelocityFvPatchVectorField.C
\*---------------------------------------------------------------------------*/
#ifndef parabolicInletVelocityFvPatchVectorField_H
#define parabolicInletVelocityFvPatchVectorField_H
#include "fixedValueFvPatchFields.H"
#include "Function1.H"
//#include "DataEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class parabolicInletVelocityFvPatchVectorField Declaration
\*---------------------------------------------------------------------------*/
class parabolicInletVelocityFvPatchVectorField
:
public fixedValueFvPatchVectorField
{
// Private Data
//- Origin of the rotation
//const vector origin_;
//- Axis of the rotation
// const vector axis_;
//- Axial velocity
//autoPtr<Function1<scalar>> axialVelocity_;
//- Radial velocity
//autoPtr<Function1<scalar>> radialVelocity_;
//- RPM
//autoPtr<Function1<scalar>> rpm_;
//- parabolic coefficients, (u_x)^2=a_1(x-b)^2+a_2(x-b)+a_3
autoPtr<Function1<scalar> > b_;
autoPtr<Function1<scalar> > a1_;
autoPtr<Function1<scalar> > a2_;
autoPtr<Function1<scalar> > a3_;
public:
//- Runtime type information
TypeName("parabolicInletVelocity");
// Constructors
//- Construct from patch and internal field
parabolicInletVelocityFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&
);
//- Construct from patch, internal field and dictionary
parabolicInletVelocityFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// flowRateInletVelocityFvPatchVectorField
// onto a new patch
parabolicInletVelocityFvPatchVectorField
(
const parabolicInletVelocityFvPatchVectorField&,
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const fvPatchFieldMapper&
);
//- Copy constructor
parabolicInletVelocityFvPatchVectorField
(
const parabolicInletVelocityFvPatchVectorField&
);
//- Construct and return a clone
virtual tmp<fvPatchVectorField> clone() const
{
return tmp<fvPatchVectorField>
(
new parabolicInletVelocityFvPatchVectorField(*this)
);
}
//- Copy constructor setting internal field reference
parabolicInletVelocityFvPatchVectorField
(
const parabolicInletVelocityFvPatchVectorField&,
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 parabolicInletVelocityFvPatchVectorField(*this, iF)
);
}
// Member Functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
第三个是Make文件夹下的files
parabolicInletVelocityFvPatchVectorField.C //边界条件源文件及名称 若未指定 默认位于Make文件夹同级目录中
LIB = $(FOAM_LIBBIN)/libparabolicInletVelocity //指定编译后所在的库 用户自定义类型 libparabolicInletVelocity 为库名称
第四个是Make文件夹下的options
EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
LIB_LIBS = \
-lOpenFOAM \
-ltriSurface \
-lmeshTools
不加include "DataEntry.H后的错误点:
添加include "DataEntry.H"后的错误点
2021-10-25T16:00:00Z