of调用IBM进行求解

想试试MIT zhang et al.开发的IBM程序( ChenguangZhang/sdfibm: Immersed boundary method empowered by signed distance field, and OpenFOAM. (github.com)),根据其教程操作之后,报错如下,想请教下正确的操作方式。
wx@DESKTOP-448V5SB:~$ cd /mnt/c/Users/miss_/Desktop/sdfibm/src

wx@DESKTOP-448V5SB:/mnt/c/Users/miss_/Desktop/sdfibm/src$ make

Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 28, in <module>
    from CommandNotFound import CommandNotFound
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
    from CommandNotFound.db.db import SqliteDatabase
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module>
    import apt_pkg
ImportError: /home/wx/OpenFOAM/ThirdParty-v1912/platforms/linux64/gcc-6.3.0/lib64/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /usr/lib/python3/dist-packages/apt_pkg.cpython-310-x86_64-linux-gnu.so)

wx@DESKTOP-448V5SB:/mnt/c/Users/miss_/Desktop/sdfibm/src$

大概是因为你用of所用的gcc版本低,而你系统里的gcc版本有太高了

是不是设置了环境变量?检查一下

另外是自己的机器吗?如果是的话,那么没必要用of里的那个,你这个of的版本也不低,用高版本编译器编译也没问题

我也有一台机器上是gcc4.8.5然后装了个gcc9,用起来也没啥大问题

是不是每包含 IFstream.H 头文件?

另外执行sdfibm时加上路径

我刚在Ubuntu中装了gcc, 但是我使用gcc-- version,显示的是of的gcc,是6。但是没有显示系统的。重新编译了下出现了一个error。暂时没管它,然后在这个ibm给的算例中选了一个,能成功生成网格,但是无法调用sdfibm求解器,可太难了

你这里rho是想要带量纲的值的话,不能这么写

IOdictionary transportProperties
(
    IOobject
    (
        "transportProperties",
        runTime.constant(),
        mesh,
        IOobject::MUST_READ_IF_MODIFIED,
        IOobject::NO_WRITE
    )
);

dimensionedScalar rho
(
    "rho",
    dimDensity,
    transportProperties
);

得写成这样

谢谢大佬的热心解答!

Thx. 应该不是环境变量的问题。我是win 10 下的Ubuntu 22.04 wls2,自己的电脑。
我重新make了下,仔细看了下error,是源文件中有错误,是不是不修改这个错误就无法调用sdfibm求解器呢?
这是尝试调用的情况:

wx@DESKTOP-448V5SB:/mnt/c/Users/miss_/Desktop/falling_ellipse$ sdfibm
-bash: /usr/local/bin/sdfibm: Permission denied
wx@DESKTOP-448V5SB:/mnt/c/Users/miss_/Desktop/falling_ellipse$ sudo sdfibm
sudo: sdfibm: command not found
wx@DESKTOP-448V5SB:/mnt/c/Users/miss_/Desktop/falling_ellipse$ ls ~ /usr/local/bin/
/home/wx:
''$'\001\020''3@pu'$'\001''@8'$'\r''@'$'\036\035\006\004''@@@�'$'\002''�'$'\002\b\003\004\030\003\030\003\030\003\034\034\001\001\004''�'$'\037''�'$'\037\020\001\005'
 OpenFOAM
 sdfibm

/usr/local/bin/:
sdfibm

附上make情况:

make -C libcollision
make[1]: Entering directory '/home/wx/sdfibm/src/libcollision'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/wx/sdfibm/src/libcollision'
make -C libmotion
make[1]: Entering directory '/home/wx/sdfibm/src/libmotion'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/wx/sdfibm/src/libmotion'
make -C libshape
make[1]: Entering directory '/home/wx/sdfibm/src/libshape'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/wx/sdfibm/src/libshape'
g++ -m64 -Dlinux32 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -DNoRepository -ftemplate-depth-100 -fPIC -std=c++11 -DWM_ARCH_OPTION=64 -DWM_LABEL_SIZE=32 -s -O3 main.cpp -o main.o -I. -IlnInclude -I/home/wx/OpenFOAM/OpenFOAM-v1912/src/finiteVolume/lnInclude -I/home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude -I/home/wx/OpenFOAM/OpenFOAM-v1912/src/dynamicFvMesh/lnInclude -I/home/wx/OpenFOAM/OpenFOAM-v1912/src/OSspecific/POSIX/lnInclude -I/home/wx/OpenFOAM/OpenFOAM-v1912/src/meshTools/lnInclude -c
In file included from main.cpp:9:0:
createFields.h: In function ‘int main(int, char**)’:
createFields.h:20:58: warning: ‘Foam::dimensioned<Type>::dimensioned(Foam::Istream&) [with Type = double]’ is deprecated: Since 2018-11 [-Wdeprecated-declarations]
 dimensionedScalar nu   (transportProperties.lookup("nu") );
                                                          ^
In file included from /home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/dimensionedType.H:565:0,
                 from /home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/dimensionedScalar.H:41,
                 from /home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/TimeState.H:41,
                 from /home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/Time.H:50,
                 from /home/wx/OpenFOAM/OpenFOAM-v1912/src/finiteVolume/lnInclude/fvCFD.H:6,
                 from main.cpp:1:
/home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/dimensionedType.C:275:1: note: declared here
 Foam::dimensioned<Type>::dimensioned(Istream& is)
 ^~~~
In file included from main.cpp:9:0:
createFields.h:23:58: warning: ‘Foam::dimensioned<Type>::dimensioned(Foam::Istream&) [with Type = double]’ is deprecated: Since 2018-11 [-Wdeprecated-declarations]
 dimensionedScalar rho  (transportProperties.lookup("rho"));
                                                          ^
In file included from /home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/dimensionedType.H:565:0,
                 from /home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/dimensionedScalar.H:41,
                 from /home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/TimeState.H:41,
                 from /home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/Time.H:50,
                 from /home/wx/OpenFOAM/OpenFOAM-v1912/src/finiteVolume/lnInclude/fvCFD.H:6,
                 from main.cpp:1:
/home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/dimensionedType.C:275:1: note: declared here
 Foam::dimensioned<Type>::dimensioned(Istream& is)
 ^~~~
In file included from main.cpp:9:0:
createFields.h:24:60: warning: ‘Foam::dimensioned<Type>::dimensioned(Foam::Istream&) [with Type = double]’ is deprecated: Since 2018-11 [-Wdeprecated-declarations]
 dimensionedScalar alpha(transportProperties.lookup("alpha"));
                                                            ^
In file included from /home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/dimensionedType.H:565:0,
                 from /home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/dimensionedScalar.H:41,
                 from /home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/TimeState.H:41,
                 from /home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/Time.H:50,
                 from /home/wx/OpenFOAM/OpenFOAM-v1912/src/finiteVolume/lnInclude/fvCFD.H:6,
                 from main.cpp:1:
/home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/dimensionedType.C:275:1: note: declared here
 Foam::dimensioned<Type>::dimensioned(Istream& is)
 ^~~~
g++ -m64 -Dlinux32 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -DNoRepository -ftemplate-depth-100 -fPIC -std=c++11 -DWM_ARCH_OPTION=64 -DWM_LABEL_SIZE=32 -s -O3 solidcloud.cpp -o solidcloud.o -I. -IlnInclude -I/home/wx/OpenFOAM/OpenFOAM-v1912/src/finiteVolume/lnInclude -I/home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude -I/home/wx/OpenFOAM/OpenFOAM-v1912/src/dynamicFvMesh/lnInclude -I/home/wx/OpenFOAM/OpenFOAM-v1912/src/OSspecific/POSIX/lnInclude -I/home/wx/OpenFOAM/OpenFOAM-v1912/src/meshTools/lnInclude -c
solidcloud.cpp: In member function ‘void sdfibm::SolidCloud::initFromDictionary(const Foam::word&)’:
solidcloud.cpp:28:5: error: ‘IFstream’ is not a member of ‘Foam’
     Foam::IFstream ifstream = Foam::IFstream(dictfile);
     ^~~~
solidcloud.cpp:29:30: error: ‘ifstream’ was not declared in this scope
     dictionary root(ifstream());
                              ^
solidcloud.cpp:29:30: note: suggested alternative:
In file included from /home/wx/OpenFOAM/ThirdParty-v1912/platforms/linux64/gcc-6.3.0/include/c++/6.3.0/iomanip:39:0,
                 from solidcloud.cpp:3:
/home/wx/OpenFOAM/ThirdParty-v1912/platforms/linux64/gcc-6.3.0/include/c++/6.3.0/iosfwd:162:34: note:   ‘std::ifstream ’
   typedef basic_ifstream<char>   ifstream;
                                  ^~~~~~~~
solidcloud.cpp: In member function ‘void sdfibm::SolidCloud::linkFluid(const volVectorField&)’:
solidcloud.cpp:587:77: error: invalid initialization of reference of type ‘const dimensionedScalar& {aka const Foam::dimensioned<double>&}’ from expression of type ‘Foam::ITstream’
     const Foam::dimensionedScalar&      density = transportProperties.lookup("rho");
                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
solidcloud.cpp: In member function ‘void sdfibm::SolidCloud::interact(const real&, const real&)’:
solidcloud.cpp:618:19: error: ambiguous overload for ‘operator=’ (operand types are ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ and ‘int’)
     (*m_ptr_ct) = 0;
                   ^
In file included from /home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/GeometricField.H:774:0,
                 from /home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/GeometricScalarField.H:40,
                 from /home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/GeometricFields.H:40,
                 from /home/wx/OpenFOAM/OpenFOAM-v1912/src/finiteVolume/lnInclude/volFields.H:39,
                 from /home/wx/OpenFOAM/OpenFOAM-v1912/src/finiteVolume/lnInclude/fvMatrix.H:46,
                 from /home/wx/OpenFOAM/OpenFOAM-v1912/src/finiteVolume/lnInclude/fvmDdt.H:41,
                 from /home/wx/OpenFOAM/OpenFOAM-v1912/src/finiteVolume/lnInclude/fvm.H:45,
                 from solidcloud.h:10,
                 from solidcloud.cpp:8:
/home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/GeometricField.C:1188:6: note: candidate: void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=(const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = double; PatchField = Foam::fvPatchField; GeoMesh = Foam::volMesh]
 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
      ^~~~
/home/wx/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/GeometricField.C:1224:6: note: candidate: void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=(const Foam::dimensioned<Type>&) [with Type = double; PatchField = Foam::fvPatchField; GeoMesh = Foam::volMesh]
 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
      ^~~~
make: *** [Makefile:56: solidcloud.o] Error 1

再次感谢

相应文件加上了H文件后,少了一个错误,但是还有如下错误:

solidcloud.cpp:588:77: error: invalid initialization of reference of type ‘const dimensionedScalar& {aka const Foam::dimensioned<double>&}’ from expression of type ‘Foam::ITstream’
     const Foam::dimensionedScalar&      density = transportProperties.lookup("rho");
                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
solidcloud.cpp: In member function ‘void sdfibm::SolidCloud::interact(const real&, const real&)’:
solidcloud.cpp:619:19: error: ambiguous overload for ‘operator=’ (operand types are ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ and ‘int’)
     (*m_ptr_ct) = 0;
l```
路径的话,因为链接了到了usr/local/bin/ 所以应该是可以全局执行的;当然我也试了加路径,报错也是一样的。

哇,大佬,我们做朋友吧,我尝试这样修改之后,这个错误就没有了,但是后面又有其他错误,最后重新装了个of6, 就是源代码中申明的版本,就直接好了。再次感谢!