OpenFOAM libtorch tutorial step by step
-
@李东岳 在 OpenFOAM libtorch tutorial step by step 中说:
net.H
#include <torch/torch.h> class NN : public torch::nn::Module { torch::nn::Sequential net_; public: NN(); torch::Tensor forward(torch::Tensor x); };
net.C
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2022-2023 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 See also SourceFiles \*---------------------------------------------------------------------------*/ #include "net.H" NN::NN() { net_ = register_module ( "net", torch::nn::Sequential ( torch::nn::Linear(2,20), torch::nn::ReLU(), torch::nn::Linear(20,30), torch::nn::ReLU(), torch::nn::Linear(30,30), torch::nn::ReLU(), torch::nn::Linear(30,20), torch::nn::ReLU(), torch::nn::Linear(20,20), torch::nn::ReLU(), torch::nn::Linear(20,1) ) ); }; torch::Tensor NN::forward(torch::Tensor x) { return net_->forward(x); }
这个要编译成库,挂到PINNFoam上面
李老师 请问这个如何编译并挂载呢 可以详细的指导一下吗
-
@李东岳 李老师您好,我在看您发的那个顶盖驱动流的代码的时候有个问题,我的电脑安装了openfoam10和11,同样的文件内容为什么在of10下我可以成功编译,但在of11下不可以呢。在11下,一开始提示找不到libtriSurface.so和libsurfMesh.so,然后我在bashrc中添加了,export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/john/OpenFOAM/OpenFOAM-11/platforms/linux64GccDPInt32Opt/lib,随后再次运行出现了这样的问题。
-
@李东岳 李老师您好,我在复现您这个例子的时候有一些细节有些糊涂?想请问您具体是怎么做的呢,能分享一下您的算例吗
@李东岳 在 OpenFOAM libtorch tutorial step by step 中说:
代码越来越复杂。这是执行一系列的卷积、池化操作等输出的8个通道的流场结果:
http://dyfluid.com/cnn.html#id6
下图是自编码器进行重组的流场:
-
CNN处理的时候,你需要生成不同的OpenFOAM网格,http://dyfluid.com/cnn.html#id6 我在这里面做了4次池化,那你就需要4套openfoam网格
我有这个算例,但是代码都是课堂现写,之前都是计划LCO课堂给大家讲的算例,写完了代码之后用我准备的算例去验证,后来大家一听一个不吱声,太难不讲了。目前我对CNN这方面也没有之前那么高涨,还没有重写代码的计划。