openfoam - 如何在 OpenFOAM 中读取 0/U 文件中的字典变量
问题描述
我想在 0/U 的入口边界读取“transportProperties”字典的粘度变量“nu”,如下所示:
boundaryField
{
inlet
{
type codedFixedValue;
value uniform (0.006 0 0);
name parabolicInlet;
code
#{
// ... some lines of code ...
scalar nu = readScalar(this->db().lookupObject<IOdictionary>("transportProperties").lookup("nu"));
// ... some lines of code ...
#};
}
}
我得到了这个错误的令牌类型错误:
--> FOAM FATAL IO ERROR:
wrong token type - expected Scalar, found on line 22 the punctuation token '['
file: /home/behzadb/research/Simulations/ConfinedCylinder2D/TestCase-01/constant/transportProperties/nu at line 22.
From function Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::doubleScalar&)
in file lnInclude/Scalar.C at line 101.
FOAM exiting
我会很高兴知道我应该如何调用字典并从中读取尺寸标量变量“nu”以用于某些计算(如雷诺数)?
非常感谢,BB
解决方案
尝试以下操作:
boundaryField
{
inlet
{
type codedFixedValue;
value uniform (0.006 0 0);
name parabolicInlet;
code
#{
// ... some lines of code ...
dimensionedScalar nu
(
"nu",
dimViscosity,
this->db().lookupObject<IOdictionary>("transportProperties").lookup("nu")
);
// ... some lines of code ...
#};
}
}
您收到该错误是因为您试图将运动粘度读取为scalar
. 相反,使用dimensionedScalar
.
如果您想使用 的标量值nu
,可以通过以下方式访问它:
scalar nu_value = nu.value();
推荐阅读
- extjs - Sencha 插件不适用于 PhpStorm 2021.1?
- python - ModuleNotFoundError:没有名为“longformer.longformer”的模块;'longformer' 不是一个包
- next.js - Next.js 中的 openGraph 和 next-seo
- python - 读取 GCS blob,其中文件名来自 apache Beam 中的先前 p 集合
- elm - 从两个 posix 时间戳在 Elm 中创建倒计时
- excel - 使用 VBA 创建图表,然后使其成为活动图表
- python - 如何获取歌词歌曲中最常用的 50 个单词(Python)
- flutter - 如果应用程序未启动,Flutter Firebase 推送通知无法获取数据
- c# - 如何在循环中保存 k 的每个值?
- xaml - xamarin forms - 将文本绑定到 xaml 中的标签 - 我可以剪掉文本的结尾吗?