Skip to content

OpenFOAM

OpenFOAM交流区

4.5k Topics 26.5k Posts
  • interFoam标量输运

    10
    10 Posts
    1k Views
    李东岳

    你这个哪个是进出口,重力是向下的么,

    alpha场也发一下

  • 对边界场进行赋值

    7
    7 Posts
    1k Views
    ZY-GONGZ

    @李东岳 :xiexie: 感谢李老师

  • 双流体方法颗粒堆积模拟

    7
    7 Posts
    1k Views
    Y

    @xpqiu 好的,谢谢老师,我学习一下

  • 请教圆柱绕流一维能谱制作方法

    1
    1 Posts
    302 Views
    yfleungY

    各位带佬大家好,小弟最近在做一个雷诺数为3900的圆柱绕流。看到文献中有取圆柱后面一条线上的点做能谱分析的。

    (如取下图X/D=5;或X/D=10处的一条直线上的点的速度取平均值)

    5c64b8f6-a5e1-4ad9-a193-62c0e672ec64-image.png

    最后得出了这样子的一维能谱图

    393a09bf-c9a0-4b64-a2e5-055baca6e431-image.png

    小弟对该图片的横坐标和纵坐标表达的含义都不是很清楚。只知道在红色部分区域好像是符合湍流的-5/3幂律关系。所以想向各位带佬请教该图片横、纵坐标代表的含义,以及制作的方法。:chouchou: :chigua:

  • 论坛无法搜索

    6
    6 Posts
    1k Views
    L

    @李东岳 好的,感谢东岳老师:papa:

  • coded边界条件中变量的输出

    3
    3 Posts
    527 Views
    M

    @李东岳 感谢李老师回复。是一个volScalarField,其实就是grad(T),但是我是自定义的热流,所以采用了coded这种方式。我是按照patch("shell")索引的面,对所有属于这个patch的面进行了遍历,所以得到了一个长度为patch所含面数的数组。
    现在想把热流输出出来显示,用chtMultiRegionFoam -postProcess -func "grad (T)"后处理命令进行输出,报错如下:c132aa67-ee05-4b6d-8c90-55ed717f760e-image.png
    算例是可以正常计算的,已经计算结束了。这个错误也无从下手,所以还是尝试在coded里面直接写好把变量输出来。

  • 1 Posts
    288 Views
    chengan.wangC

    大家好、各位大佬好,咨询一个编译函数调用问题
    我在别的论坛找到了一个在求解器中定义函数编译调用的例子如下:

    //fun.H #ifndef fun_H #define fun_H #include "scalar.H" #include "vector.H" namespace Foam { vector TestMe(const vector& myvec); } #endif

    以及

    //fun.C #include "fun.H" Foam::vector Foam::TestMe(const vector& myvec) { Info<< "Hello from TestMe" << endl; Info<< "vector: " << myvec << endl; }

    然后在主函数里面调用 "fun.H"就行了。

    #include "fun.H" using namespace Foam; int main(int argc, char *argv[]) { vector A(1,2,3); Info<< "Hello from the main()" << endl; return 0; }

    我的思路就是直接在fun.H中写我想调用的代码。比如在“KinematicCloudI.H”文件中定义的

    template<class CloudType> inline const Foam::tmp<Foam::volVectorField> Foam::KinematicCloud<CloudType>::UPar() const { tmp<volVectorField> tUPar ( volVectorField::New ( this->name() + ":UPar", mesh_, dimensionedVector(dimVelocity, vector(0,0,0)), extrapolatedCalculatedFvPatchVectorField::typeName ) ); volVectorField& UPar = tUPar.ref(); forAllConstIter(typename KinematicCloud<CloudType>, *this, iter) { const parcelType& p = iter(); const label celli = p.cell(); UPar[celli] += (p.U())/(p.nParticle()); } UPar.primitiveFieldRef() /= 1;//mesh_.V(); UPar.correctBoundaryConditions(); return tUPar; }

    我直接移植过来,编译出现了如下错误:

    fun.H:16:41: error: no ‘const Foam::tmp<Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> > Foam::KinematicCloud<CloudType>::UPar() const’ member function declared in class ‘Foam::KinematicCloud<CloudType>’ Foam::KinematicCloud<CloudType>::UPar() const

    我尝试把“KinematicCloudI.H”里面的头文件粘上去也通过不了,应该怎么修改以及加一些什么内容呢?
    谢谢

  • 4 Posts
    906 Views
    J

    @李东岳 是的李老师

  • pFinal 关键字的实现过程

    3
    3 Posts
    625 Views
    Y

    @李东岳 好的,李老师,原来是这样

  • 3 Posts
    556 Views
    李东岳

    我也发现了这个情况,并且写在了ns方程笔记里面。不过没有详细研究。我觉得是因为多相流密度差异导致的压差计算不同导致的。有空是应该研究一下。

  • 虚拟机双版本OpenFOAM怎么切换使用

    3
    3 Posts
    801 Views
    U

    @李东岳谢谢东岳老师,已经搞定了在求解器窗口输入 of2106 就切换回V2106版本了:high:

  • 后处理输出Qdot

    2
    2 Posts
    771 Views
    C

    @adcpk 您好,请问这个问题后面解决了嘛,请教一下

  • 15 Posts
    3k Views
    I

    大家好,我来更新这个问题的相关进展。最近两天我查了些资料,基本上解决了这个问题,感谢大家的帮助,尤其是bestucan大佬。
    参考帖子关于相邻cell我写了个遍历进行暴力求解。
    (1)代码思路:对所有网格做遍历,找到气液界面网格,针对每一个气液界面网格都对所有网格再做一次遍历,计算两网格之间的距离,对满足距离要求的网格在markRegionNearInterface这个场上+1。最后,可以利用markRegionNearInterface>=1来筛选出所有满足条件的网格。
    (2)这段代码计算起来实在是费时间,因为我的需求(见贴名)不需要每一个时间步都运行这段代码,所以我在代码最外层套了一个时间步判断,可以实现多个时间步运行一次该代码。
    (3)我从其他地方抄了点代码写了两个接口,分别从transportProperties读取 加密时间步间隔 和 加密范围,其中加密范围是依据气泡半径写的无量纲范围,所以需要配合前面代码(未在本段代码中给出)求出的气泡半径radius.value()定义标记区域。

    代码如下

    //read timestep interval required for the following code, as the following code is very time consuming so I needn't it run for every timestep. const label calculateTimestepInterval = transportProperties.get<label>("calculateTimestepInterval"); //read information from transportProperties so that we can modify the size of marked region easily. scalar markRegionNearInterfaceSize = transportProperties.get<scalar>("markRegionNearInterfaceSize"); if (mesh.time().timeIndex() % calculateTimestepInterval == 0)//judge whether the timestep satisfy the timestep interval criterion. { markRegionNearInterface.field()=0;//reset the field to be zero first. Of course such field is claimed in createFields.H first. forAll(mesh.C(), i)//Cycle all meshes { if (alpha1[i]>0.0001&&alpha1[i]<0.9999)//judge whether the cell contains gas-liquid interface { vector centerOfSurfacePoint = mesh.C()[i];//store center information of such a interface cell forAll(mesh.C(), cellI)//Cycle all meshes again { scalar offset = mag(centerOfSurfacePoint - mesh.C()[cellI]);//distance between any cells and the interface cell if (offset <= markRegionNearInterfaceSize*radius.value())//judge the criterion, note the radius is calculated before with code which is not shown here { markRegionNearInterface.field()[cellI] += 1;//any cells which meet the criterion will be marked with value>0 } } } } }

    运行结果如下
    10652d23-2e1a-470d-a7ef-a8637883685a-image.png

    BTW
    (1) 因为我是个beginner,代码是东抄抄西抄抄弄出来的,上述代码可能有些冗余,如果大佬们有时间,想麻烦大佬们帮我看看我这些代码能从哪些角度优化优化。代码中的变量类型scalar vector label之类都是我一次次试错试出来的,也不知道这些变量类型用的合理不合理。
    (2)我在代码中写了两个链接到transportProperties的接口读取 加密时间步间隔 和 加密范围,测试中发现程序只会在刚开始运行时读取这些常量。请问各位大佬,有没有什么办法能否让程序运行中也能读取这些常量呢?因为假设运行过程中我想改动这两个常量,目前只能把计算停下来改了后重新继续算,不能边算边改。

  • 5 Posts
    944 Views
    疏影横斜水清浅

    @田畔的风 好的,谢谢

  • 3 Posts
    621 Views

    @李东岳 谢谢李老师!:xiezuoye:

  • 2 Posts
    446 Views
    李东岳

    那个有alpha场,可以用来定义界面。类似interFoam

  • 网格如何划分问题

    6
    6 Posts
    889 Views
    疏影横斜水清浅

    老师,我刚刚使用pimpleFoam算了,没有问题,加入拉格朗日颗粒场(使用pimple算法改的)导致的发散

  • InterFoam设置壁面Wall上不同的润湿性

    7
    7 Posts
    1k Views
    D

    @wsxfyy 谢谢,我试一下

  • 6 Posts
    1k Views

    @hurricane007 好的,非常感谢

  • 7 Posts
    1k Views
    chengan.wangC

    @星星星星晴 感觉nSector不能设为1,最后输出的sum(total mass),sum(average mass flow rate)是nSector>1的4倍左右。

    if (nSector_ > 1) { refDir = this->coeffDict().lookup("refDir"); refDir -= normal_[0]*(normal_[0] & refDir); refDir /= mag(refDir); } else { // set 4 quadrants for single sector cases nS = 4; vector tangent = vector::zero; scalar magTangent = 0.0; Random rnd(1234); while (magTangent < SMALL) { vector v = rnd.vector01(); tangent = v - (v & normal_[0])*normal_[0]; magTangent = mag(tangent); } refDir = tangent/magTangent; }

    可能跟源代码中nS = 4;有关系