UDF——Fluent与Matlab数据耦合
该插件可以直接在Visual Studio中一键编译、加载、调试UDF源码,极大提高编写排错效率,且支持C++,MFC,Windows API和第三方库,大大拓展UDF功能。插件的官方网站:https://vcudfstudio.bitbucket.io/。注:我不是这款插件的作者
有时候我们需要在计算的过程中将Fluent的数据传递给Matlab处理,然后将Matlab处理后的数据再回传给Fluent,实现二者之间的耦合,下面的代码简单实现了该过程。Fluent向Matlab发送“Hello Matlab”,然后Matlab向Fluent发送“Hello Fluent”
我们编写如下的Fluent的UDF源码:
Matlab端的代码比较简单,如下:
我们需要首先运行Matlab的程序,然后等待Fluent来连接
然后运行Fluent
运行结果如下:
@font-face { font-family: 宋体 }
@font-face { font-family: “Cambria Math” }
@font-face { font-family: Consolas }
@font-face { font-family: 楷体 }
@font-face { font-family: 微软雅黑 }
@font-face { font-family: “@楷体” }
@font-face { font-family: “@宋体” }
@font-face { font-family: “@微软雅黑” }
p.MsoNormal, li.MsoNormal, div.MsoNormal { mso-style-unhide: no; mso-style-qformat: yes; mso-style-parent: “”; margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: none; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; font-family: 等线; mso-ascii-font-family: 等线; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 等线; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: 等线; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: minor-bidi; mso-font-kerning: 1.0pt }
a:link, span.MsoHyperlink { mso-style-priority: 99; color: rgba(5, 99, 193, 1); mso-themecolor: hyperlink; text-decoration: underline; text-underline: single }
a:visited, span.MsoHyperlinkFollowed { mso-style-noshow: yes; mso-style-priority: 99; color: rgba(149, 79, 114, 1); mso-themecolor: followedhyperlink; text-decoration: underline; text-underline: single }
p { mso-style-noshow: yes; mso-style-priority: 99; mso-margin-top-alt: auto; margin-right: 0; mso-margin-bottom-alt: auto; margin-left: 0; mso-pagination: widow-orphan; font-size: 12pt; font-family: 宋体; mso-bidi-font-family: 宋体 }
.MsoChpDefault { mso-style-type: export-only; mso-default-props: yes; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: minor-bidi }
@page { mso-page-border-surround-header: no mso-page-border-surround-footer: no }
@page WordSection1 { size: 595.3pt 841.9pt margin-top: 72pt margin-right: 90pt margin-bottom: 72pt margin-left: 90pt mso-header-margin: 42.55pt mso-footer-margin: 49.6pt mso-paper-source: 0 layout-grid: 15.6pt }
div.WordSection1 { page: WordSection1 }
源码下载链接: https://pan.baidu.com/s/1ScLQdVvtqlt9YfTUsto_dQ
提取码: 95mj