如何在 OpenFOAM 中读取 0/U 文件中的字典变量
How to read dictionary variable in 0/U file in OpenFOAM
我想在 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();
我想在 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();