Windows上编译计算Palabos案例指南

本文详细介绍了如何在Windows环境下使用code::blocks编译Palabos,包括配置环境、选择合适的编译器(如GCC)、解决路径名差异及生成GIF图像等问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Windows上编译计算Palabos

Palabos用户文档
Palabos主页
只有2.0版本里面还有code::block的设置文件cbp文件,新的2.1版就没有了,用户手册都是1.0版本的,如果想用windows,下载2.0版本的用,2.1版的,我还没看过
Palabos旧版2.0

原始文档

The C++ Integrated Development Environment (IDE) Code::Blocks is free, and you can download binaries for various flavors of Windows and Linux, and for Mac OS X (see codeblocks). A configuration file is delivered with the Palabos releases which can be used to compile Palabos with Code::Blocks. This approach was successfully tested under Windows and Linux, and neither Python nor make are needed for the compilation process.
Open the project file $(PALABOS)/codeblocks/Palabos.cbp under code::blocks, build and run the project. By default, the example program examples/showCases/cavity2d.cpp is compiled. To compile another example or your own program, remove the file cavity2d.cpp from the list of source files, and replace it by another one. The GIF images and other output files from the program are written in the directory $(PALABOS)/codeblocks/tmp/.
Code::Blocks is a cross-compiler environment, and you can in principle use it with just any C++ compiler. In particular, you can use it with the free GCC compiler. This compiler does not even need to be installed separately under Windows if you download the version of Code::Blocks which is directly packaged with the GCC port MinGW.
Note that the Palabos code does not compile with Visual C++, and we don’t know why; any suggestion is appreciated. In the meantime, you should use another compiler, such as GCC, the Intel compiler, or the Portland Group compiler.
As mentioned above, the Palabos download provides a project file for the free IDE Code::Blocks, through which you can easily use any of these compilers (we have only tested GCC/MinGW, though). If you have no C++ compiler installed on your system (other than Visual C++), remember to download the version of Code::Blocks which is packaged with the GCC port MinGW, after which you can directly compile Palabos.
Just as under Linux, you need to install ImageMagick if you want Palabos to be able to produce GIF images. If this fails, Palabos will write images in the PPM format, which is not recognized by most of the standard image viewers under Windows. In this case, you have the possibility to install the free image editor Gimp, which can view PPM images and convert them to another format.
It should also be reminded that the pathnames in the Palabos examples are written using the Unix convention, with slashes between directory names, while Windows uses backslashes. Under Windows, it is therefore recommended to change lines like
global::directories().setOutputDir("./tmp/");
to something like
global::directories().setOutputDir(".\\tmp\\");
although the programs appear to behave reasonably well even when you don’t do this.

文档翻译

c++集成开发环境(IDE)code::blocks是免费的,您可以下载Windows和Linux以及Mac OS X等格式的二进制文件(参见code::blocks)。配置文件随Palabos版本一起发布,可以使用code::blocks来编译Palabos。此方法已在Windows和Linux下成功测试,编译过程不需要Python或make。
在code::blocks中打开项目文件$(PALABOS)/codeblocks/palabos.cbp,建设和运行项目。默认情况下,编译示例程序examples/showCases/cavity2d.cpp。要编译另一个示例或您自己的程序,请从源文件列表中删除cavity2d.cpp文件,并将其替换为另一个文件。来自程序的GIF图像和其他输出文件写在$(PALABOS)/codeblocks/tmp/目录中。
code::blocks是一个交叉编译器环境,原则上可以与任何c++编译器一起使用。特别是,您可以在免费的GCC编译器中使用它。如果您下载直接与GCC端口MinGW打包的code::blocks的版本,那么这个编译器甚至不需要单独安装在Windows下。
注意,Palabos代码不能用Visual c++编译,我们不知道为什么;欢迎提出任何建议。同时,您应该使用其他编译器,如GCC、Intel编译器或Portland Group编译器。
如上所述,Palabos下载中,为code::blocks提供了一个项目文件,通过这个文件,您可以轻松地使用任何这些编译器(尽管我们只测试了GCC/MinGW)。如果您的系统上没有安装c++编译器(除了Visual c++),请记住下载与GCC端口MinGW打包的code::blocks的版本,然后您可以直接编译Palabos。
与在Linux下一样,如果希望Palabos能够生成GIF图像,则需要安装ImageMagick。如果失败,Palabos将以PPM格式编写图像,而大多数Windows下的标准图像查看器无法识别这种格式。在这种情况下,您可以安装免费的图像编辑器Gimp,它可以查看PPM图像并将其转换为另一种格式。
还应该注意,Palabos示例中的路径名是使用Unix约定编写的,目录名之间有斜杠,而Windows使用反斜杠。因此,在Windows下,建议更改类似的行
全球:目录().setOutputDir ("/tmp/.");
到类似的
全球:目录().setOutputDir (”.\ \ \ tmp \ \ \ \ ");
即使你不这样做,程序也表现得相当好。

解释说明

code::blocks下载地址
请选择带mingw编译期的版本下载,我下载的codeblocks-17.12mingw-setup.exe
装好,打开$(PALABOS)/codeblocks/palabos.cbp文件,所有配置就都配置好了。
一开始的文件是cavity2D.cpp,直接调试,如果显示
ERROR: You need to specify a debugger program in the debuggers’s settings.
请参考
解决方法:https://blog.csdn.net/baibaigao/article/details/80990266
生成正式版本时,也就是release时,同时只能有一个工程在showcases目录下,多项目文件放在这里,无法生成可执行文件,会报错。
调试时,也就是debug时,不用关心这个,选到你要调试的文件,直接调试就行。
在这里插入图片描述新项目添加,旧项目删除,即可调试其他案例
在这里插入图片描述

Palabos作为一个开源的并行计算软件,广泛应用于流体力学模拟。如果你是Palabos的新手,首先要熟悉其核心概念和安装过程。这里推荐《Palabos用户指南:入门与编程接口》,它将带你一步步了解Palabos的基础知识和使用方法。 参考资源链接:[Palabos用户指南:入门与编程接口](https://wenku.csdn.net/doc/iuas70ekzi?spm=1055.2569.3001.10343) 在不同操作系统上安装Palabos的过程会有所不同。对于Linux和Unix-like系统,你可能需要使用GCC或Clang编译器。根据指南,你需要下载Palabos的源代码,然后按照提供的步骤配置环境和编译项目。在MacOS X上,你可以使用Xcode进行编译,或者使用指南中推荐的其他方法。而Windows用户则可考虑使用Code::Blocks集成开发环境来编译Palabos代码。 选择合适的编程接口是根据你的具体需求和编程熟练度来决定的。如果你偏好使用Python,并希望快速上手,Palabos提供了Python接口,它允许你利用Python的强大功能和易用性来编写模拟程序。对于那些熟悉Java的开发者,Palabos同样提供了Java接口,这样你可以使用Java语言进行开发。根据《Palabos用户指南:入门与编程接口》,你可以找到详细的安装和使用说明,帮助你根据个人情况作出选择。 在开始使用Palabos进行流体力学模拟之前,你需要熟悉其基础数据类型和编程准则。这些内容在《Palabos用户指南》中有详尽的解释和示例,使你能够正确构建和操作流体模型。 综上所述,无论你是哪个操作系统上的新手,或是在选择编程语言上有疑惑,《Palabos用户指南:入门与编程接口》都是一个不可多得的资源。它不仅涵盖了安装和编译的基本步骤,还提供了如何利用Python和Java接口进行编程的指导,是深入了解Palabos的起点。 参考资源链接:[Palabos用户指南:入门与编程接口](https://wenku.csdn.net/doc/iuas70ekzi?spm=1055.2569.3001.10343)
评论 28
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值