2.创建第一个Moose应用程序

MOOSE is designed for building custom applications, therefore to use MOOSE an application is required. An application is where code and input files are created for a particular problem or set of problems of interest.

MOOSE 专为构建自定义应用程序而设计,因此要使用 MOOSE,需要应用程序。应用程序是为特定问题或一组感兴趣的问题创建代码和输入文件的地方。

1.Create an Application 创建应用程序

To create an application, run the stork.sh script while sitting outside the MOOSE repository with a single argument: the name of your application:

若要创建应用程序,请在 MOOSE 存储库外部运行 stork.sh 脚本,并使用单个参数:应用程序的名称:

点击查看代码
cd ~/projects
./moose/scripts/stork.sh YourAppName

Running this script will create a folder named "your_app_name" in the projects directory, this application will automatically link against MOOSE. Obviously, the "YourAppName" should be the desired name of your application; consider the use of an acronym. Animal names are preferred for applications, but you are free to choose whatever name suits your needs.

运行此脚本将在项目目录中创建一个名为“your_app_name”的文件夹,此应用程序将自动链接到 MOOSE。显然,“YourAppName”应该是应用程序的所需名称;考虑使用首字母缩略词。动物名称是申请的首选,但您可以自由选择适合您需求的任何名称。

WARNING:Execute stork from outside of the MOOSE directory
warning警告:从 MOOSE 目录外部执行 stork
Do not attempt to run this script while inside the MOOSE repository. Doing so will result in an error.
请勿尝试在 MOOSE 存储库中运行此脚本。这样做将导致错误。

2.Build and Test 生成和测试

Enter your application's directory, build your application and then run tests:
输入应用程序的目录,构建应用程序,然后运行测试:

点击查看代码
cd ~/projects/YourAppName
make -j 6
./run_tests -j 6

If your application is working correctly, the output shows a single passing test. This indicates that your application is ready to be further developed. Be sure to recompile and test your application each time you update MOOSE.

如果应用程序工作正常,则输出将显示单个通过测试。这表示您的应用程序已准备好进一步开发。请务必在每次更新 MOOSE 时重新编译和测试应用程序。

3.Enable Modules启用模块

To enable use of the various Physics Modules available from MOOSE in an application, modify the section of ~/projects/your_app_name/Makefile that is shown below.
要在应用程序中使用 MOOSE 提供的各种物理模块,请修改如下所示的 ~/projects/your_app_name/Makefile 部分。

点击查看代码
################################## MODULES ####################################
# To use certain physics included with MOOSE, set variables below to
# yes as needed.  Or set ALL_MODULES to yes to turn on everything (overrides
# other set variables).

ALL_MODULES                 := no

CHEMICAL_REACTIONS          := no
CONTACT                     := no
ELECTROMAGNETICS            := no
EXTERNAL_PETSC_SOLVER       := no
FLUID_PROPERTIES            := no
FSI                         := no
FUNCTIONAL_EXPANSION_TOOLS  := no
GEOCHEMISTRY                := no
HEAT_TRANSFER               := no
LEVEL_SET                   := no
MISC                        := no
NAVIER_STOKES               := no
OPTIMIZATION                := no
PERIDYNAMICS                := no
PHASE_FIELD                 := no
POROUS_FLOW                 := no
RAY_TRACING                 := no
REACTOR                     := no
RDG                         := no
RICHARDS                    := no
STOCHASTIC_TOOLS            := no
THERMAL_HYDRAULICS          := no
TENSOR_MECHANICS            := no
XFEM                        := no

Then, to begin using a module's capabilities, recompile the application in the same manner described in the Build and Test section.

然后,若要开始使用模块的功能,请按照“生成和测试”部分中所述的相同方式重新编译应用程序。

TIP:Only enable modules needed
schoolTIP:仅启用需要的模块
Each module enabled will increase compilation times, thus it is recommended to enable modules as-needed.
每个启用的模块都会增加编译时间,因此建议根据需要启用模块。

4.Staying Up To Date 保持最新状态

MOOSE does not use traditional versioning, is under heavy development, and is being updated continuously. Therefore, it is important that you continue to update MOOSE as you use it to develop your application(s); weekly updates are recommended.
MOOSE 不使用传统的版本控制,正在大量开发中,并且正在不断更新。因此,在使用 MOOSE 开发应用程序时,继续更新 MOOSE 非常重要;建议每周更新一次。

If this is your first day with MOOSE, you are already up to date. Come back in a week!
如果这是您使用 MOOSE 的第一天,那么您已经是最新的。一周后再来!

Update MOOSE repository:
更新 MOOSE 存储库:

点击查看代码
cd ~/projects/moose
git fetch origin
git rebase origin/master

Update Conda:
更新 Conda:

点击查看代码
conda activate base
conda env remove -n moose
conda create -n moose moose-dev=2023.12.20
conda activate moose

NOTE:Always Update MOOSE and the Conda packages together
注释注意:始终同时更新 MOOSE 和 Conda 软件包
There is a tight dependency between libraries being provided by Conda, and what libraries MOOSE depends on. Therefore, when you update one you should always update the other.
Conda 提供的库与 MOOSE 所依赖的库之间存在紧密的依赖关系。因此,当您更新一个时,您应该始终更新另一个。

Then return to your application, re-compile, and test:
然后返回到应用程序,重新编译和测试:

点击查看代码
cd ~/projects/YourAppName
make clobberall
make -j 6
./run_tests -j 6

5.Learn MoreLearn More

With a working application next consider looking at the Examples & Tutorials page for a beginning tour of how to use input files and implement custom behavior in an application. The first tutorial demonstrates how MOOSE application development works. If you are interested in contributing to MOOSE please visit Framework Development.
对于一个正常工作的应用程序,接下来考虑查看示例和教程页面,了解如何在应用程序中使用输入文件和实现自定义行为。第一个教程演示了 MOOSE 应用程序开发的工作原理。如果您有兴趣为 MOOSE 做出贡献,请访问 框架开发 。

6.Helpful Software一些有用的软件

A text editor is necessary for creating application files. There are many options available, so please feel free to chose an editor that meets your needs. A popular option for application developers is VSCode, which has community developed add-ons specifically for MOOSE: VSCode MOOSE.
创建应用程序文件需要文本编辑器。有很多选项可供选择,因此请随时选择满足您需求的编辑器。应用程序开发人员的一个流行选择是 VSCode ,它有社区专门为 MOOSE 开发的附加组件: VSCode MOOSE .

A graphical post-processor, particularly one that can read ExodusII files, is also necessary. MOOSE includes a graphical user interface (GUI): PEACOCK. Another popular tool is ParaView. Both of these applications are free and will allow you to visualize and process the results of your simulations.
图形后处理器,特别是可以读取 ExodusII 文件的后处理器,也是必要的。MOOSE 包括一个图形用户界面 (GUI):PEACOCK。另一个流行的工具是 ParaView .这两个应用程序都是免费的,允许您可视化和处理模拟结果。

7.Join the Community 加入社区

  • If you haven't already, please sign up for GitHub: github.com/join.
    如果您尚未注册,请注册 GitHub: github.com/join .

  • Visit the MOOSE Discussion forum on GitHub for technical Q&A.
    访问 GitHub 上的 MOOSE 论坛,获取技术问答。

8.Customizing MOOSE

MOOSE can be customized by running a configure script in ~/projects/moose. Note that the configure script must be invoked from ~/projects/moose. Below we summarize the configuration options available:
可以通过在 ~/projects/moose 中运行 configure 脚本来自定义 MOOSE。请注意, configure 脚本必须从 ~/projects/moose 调用。下面我们总结了可用的配置选项:

Automatic Differentiation 自动区分

  • --with-derivative-type: Specify the derivative storage type to use for MOOSE's DualReal object. Options are sparse and nonsparse. sparse selects SemiDynamicSparseNumberArray as the derivative storage type; nonsparse selects NumberArray. A more detailed overview of these storage types can be found in the DualReal documentation.
    --with-derivative-type :指定要用于 MOOSE 的 DualReal 对象的派生存储类型。选项为 sparse 和 nonsparse 。 sparse 选择 SemiDynamicSparseNumberArray 作为衍生存储类型; nonsparse 选择 NumberArray 。有关这些存储类型的更详细概述,请参阅 DualReal 文档。

  • --with-derivative-size=: Specify the length of the underlying derivative storage array. The default is 50. A smaller number may be chosen for increased speed; a larger number may be required for 3D problems or problems with coupling between many variables.
    --with-derivative-size= :指定底层派生存储阵列的长度。默认值为 50。为了提高速度,可以选择较小的数字;对于 3D 问题或许多变量之间的耦合问题,可能需要更大的数字。

  • --prefix: Specify a target installation path. Useful if you plan on running make install.
    --prefix :指定目标安装路径。如果您计划运行 make install ,则很有用。

9.Troubleshooting问题快照

Please see the MOOSE FAQ page for common issues. If your issue is not listed, this would be an excellent time to visit the MOOSE Discussion forum and ask for help.
有关常见问题,请参阅 MOOSE 常见问题解答页面。如果您的问题未列出,这将是访问 MOOSE 论坛并寻求帮助的绝佳时机。

posted @ 2023-12-24 20:21  Jankin-Wen  阅读(70)  评论(0编辑  收藏  举报