Skip to content
  • 最新
  • 版块
  • 东岳流体
  • 随机看[请狂点我]
皮肤
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 默认(不使用皮肤)
  • 不使用皮肤
折叠
CFD中文网

CFD中文网

  1. CFD中文网
  2. OpenFOAM
  3. OpenFoam定义新边界条件问题---通量边界

OpenFoam定义新边界条件问题---通量边界

已定时 已固定 已锁定 已移动 OpenFOAM
13 帖子 3 发布者 10.6k 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
回复
  • 在新帖中回复
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • G 离线
    G 离线
    general
    写于2019年6月13日 10:27 最后由 编辑
    #1

    最近需要计算一个壁面传热传质的模型,结果发现fluent中的壁面边界条件在组分输运上只有两个选项,一个是质量分数,另一个是零梯度。
    所以计划利用openfoam编写一个组分或者热量运输通量的边界条件,参考了网上的一个相关教程(https://wenku.baidu.com/view/67aeca451fd9ad51f01dc281e53a580216fc50ea.html)
    但是在创建边界的过程中总是报错。这种边界有人建立过吗?未标题-1.jpg

    1 条回复 最后回复
  • G 离线
    G 离线
    general
    写于2019年6月13日 10:28 最后由 编辑
    #2

    未标题-1.jpg

    1 条回复 最后回复
  • G 离线
    G 离线
    general
    写于2019年6月13日 11:20 最后由 编辑
    #3

    这边参考网上陈丽萍老师的教程,但是编译总是出错,是不是版本不支持了?我的是5.0版本
    e4904532-1e1c-4acd-b240-2ad0240d3421-图片.png
    db7ea7a3-904c-4563-bbe1-1fcb980ac46d-图片.png
    b1554f22-9df0-475b-9eca-2e3c05691889-图片.png
    c027aa64-1a22-45a8-8a8a-2844beee8732-图片.png

    1 条回复 最后回复
  • G 离线
    G 离线
    general
    写于2019年6月13日 11:31 最后由 编辑
    #4

    尝试编译过程发现提示.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();
    }
    1 条回复 最后回复
  • 李 离线
    李 离线
    李东岳 管理员
    写于2019年6月13日 23:37 最后由 编辑
    #5

    @general 在 OpenFoam定义新边界条件问题---通量边界 中说:

    这边参考网上陈丽萍老师的教程,但是编译总是出错,是不是版本不支持了?我的是5.0版本

    没细看,不过单独看这一句,是版本不支持

    http://dyfluid.com/index.html
    需要帮助debug算例的看这个 https://cfd-china.com/topic/8018

    1 条回复 最后回复
  • G 离线
    G 离线
    general
    写于2019年6月16日 11:59 最后由 编辑
    #6

    最近尝试修改,整理完成后边界可以编译了,但是放到计算文件中还是报错,提示错误如下,有人知道这是什么原因吗?

    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
    );
    }
    1 条回复 最后回复
  • G 离线
    G 离线
    general
    写于2019年6月16日 15:27 最后由 编辑
    #7

    边界条件编译了, .so文件也添加到字典中了,还是提示Unknown patchField type newgrad for patch type wall,这个好让人困惑。。。

    1 条回复 最后回复
  • G 离线
    G 离线
    general
    写于2019年6月17日 04:16 最后由 编辑
    #8

    检查发现是在字典中少将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
    
    // ************************************************************************* //
    
    
    1 条回复 最后回复
  • G 离线
    G 离线
    general
    写于2019年6月18日 09:30 最后由 编辑
    #9

    有人知道下面这种错误的原因吗?

    myicoFoam: symbol lookup error: /home/a/OpenFOAM/a-5.x/platforms/linux64GccDPInt32Opt/lib/libnewFvPatchScalarField.so: undefined symbol: _ZN4Foam21newFvPatchScalarFieldC1ERKNS_7fvPatchERKNS_16DimensionedFieldIdNS_7volMeshEEERKNS_10dictionaryE
    
    
    1 条回复 最后回复
  • 李 离线
    李 离线
    李东岳 管理员
    写于2019年6月19日 00:41 最后由 编辑
    #10

    看起来像是调用了一个过时的lib,库和求解器全部重新编译一下

    http://dyfluid.com/index.html
    需要帮助debug算例的看这个 https://cfd-china.com/topic/8018

    G 1 条回复 最后回复 2019年6月20日 01:02
  • G 离线
    G 离线
    general
    在 2019年6月20日 01:02 中回复了 李东岳 最后由 编辑
    #11

    @东岳 好的谢谢东岳老师,我试一下

    1 条回复 最后回复
  • J 离线
    J 离线
    Jhhu
    写于2019年9月24日 02:32 最后由 李东岳 编辑 2019年9月25日 08:02
    #12

    @general 在 OpenFoam定义新边界条件问题---通量边界 中说:

    您好,您最后这个边界条件成功了吗?是变通量边界条件吗?谢谢!

    G 1 条回复 最后回复 2019年11月17日 12:39
  • G 离线
    G 离线
    general
    在 2019年11月17日 12:39 中回复了 Jhhu 最后由 编辑
    #13

    @Jhhu 你好,我最后没有成功,由于时间很紧张,还是使用了商用软件。

    1 条回复 最后回复
2019年6月13日 10:27

1/13

2019年6月13日 10:27

未读 12
2019年11月17日 12:39
  • 登录

  • 登录或注册以进行搜索。
1 / 13
  • 第一个帖子
    1/13
    最后一个帖子
0
  • 最新
  • 版块
  • 东岳流体
  • 随机看[请狂点我]