首页 > 解决方案 > OpenFOAM 简单 blockMesh 浮点异常

问题描述

我正在逐步学习 OpenFOAM,目前正在尝试使用该blockMesh工具创建一个非常简单的网格,但不断收到浮点异常。My与 OF 用户手册第 4.3.1 节中blockMeshDict的网格划分教程几乎完全一致:

FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

scale 1.0;

vertices
(
    (0 0 0) //0
    (0 0 1) //1
    (0 1 1) //2
    (0 1 0) //3
    (1 0 0) //4
    (1 0 1) //5
    (1 1 1) //6
    (1 1 0) //7
);

edges
(
);

blocks
(
    hex (0 1 2 3 7 6 5 4)
    (2 1 1)               // 2 blocks in the x direction
    simpleGrading (1 1 1) // default expansion ratios
);

boundary
(
    inlet
    {
        type patch;
        faces
        (
            (0 1 2 3) 
        );
    }

    outlet
    {
        type patch;
        faces
        (
            (4 5 6 7)
        );
    }

    walls
    {
        type wall;
        faces
        (
            (0 4 7 3)
            (0 4 5 1)
            (1 5 6 2)
            (2 6 7 3)
        );
    }
);

这只是一个单位长度的“空气管”立方体,沿 x 轴有两个部分,相对两侧的入口和出口以及其他任何地方的墙壁:

在此处输入图像描述

此配置立即中断并出现以下错误:

$ blockMesh
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  9
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
Build  : 9-c8374a4890ad
Exec   : blockMesh
Date   : Nov 02 2021
Time   : 11:50:35
Host   : "artixlinux"
PID    : 10555
I/O    : uncollated
Case   : /home/andrii/foamtest
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Reading "blockMeshDict"

Creating block mesh from
    "system/blockMeshDict"
Creating block edges
No non-planar block faces defined
Creating topology blocks
#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigFpe::sigHandler(int) at ??:?
#2  ? in "/usr/lib/libc.so.6"
#3  Foam::face::centre(Foam::Field<Foam::Vector<double> > const&) const at ??:?
#4  Foam::blockDescriptor::check(Foam::Istream const&) at ??:?
#5  Foam::blockDescriptor::blockDescriptor(Foam::dictionary const&, int, Foam::Field<Foam::Vector<double> > const&, Foam::PtrList<Foam::blockEdge> const&, Foam::PtrList<Foam::blockFace> const&, Foam::Istream&) at ??:?
#6  Foam::block::block(Foam::dictionary const&, int, Foam::Field<Foam::Vector<double> > const&, Foam::PtrList<Foam::blockEdge> const&, Foam::PtrList<Foam::blockFace> const&, Foam::Istream&) at ??:?
#7  Foam::block::New(Foam::dictionary const&, int, Foam::Field<Foam::Vector<double> > const&, Foam::PtrList<Foam::blockEdge> const&, Foam::PtrList<Foam::blockFace> const&, Foam::Istream&) at ??:?
#8  void Foam::PtrList<Foam::block>::read<Foam::block::iNew>(Foam::Istream&, Foam::block::iNew const&) at ??:?
#9  Foam::blockMesh::createTopology(Foam::IOdictionary const&, Foam::word const&) at ??:?
#10  Foam::blockMesh::blockMesh(Foam::IOdictionary const&, Foam::word const&) at ??:?
#11  ? in "/opt/OpenFOAM/OpenFOAM-9/platforms/linux64GccDPInt32Opt/bin/blockMesh"
#12  __libc_start_main in "/usr/lib/libc.so.6"
#13  ? in "/opt/OpenFOAM/OpenFOAM-9/platforms/linux64GccDPInt32Opt/bin/blockMesh"
zsh: floating point exception  blockMesh

我有理由确定这不仅仅是一个损坏的 OpenFOAM 安装(我专门使用 Arch AUR 的 org 版本),因为从本教程中给出的存档中复制了一个不同的网格字典来代替我的完美工作。

我对此失去了理智,我多次检查了顶点和面部描述,没有发现任何问题,但错误仍然存​​在。我错过了什么错误吗?

标签: c++openfoam

解决方案


你的 blockMeshDict 文件的问题是你没有遵循这些规则:

局部坐标系由顶点在块定义中呈现的顺序定义,根据:

  • 轴原点是块定义中的第一个条目,顶点 0

  • x方向通过从顶点 0 移动到顶点 1 来描述;

  • 通过从顶点 1 移动到顶点 2 来描述y方向;

  • 顶点 0、1、2、3 定义平面 z = 0。

  • 通过从顶点 0沿z方向移动找到顶点 4。

  • 通过分别从顶点 1,2 和 3 沿z方向移动,类似地找到顶点 5,6 和 7 。

  • 指定面时必须遵循右手定则


这是一个blockMesh可以正常工作的版本:

FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

scale 1.0;

vertices
(
    (0 0 0) //0
    (0 0 1) //1
    (0 1 1) //2
    (0 1 0) //3
    (1 0 0) //4
    (1 0 1) //5
    (1 1 1) //6
    (1 1 0) //7
);

edges
(
);

blocks
(
    hex (0 4 7 3 1 5 6 2) //>>>> Follow the rules above <<<<
    (2 1 1)               // 2 blocks in the x direction
    simpleGrading (1 1 1) // default expansion ratios
);

boundary
(
    inlet
    {
        type patch;
        faces
        (
            (0 1 2 3) 
        );
    }

    outlet
    {
        type patch;
        faces
        (
            (4 7 6 5)
        );
    }

    walls
    {
        type wall;
        faces
        (
            (0 3 7 4)
            (0 4 5 1)
            (1 5 6 2)
            (2 6 7 3)
        );
    }
);

使用:

blockMesh
paraFoam -block

你会得到:

块的视图

旁注openfoam.com:您在使用 OpenFOAM 基础版本 ( openfoam.org)时指的是文档。小心,因为它们不一定兼容。


推荐阅读