@1064168551 在 求助:在codedict中读取求解器中定义的标量 中说:
@李东岳 东岳老师,抱歉再打扰您,我现在改成这个样子,还是会报错,dimensionedScalar好像还是无法lookup
报错在这里,就还是这行const dimensionedScalar vv = mesh.lookupObject<dimensionedScalar>("vv");有问题
@1064168551 在 求助:在codedict中读取求解器中定义的标量 中说:
@李东岳 东岳老师,抱歉再打扰您,我现在改成这个样子,还是会报错,dimensionedScalar好像还是无法lookup
报错在这里,就还是这行const dimensionedScalar vv = mesh.lookupObject<dimensionedScalar>("vv");有问题
@李东岳 东岳老师,抱歉再打扰您,我现在改成这个样子,还是会报错,dimensionedScalar好像还是无法lookup
@李东岳 好的,谢谢老师
@李东岳 老师我现在改成了这个样子,右边如果不lookup“vv”的话好像有点问题。
@李东岳 谢谢老师,那是不是就不需要用lookup函数读取vv了,可以在codedict里面直接调用vv
如图,左边为求解器代码,右图为自定义边界条件的codeDict,我想在codeDict中读取求解器中的标量vv,并赋值给入口速度,现在用lookup函数读取遇到了问题,想请教各位老师右图红色方框中代码应该改成什么?
@李东岳 在 OpenFOAM外挂libtorch 中说:
http://dyfluid.com/download.html 我这面有全系列的,里面gcc也可以切换。
你用你的老版本也行,老版本要更新gcc。
不管咋的你可以试试,有问题反馈我我协助
谢谢东岳老师,我的伴随拓扑优化是用老版本of写的,我试着更新gcc后编译一下,感谢感谢
@李东岳 好的谢谢老师
@1064168551 ![44c95d02-bafe-4b04-8ecb-10603fb0e805-image.png](/assets/uploads/files/17162 81973254-44c95d02-bafe-4b04-8ecb-10603fb0e805-image.png) 这里截了下部分报错信息
东岳老师您好,我正在做基于伴随的流热力拓扑优化,想用神经网络预测流体伴随方程解,在配置您说的这个libtorch时编译torchFoam失败了(我的环境变量都按您说的配置好了),我用的是您配置的openfoam5x的虚拟机,请问of版本不兼容吗?您用的是哪个版本of配置的呢?
报错的自定义边界如下,如图所示报错为:“‘incompressible’ does not name a type“,恳请论坛内各位老师解惑
/---------------------------------------------------------------------------\
\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
\ / O peration | |
\ / A nd | Copyright (C) 2011 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/>.
*---------------------------------------------------------------------------*/
#include "adjointOutletPressureHeatFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchMapper.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "RASModel.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::adjointOutletPressureHeatFvPatchScalarField::
adjointOutletPressureHeatFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF)
{}
Foam::adjointOutletPressureHeatFvPatchScalarField::
adjointOutletPressureHeatFvPatchScalarField
(
const adjointOutletPressureHeatFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper)
{}
Foam::adjointOutletPressureHeatFvPatchScalarField::
adjointOutletPressureHeatFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF)
{
fvPatchField<scalar>::operator=
(
scalarField("value", dict, p.size())
);
}
Foam::adjointOutletPressureHeatFvPatchScalarField::
adjointOutletPressureHeatFvPatchScalarField
(
const adjointOutletPressureHeatFvPatchScalarField& tppsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(tppsf, iF)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::adjointOutletPressureHeatFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
const fvsPatchField<scalar>& phip =
patch().lookupPatchField<surfaceScalarField, scalar>("phi");
const fvsPatchField<scalar>& phiap =
patch().lookupPatchField<surfaceScalarField, scalar>("phib");
const fvPatchField<vector>& Uap =
patch().lookupPatchField<volVectorField, vector>("Ub");
const dictionary& transportProperties = db().lookupObject<IOdictionary>("transportProperties");
dimensionedScalar nu(transportProperties.lookup("nu"));
scalarField Up_n = phip / patch().magSf();//Primal
scalarField Uap_n = phiap / patch().magSf();//Adjoint
const incompressible::RASModel& rasModel =
db().lookupObject<Foam::incompressible::RASModel>("RASProperties");
scalarField nueff = rasModel.nuEff()().boundaryField()[patch().index()];
const scalarField& deltainv = patch().deltaCoeffs(); // distance^(-1)
scalarField Uaneigh_n = (Uap.patchInternalField() & patch().nf());
//operator ==((Up_n * Uap_n) +2*nu.value()*deltainv*(Uap_n-Uaneigh_n));
operator ==((Up_n * Uap_n) +2*nueff.value()deltainv(Uap_n-Uaneigh_n));
fixedValueFvPatchScalarField::updateCoeffs();
}
void Foam::adjointOutletPressureHeatFvPatchScalarField::write(Ostream& os) const
{
fvPatchScalarField::write(os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
adjointOutletPressureHeatFvPatchScalarField
);
incompressible
}
如图,我想求解T的场,即第二张云图,但是求解出的场结果不符合物理意义,求解的方程如图1,DT和速度场如第三张和第一张云图所示,管道的右侧区域模拟的是固体,正常应该在T的场图中为0,但是结果却并非如此,求问造成这种现象的原因
@李东岳 谢谢李老师,我是两个block对应一个block会出问题,把右边的大block改成两个就不会出现defaultfaces了
请问我这个为什么blockMesh给我自动生成了两个defaultFaces面,这两个面是我不需要的
@李东岳 好的,谢谢老师,我目前主要是想对多组分气体(氧气和氮气)的稳态流动扩散进行求解,想着基于twomixingLiquidfoam简单修改修改,因为我对MULES研究的不多,如果是稳态计算的话,我可否直接在相方程里面添加对流项fvm::div(phi,alpha1),将求解alpha1的方程写成:
fvm::div(phi,alpha1) - fvm::laplacian
(
volScalarField("Dab", Dab + alphatab*turbulence->nut()),
alpha1
)
从而删去MULES部分呢?
各位老师好,我最近想把openfoam的twomixingLiquidfoam求解器改成稳态求解器,不知道怎样实现最简单?我的初步想法是把求解速度场和压力场的pimple求解器先改成simple求解器,然后把求解相alpha
1的方程中非稳态项(t的导数项)去掉,这样做可以吗?MULES的相关求解部分需要进行修改吗?或者各位老师有什么更简便的建议和方法?
@李东岳 好的谢谢老师
@xpqiu 1064168551@qq.com,谢谢老师!!!
有个问题想要请教下各位老师,如图,twoliquidmixingFoam求解器里面这个扩散方程里面为啥没有对流项fvm::div(phi,alpha)?