OpenFoam定义新边界条件问题---通量边界
-
尝试编译过程发现提示.C的173行有问题
wmake libso . g++ -std=c++11 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3 -DNoRepository -ftemplate-depth-100 -I/home/a/OpenFOAM/OpenFOAM-5.x/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/a/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude -I/home/a/OpenFOAM/OpenFOAM-5.x/src/OSspecific/POSIX/lnInclude -fPIC -c flowFvPatchScalarField.C -o Make/linux64GccDPInt32Opt/flowFvPatchScalarField.o flowFvPatchScalarField.C: In member function ‘virtual void Foam::flowFvPatchScalarField::updateCoeffs()’: flowFvPatchScalarField.C:173:48: error: qualified-id in declaration before ‘(’ token void Foam::flowFvPatchScalarField::updateCoeffs() ^ /home/a/OpenFOAM/OpenFOAM-5.x/wmake/rules/General/transform:25: recipe for target 'Make/linux64GccDPInt32Opt/flowFvPatchScalarField.o' failed make: *** [Make/linux64GccDPInt32Opt/flowFvPatchScalarField.o] Error 1
对应173行的代码为:
void Foam::flowFvPatchScalarField::updateCoeffs() { const volScalarField& C = db().lookupObject<volScalarField>(C_); gradient_ =5; operator== ( this->patchInternalField() + gradient_/this->patch().deltaCoeffs ); } fixedValueFvPatchScalarField::updateCoeffs(); }
-
最近尝试修改,整理完成后边界可以编译了,但是放到计算文件中还是报错,提示错误如下,有人知道这是什么原因吗?
Unknown patchField type newgrad for patch type wall Valid patchField types are : (。。。。。(省略) ) file: /home/a/temp/cavity/0/C.boundaryField.wall2flow from line 41 to line 41. From function static Foam::tmp<Foam::fvPatchField<Type> > Foam::fvPatchField<Type>::New(const Foam::fvPatch&, const Foam::DimensionedField<Type, Foam::volMesh>&, const Foam::dictionary&) [with Type = double] in file /home/a/OpenFOAM/OpenFOAM-5.x/src/finiteVolume/lnInclude/fvPatchFieldNew.C at line 134. FOAM exiting
H文件
#ifndef newgradFvPatchScalarField_H #define newgradFvPatchScalarField_H #include "fixedValueFvPatchFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { /*---------------------------------------------------------------------------*\ Class newgradFvPatchScalarField Declaration \*---------------------------------------------------------------------------*/ class newgradFvPatchScalarField : public fixedValueFvPatchScalarField { // Private data //- Total pressure scalarField gradient_; public: //- Runtime type information TypeName("newgrad"); // Constructors //- Construct from patch and internal field newgradFvPatchScalarField ( const fvPatch&, const DimensionedField<scalar, volMesh>& ); //- Construct from patch, internal field and dictionary newgradFvPatchScalarField ( const fvPatch&, const DimensionedField<scalar, volMesh>&, const dictionary& ); //- Construct by mapping given newgradFvPatchScalarField // onto a new patch newgradFvPatchScalarField ( const newgradFvPatchScalarField&, const fvPatch&, const DimensionedField<scalar, volMesh>&, const fvPatchFieldMapper& ); //- Construct as copy newgradFvPatchScalarField ( const newgradFvPatchScalarField& ); //- Construct and return a clone virtual tmp<fvPatchScalarField> clone() const { return tmp<fvPatchScalarField> ( new newgradFvPatchScalarField(*this) ); } //- Construct as copy setting internal field reference newgradFvPatchScalarField ( const newgradFvPatchScalarField&, const DimensionedField<scalar, volMesh>& ); //- Construct and return a clone setting internal field reference virtual tmp<fvPatchScalarField> clone ( const DimensionedField<scalar, volMesh>& iF ) const { return tmp<fvPatchScalarField> ( new newgradFvPatchScalarField(*this, iF) ); } // Member functions // Access //- Return the total pressure const scalarField& gradient() const { return gradient_; } //- Return reference to the total pressure to allow adjustment scalarField& gradient() { return gradient_; } // Mapping functions //- Map (and resize as needed) from self given a mapping object virtual void autoMap ( const fvPatchFieldMapper& ); //- Reverse map the given fvPatchField onto this fvPatchField virtual void rmap ( const fvPatchScalarField&, const labelList& ); // Evaluation functions //- Update the coefficients associated with the patch field virtual void updateCoeffs(); //- Write //virtual void write(Ostream&) const; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif // ************************************************************************* //
C文件
#include "newgradFvPatchScalarField.H" #include "addToRunTimeSelectionTable.H" #include "fvPatchFieldMapper.H" #include "volFields.H" #include "surfaceFields.H" void Foam::newgradFvPatchScalarField::updateCoeffs() { if (updated()) { return; } const volScalarField& C = db().lookupObject<volScalarField>("C"); gradient_=0.5*C; operator== ( this->patchInternalField()+gradient_/this->patch().deltaCoeffs() ); fixedValueFvPatchScalarField::updateCoeffs(); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { makePatchTypeField ( fvPatchScalarField, newgradFvPatchScalarField ); }
-
检查发现是在字典中少将libs 写成了lib,修改之后还是出错,不过边界条件可以识别了。
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time Create mesh for time = 0 PISO: Operating solver in PISO mode Reading transportProperties Reading field p Reading field U Reading field C Reading/calculating face flux field phi Starting time loop Time = 5e-05 Courant Number mean: 7.5e-05 max: 0.194817 smoothSolver: Solving for Ux, Initial residual = 1, Final residual = 2.38974e-06, No Iterations 8 smoothSolver: Solving for Uy, Initial residual = 0, Final residual = 0, No Iterations 0 #0 Foam::error::printStack(Foam::Ostream&) at ??:? #1 Foam::sigFpe::sigHandler(int) at ??:? #2 ? in "/lib/x86_64-linux-gnu/libc.so.6" #3 Foam::divide(Foam::Field<double>&, Foam::UList<double> const&, Foam::UList<double> const&) at ??:? #4 Foam::operator/(Foam::UList<double> const&, Foam::UList<double> const&) at ??:? #5 Foam::newFvPatchScalarField::updateCoeffs() at ??:? #6 Foam::fvMatrix<double>::fvMatrix(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::dimensionSet const&) at ??:? #7 Foam::fv::gaussLaplacianScheme<double, Foam::SymmTensor<double> >::fvmLaplacianUncorrected(Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) at ??:? #8 Foam::fv::gaussLaplacianScheme<double, double>::fvmLaplacian(Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) at ??:? #9 ? at ??:? #10 ? at ??:? #11 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6" #12 ? at ??:? 浮点数例外 (核心已转储)
C文件
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 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 "newFvPatchScalarField.H" #include "addToRunTimeSelectionTable.H" #include "fvPatchFieldMapper.H" #include "volFields.H" #include "surfaceFields.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::newFvPatchScalarField::newFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF ) : fixedValueFvPatchScalarField(p, iF) {} Foam::newFvPatchScalarField::newFvPatchScalarField ( const newFvPatchScalarField& ptf, const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, const fvPatchFieldMapper& mapper ) : fixedValueFvPatchScalarField(ptf, p, iF, mapper) {} Foam::newFvPatchScalarField::newFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, const dictionary& dict ) : fixedValueFvPatchScalarField(p, iF, dict, false) { } Foam::newFvPatchScalarField::newFvPatchScalarField ( const newFvPatchScalarField& tppsf ) : fixedValueFvPatchScalarField(tppsf) {} Foam::newFvPatchScalarField::newFvPatchScalarField ( const newFvPatchScalarField& tppsf, const DimensionedField<scalar, volMesh>& iF ) : fixedValueFvPatchScalarField(tppsf, iF) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::newFvPatchScalarField::autoMap ( const fvPatchFieldMapper& m ) { fixedValueFvPatchScalarField::autoMap(m); } void Foam::newFvPatchScalarField::rmap ( const fvPatchScalarField& ptf, const labelList& addr ) { fixedValueFvPatchScalarField::rmap(ptf, addr); } void Foam::newFvPatchScalarField::updateCoeffs() { if (updated()) { return; } const volScalarField& C = db().lookupObject<volScalarField>("C"); gradient_=0.5*C; operator== ( this->patchInternalField()+gradient_/this->patch().deltaCoeffs() ); fixedValueFvPatchScalarField::updateCoeffs(); } //void Foam::newFvPatchScalarField::write(Ostream& os) const //{ // fvPatchScalarField::write(os); //} // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { makePatchTypeField ( fvPatchScalarField, newFvPatchScalarField ); } // ************************************************************************* //
H文件
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 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::newFvPatchScalarField Group grpInletBoundaryConditions grpOutletBoundaryConditions Description This boundary condition provides a total temperature condition. Usage \table Property | Description | Required | Default value U | Velocity field name | no | U phi | Flux field name | no | phi psi | Compressibility field name | no | thermo:psi gamma | ratio of specific heats (Cp/Cv) | yes | T0 | reference temperature | yes | \endtable Example of the boundary condition specification: \verbatim <patchName> { type new; T0 uniform 300; } \endverbatim SourceFiles newFvPatchScalarField.C See also Foam::fixedValueFvPatchField \*---------------------------------------------------------------------------*/ #ifndef newFvPatchScalarField_H #define newFvPatchScalarField_H #include "fixedValueFvPatchFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { /*---------------------------------------------------------------------------*\ Class newFvPatchScalarField Declaration \*---------------------------------------------------------------------------*/ class newFvPatchScalarField : public fixedValueFvPatchScalarField { // Private data scalarField gradient_; public: //- Runtime type information TypeName("new"); // Constructors //- Construct from patch and internal field newFvPatchScalarField ( const fvPatch&, const DimensionedField<scalar, volMesh>& ); //- Construct from patch, internal field and dictionary newFvPatchScalarField ( const fvPatch&, const DimensionedField<scalar, volMesh>&, const dictionary& ); //- Construct by mapping given newFvPatchScalarField // onto a new patch newFvPatchScalarField ( const newFvPatchScalarField&, const fvPatch&, const DimensionedField<scalar, volMesh>&, const fvPatchFieldMapper& ); //- Construct as copy newFvPatchScalarField ( const newFvPatchScalarField& ); //- Construct and return a clone virtual tmp<fvPatchScalarField> clone() const { return tmp<fvPatchScalarField> ( new newFvPatchScalarField(*this) ); } //- Construct as copy setting internal field reference newFvPatchScalarField ( const newFvPatchScalarField&, const DimensionedField<scalar, volMesh>& ); //- Construct and return a clone setting internal field reference virtual tmp<fvPatchScalarField> clone ( const DimensionedField<scalar, volMesh>& iF ) const { return tmp<fvPatchScalarField> ( new newFvPatchScalarField(*this, iF) ); } // Member functions // Access //- Return the total pressure //- Return the total pressure const scalarField& gradient() const { return gradient_; } //- Return reference to the total pressure to allow adjustment scalarField& gradient() { return gradient_; } // Mapping functions //- Map (and resize as needed) from self given a mapping object virtual void autoMap ( const fvPatchFieldMapper& ); //- Reverse map the given fvPatchField onto this fvPatchField virtual void rmap ( const fvPatchScalarField&, const labelList& ); // Evaluation functions //- Update the coefficients associated with the patch field virtual void updateCoeffs(); //- Write //virtual void write(Ostream&) const; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif // ************************************************************************* //