2024年10月11日 06:26
@李东岳 是的,这里换成T后下面的scalar T = gMax(T)函数也可以正常使用
@李东岳 是的,这里换成T后下面的scalar T = gMax(T)函数也可以正常使用
我尝试将of2306的jouleHeating算例中的jouleHeating::V从恒定电压改为恒定电流设置,因此想要通过电流乘以电阻来计算电压,其中电阻的设置涉及到电导率,而这个电导率是随着温度的变化变化的,所以想要读取标量场中的电导率(sigma)数据。
以下是sigma设置
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2206 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
heating
{
type jouleHeatingSource;
active true;
jouleHeatingSourceCoeffs
{
anisotropicElectricalConductivity no;
// Optionally specify sigma as a function of temperature
//sigma 127599.8469;
//
sigma table
(
(273 59600000)
(298 58000000)
(500 32000000)
);
}
}
// ************************************************************************* //
下面是我写的codedFixedValue边界条件
boundaryField
{
inlet
{
type codedFixedValue;
value uniform 0;// 初始值,可以为0或其他合理的数值
name dynamicV;
codeInclude
#{
#include "mathematicalConstants.H"
#include "fvCFD.H"
#};
codeOptions
#{
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
#};
codeLibs
#{
-lmeshTools \
-lfiniteVolume
#};
code
#{
const fvMesh& mesh = this->patch().boundaryMesh().mesh();
dictionary C = mesh.lookupObject<dictionary>("fvOptions");
// 定义常数
scalar I = 0.6;
scalar L = 0.007875;
scalar A = 1.125e-8;
const volScalarField& sigma = mesh.lookupObject<volScalarField>("sigma");
scalar sigma = gMax(sigma);
// 计算电阻
scalar R = L / (sigma * A);
// 计算电压,确保恒定电流 I
scalar V = I * R;
Info << "V: " << V << endl;
Info << "R: " << R << endl;
Info << "sigma: " << sigma << endl;
// 将计算出的电压值作为边界条件
operator==(V);
#};
}
outlet
{
type fixedValue;
value uniform 0;
}
这样的写法会出现
Failed wmake "dynamicCode/dynamicV/platforms/linux64GccDPInt32Opt/lib/libdynamicV_c6587780c1810df06b6735b285db38c4418d36ec.so"
file: 0/solid/jouleHeatingSource:V.boundaryField.inlet at line 28 to 47.
From void Foam::codedBase::createLibrary(Foam::dynamicCode&, const Foam::dynamicCodeContext&) const
in file db/dynamicLibrary/codedBase/codedBase.C at line 245.
FOAM exiting
code_text
但是如果我把上面的sigam换成T又是可以运行的,想问问大家知道我该如何去写这段代码吗