李老师您好。
目前出口是采用如下方程
这里Uc尝试过:
- 使用上下层速度的平均值1.5。
- 在X方向上采集最靠近边界的三个点的速度值进行平均,作为Uc。
如果采用2的话,Uc是一个随着Y坐标以及时间变换的函数Uc(y,t)
Phi是压力泊松方程构造的中间量,这个查了好多文章都说的很模糊,我也就直接用了零梯度。
李老师您好。
目前出口是采用如下方程
这里Uc尝试过:
如果采用2的话,Uc是一个随着Y坐标以及时间变换的函数Uc(y,t)
Phi是压力泊松方程构造的中间量,这个查了好多文章都说的很模糊,我也就直接用了零梯度。
各位老师好。目前我所模拟的是两层不同速度流体的混合问题。
N-S方程的求解采用的是Fractional Step Method,时间步进为三步龙格库塔法。
上下速度边界采用的是零梯度,左右采用周期性边界条件,进口指定一个速度Profile,出口采用的是对流流出的边界条件。
在计算过程中我遇到了一个问题,当压力结构到达出口边界时,会发生严重的扭曲。
这里主要有几个疑问:
自己在读本科的时候,大概是对科研一点想法也没有的吧。从小到大被教育好好学习,上了大学就轻松了,于是我就真的大学轻松了四年,之后在找个工作,拿一份能够养活自己的薪水,大概这就是自己的人生了。然而事实却告诉我,并不能这样,2014年恰好遭遇行业严冬,因为学校牌子多少还算是个985,所以虽然自身条件不怎么样,我也顺利进入了一所国企,但是实际的薪资却是差强人意,面对高额的房价再估算一下自己工资未来的涨幅,无奈之下只能工作之余复习考研。
当时的自己特别想出国读书,看看外面的世界,然而遭到了家里的强烈反对,家长纷纷表示按我本科的表现想要出国读书实在是好高骛远,后来我又表示最少换个专业换个更好的学校,至少避免重蹈本科工作的覆辙,又被家里拒绝了。我个人性格又软(可能这就是我一直做不好的事情的原因),于是就听家里的话老实报回了本校本专业。当时或许也是觉得已经没有退路,反而激发了我的斗志,最后考出了400多分的成绩,让家人后悔不已,没有听我当初的话让我拼一把,不过当时我是觉得本校也有本校的好处,毕竟朋友都在这里生活上也比较开心。于是开开心心地区复试了。
复试前便是选导师,由于本科没有实验室经历,也就凭本科上课的感觉选了现在的导师。导师年纪不大,但是却非常有为,每年论文稳定产出,学术称号也是一堆,让我觉得我的选择是正确的。当时刚进实验室时,心里是想着虽然硕士没能出去,至少博士能够出去读。然而很可惜,事实却很骨感,导师初始对我很热情,然而得知我出国读博而不是继续跟他的想法之后,我立即变成了“别人的学生”,进入不管不问偶尔打杂的时间。无奈下我开始自己找课题自己弄,也就是这个时期了解到了OpenFOAM。当然最初只是单纯觉得这个做出来图“很好看”,外加许多编程的地方比较多,自己也多少有点编程的天赋,于是就入了这个坑,顺便还能再结合本专业的内容进行研究。因为周围也没有搞这个的,也就自己摸索,外加的确Openfoam在外网开源的资料比较多,也就对照的看一下。由于之前只写过一些面向过程的程序,记得刚看Openfoam这种大量运用面向对象特性的程序感到无从下手,不过毕竟只要愿意下功夫,还是会有收获的。自己也算磕磕绊绊地上手了,虽然自己没有涉及过CFD和FVM底层的东西,但最后也能自己根据自己需要写一些功能,修改一下求解器,也算是能够上手了。这个过程或许是非常痛苦的,然而当有所进步时,也同时是最开心的,自己也是在这个过程中第一次有了做科研很有趣的想法,后来自费参加了东岳老师的暑期培训,也逐渐思考着未来自己能不能向纯CFD算法靠拢。然而个人的能力毕竟是有限的,尤其是对于我们这种工科非理科,除非是算法上很大创新,否则光有数值模拟没有试验很难发出什么高质量的文章。结果满打满算,自己即将毕业时不过手握两篇EI水会,虽然凭借自己努力考出了比较高的语言成绩,然而这是博士并非硕士,语言成绩已经不是什么重要因素,自己的论文又实在不够看,在申请季收到的回复寥寥无几,要么是“实验室已满”,要么是“我没有钱如果你自费我们再考虑你”,于是自己现在还是前路未卜。
现在离毕业只有3个多月,我却手里还没有收到什么像样的offer,加上春招由于疫情缘故也转为网络形式,比起往年形式不容乐观。自己又是进又不得,退又不得,我现在26岁,家里人又一直催我找工作,早点安定下来。我却每天生活在痛苦当中,深感这三年的付出如同泡沫一般付诸东流,自己无论怎么折腾都只是在瞎蹦跶。我又该何去何从呢....真的就要这么放手吗....
可能我这个问题比较奇葩,目标是要在multiphaseInterFoam里引入造波功能,造波功能主要基于waves2Foam。我的思路是这样的:
首先我观察了一下intefoam跟multiphaseInterFoam对于mixture的求解区别。发现主要在于,interfoam是把两相分为主相以及背景相,求解时只求解主相,这样背景相可以简单的进行反向选取,即alpha2=1-alpha1就能获得了。
但是相数超过2,就不存在这个背景相的问题了,在multiphaseMixture里,每一相都单独计算,最后累加出一个总相alphas出来。
对于解速度压力那一套,两者我感觉没有太大区别。
我打算先从两相做起,在multiphaseInterFoam里先实现一般的水-气两相造波,再考虑第三相的问题。也就是打算用multiphaseInterFoam复现interfoam的功能。
我按照以下步骤进行:
1.修改multiphasemixture的代码,提供一个获取各个相的相分数的接口。
2.修改multiphaseInterFoam的代码,将这个接口提供给原先造波消波的松弛区,每一步都对波浪进行修正。
2.修改waves2Foam的代码,对空气设定一个相分数的入射边界(实际上就是波浪相分数边界的反向选取)。
3.在求解器中,每次循环都同时对alpha.water以及alpha.air在边界上进行更新。
比如对于水,边界上入射的相分数可能是(假设2D算例,竖直方向共5个网格):
(0 0 0.6 1 1)
那么对于空气,就是
(1 1 0.4 0 0)
这样进行累加计算alphas的时候保证边界气液相分数累加为1,我在每一步的文件夹下观察结果,也的确没有发生越界。
但是实际运算的时候,出现了气液相分数越界,总相分数不守恒的现象,最后造出来的波是这种形状的
因为multiphaseInterFoam我想用在化工方面比较多一点,所以我想请问一下我是遗漏了哪些部分吗?
也请@东岳 老师指点。
第二个问题就是,我这个问题其实也类似一个分层流动,从上到下,第一相,第二相,第三相之间,第一相跟第三相是没有任何接触的。有没有划分成两个计算域,在第二相上交换信息的办法?
本人在学习OF之前,使用的商业软件基本都是依赖势流理论,引入格林函数基于边界元理论求解Laplace方程,最后用伯努利方程估算压力。
今天发现OF中也有一个potentialFoam是基于势流理论的,但是似乎跟我了解的势流理论有很大区别,只能计算稳态问题,但是控制方程的确也是Laplace方程。看起来两种求解器不单纯是FVM与边界元这种离散方式的区别,而是还有其他的不同,请问有了解这一块的大佬能讲讲这其中的问题所在吗?
@wwzhao 看起来显示的只是个并行计算的信息?
总而言之谢谢老师的指点了
@wwzhao 老师我想请教一个问题。我看到一些论文把重叠网格分为插值边界单元,贡献单元以及孤点单元,我想问着是否跟OpenFOAM的重叠单元的interpolated from local , mixed local/remote 以及 remoted相对应呢?
我计算的时候遇到了remoted单元不断上升的情况(初始0,计算100s后可能上升到几千),但是我的计算确实也没有发散,能够进行下去,如果remoted对应孤点单元,是不是代表我这个计算设定是不准确的呢?
@chaoscfd
想请问一下我是这是什么回事呢。。。
好像snap阶段结束后..就直接真的没了...
@东岳 顺便请教一下东岳老师
@chaoscfd
这里想请问您几个问题:
@东岳 好的 明白了 不过咱的求解器是基于InterFoam自己改的...我试试算的效果如何吧
谢谢老师
@东岳 谢谢东岳老师,不过想请问一下没问题是什么意思呢?
是指对敛散性不会有大的影响还是指对精度不会有太大影响呢?
但是更加奇怪的是我这种质量的网格依旧能够通过checkMesh...
这是为什么啊...
目前的问题主要是两方面:
2.边界层随缘加密,有时候能加上,有时候不能加上。
我个人的使用流程是这样的:
①用Solidwork画好实体,生成STL
②画背景网格并局部加密
③用surfaceFeatureExtract提取实体的边。
④SnappyHexMesh,将实体投射进网格。
结果实际制作出来的网格是坑坑洼洼的,完全不光滑,例如...
这样的效果还是在本人将Smooth和Snap的iteration调的非常大之后才能实现的,用200核的机器跑都需要15小时以上,然后跑出来结果就是这样的网格。
另外一个问题就是,我是的确选择了施加边界层的,但是到最后并没有出现边界层,依然只是局部加密。以下是我的SnappyHexMeshDict,不知有人愿意指点一下吗?谢谢
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Which of the steps to run
castellatedMesh true;
snap true;
addLayers true;
geometry
{
body.stl
{
name floatingObject;
type triSurfaceMesh;
}
};
// Settings for the castellatedMesh generation.
castellatedMeshControls
{
// Refinement parameters
// ~~~~~~~~~~~~~~~~~~~~~
// If local number of cells is >= maxLocalCells on any processor
// switches from from refinement followed by balancing
// (current method) to (weighted) balancing before refinement.
maxLocalCells 100000;
// Overall cell limit (approximately). Refinement will stop immediately
// upon reaching this number so a refinement level might not complete.
// Note that this is the number of cells before removing the part which
// is not 'visible' from the keepPoint. The final number of cells might
// actually be a lot less.
maxGlobalCells 3000000;
// The surface refinement loop might spend lots of iterations refining just a
// few cells. This setting will cause refinement to stop if <= minimumRefine
// are selected for refinement. Note: it will at least do one iteration
// (unless the number of cells to refine is 0)
minRefinementCells 50;
// Allow a certain level of imbalance during refining
// (since balancing is quite expensive)
// Expressed as fraction of perfect balance (= overall number of cells /
// nProcs). 0=balance always.
maxLoadUnbalance 0.10;
// Number of buffer layers between different levels.
// 1 means normal 2:1 refinement restriction, larger means slower
// refinement.
nCellsBetweenLevels 2;
// Explicit feature edge refinement
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Specifies a level for any cell intersected by explicitly provided
// edges.
// This is a featureEdgeMesh, read from constant/triSurface for now.
// Specify 'levels' in the same way as the 'distance' mode in the
// refinementRegions (see below). The old specification
// level 2;
// is equivalent to
// levels ((0 2));
features
(
{
file "body.eMesh";
level 2;
}
);
// Surface based refinement
// ~~~~~~~~~~~~~~~~~~~~~~~~
// Specifies two levels for every surface. The first is the minimum level,
// every cell intersecting a surface gets refined up to the minimum level.
// The second level is the maximum level. Cells that 'see' multiple
// intersections where the intersections make an
// angle > resolveFeatureAngle get refined up to the maximum level.
refinementSurfaces
{
floatingObject
{
level (1 2);
}
}
// Feature angle:
// - used if min and max refinement level of a surface differ
// - used if feature snapping (see snapControls below) is used
resolveFeatureAngle 30;
// Region-wise refinement
// ~~~~~~~~~~~~~~~~~~~~~~
// Specifies refinement level for cells in relation to a surface. One of
// three modes
// - distance. 'levels' specifies per distance to the surface the
// wanted refinement level. The distances need to be specified in
// increasing order.
// - inside. 'levels' is only one entry and only the level is used. All
// cells inside the surface get refined up to the level. The surface
// needs to be closed for this to be possible.
// - outside. Same but cells outside.
refinementRegions
{
floatingObject
{
mode distance;
levels ((2 2) (4 1));
}
}
// Mesh selection
// ~~~~~~~~~~~~~~
// After refinement patches get added for all refinementSurfaces and
// all cells intersecting the surfaces get put into these patches. The
// section reachable from the locationInMesh is kept.
// NOTE: This point should never be on a face, always inside a cell, even
// after refinement.
locationInMesh (0.0 0.0 0.1);
// Whether any faceZones (as specified in the refinementSurfaces)
// are only on the boundary of corresponding cellZones or also allow
// free-standing zone faces. Not used if there are no faceZones.
allowFreeStandingZoneFaces true;
}
// Settings for the snapping.
snapControls
{
// Number of patch smoothing iterations before finding correspondence
// to surface
nSmoothPatch 120;
// Maximum relative distance for points to be attracted by surface.
// True distance is this factor times local maximum edge length.
// Note: changed(corrected) w.r.t 17x! (17x used 2* tolerance)
tolerance 2.0;
// Number of mesh displacement relaxation iterations.
nSolveIter 300;
// Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh.
nRelaxIter 80;
// Feature snapping
// Number of feature edge snapping iterations.
// Leave out altogether to disable.
nFeatureSnapIter 80;
// Detect (geometric only) features by sampling the surface
// (default=false).
implicitFeatureSnap true;
// Use castellatedMeshControls::features (default = true)
explicitFeatureSnap true;
// Detect features between multiple surfaces
// (only for explicitFeatureSnap, default = false)
multiRegionFeatureSnap false;
}
// Settings for the layer addition.
addLayersControls
{
// Are the thickness parameters below relative to the undistorted
// size of the refined cell outside layer (true) or absolute sizes (false).
relativeSizes false;
// Layer thickness specification. This can be specified in one of four ways
// - expansionRatio and finalLayerThickness (cell nearest internal mesh)
// - expansionRatio and firstLayerThickness (cell on surface)
// - overall thickness and firstLayerThickness
// - overall thickness and finalLayerThickness
// Expansion factor for layer mesh
expansionRatio 1.2;
// Wanted thickness of final added cell layer. If multiple layers
// is the thickness of the layer furthest away from the wall.
// Relative to undistorted size of cell outside layer.
// See relativeSizes parameter.
//finalLayerThickness 0.03;
// Wanted thickness of the layer next to the wall.
// If relativeSizes this is relative to undistorted size of cell
// outside layer.
//firstLayerThickness 0.3;
// Wanted overall thickness of layers.
// If relativeSizes this is relative to undistorted size of cell
// outside layer.
//thickness 0.2;
// Minimum overall thickness of total layers. If for any reason layer
// cannot be above minThickness do not add layer.
// If relativeSizes this is relative to undistorted size of cell
// outside layer..
minThickness 0.001;
// Per final patch (so not geometry!) the layer information
// Note: This behaviour changed after 21x. Any non-mentioned patches
// now slide unless:
// - nSurfaceLayers is explicitly mentioned to be 0.
// - angle to nearest surface < slipFeatureAngle (see below)
layers
{
floatingBody
{
nSurfaceLayers 8;
firstLayerThickness 0.02;
}
}
// If points get not extruded do nGrow layers of connected faces that are
// also not grown. This helps convergence of the layer addition process
// close to features.
// Note: changed(corrected) w.r.t 17x! (didn't do anything in 17x)
nGrow 0;
// Advanced settings
// When not to extrude surface. 0 is flat surface, 90 is when two faces
// are perpendicular
featureAngle 360;
// At non-patched sides allow mesh to slip if extrusion direction makes
// angle larger than slipFeatureAngle.
//slipFeatureAngle 30;
// Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh.
nRelaxIter 80;
// Number of smoothing iterations of surface normals
nSmoothSurfaceNormals 100;
// Number of smoothing iterations of interior mesh movement direction
nSmoothNormals 50;
// Smooth layer thickness over surface patches
nSmoothThickness 100;
// Stop layer growth on highly warped cells
maxFaceThicknessRatio 0.5;
// Reduce layer growth where ratio thickness to medial
// distance is large
maxThicknessToMedialRatio 0.9;
// Angle used to pick up medial axis points
// Note: changed(corrected) w.r.t 17x! 90 degrees corresponds to 130 in 17x.
minMedianAxisAngle 150;
// Create buffer region for new layer terminations
nBufferCellsNoExtrude 0;
// Overall max number of layer addition iterations. The mesher will exit
// if it reaches this number of iterations; possibly with an illegal
// mesh.
nLayerIter 80;
// Max number of iterations after which relaxed meshQuality controls
// get used. Up to nRelaxIter it uses the settings in meshQualityControls,
// after nRelaxIter it uses the values in meshQualityControls::relaxed.
nRelaxedIter 80;
// Additional reporting: if there are just a few faces where there
// are mesh errors (after adding the layers) print their face centres.
// This helps in tracking down problematic mesh areas.
//additionalReporting true;
}
// Generic mesh quality settings. At any undoable phase these determine
// where to undo.
meshQualityControls
{
// Maximum non-orthogonality allowed. Set to 180 to disable.
maxNonOrtho 70;
// Max skewness allowed. Set to <0 to disable.
maxBoundarySkewness 4;
maxInternalSkewness 4;
// Max concaveness allowed. Is angle (in degrees) below which concavity
// is allowed. 0 is straight face, <0 would be convex face.
// Set to 180 to disable.
maxConcave 80;
// Minimum pyramid volume. Is absolute volume of cell pyramid.
// Set to a sensible fraction of the smallest cell volume expected.
// Set to very negative number (e.g. -1E30) to disable.
minVol 1e-13;
// Minimum quality of the tet formed by the face-centre
// and variable base point minimum decomposition triangles and
// the cell centre. This has to be a positive number for tracking
// to work. Set to very negative number (e.g. -1E30) to
// disable.
// <0 = inside out tet,
// 0 = flat tet
// 1 = regular tet
minTetQuality 1e-15;
// Minimum face area. Set to <0 to disable.
minArea -1;
// Minimum face twist. Set to <-1 to disable. dot product of face normal
// and face centre triangles normal
minTwist -2;
// minimum normalised cell determinant
// 1 = hex, <= 0 = folded or flattened illegal cell
minDeterminant 0.001;
// minFaceWeight (0 -> 0.5)
minFaceWeight 0.00;
// minVolRatio (0 -> 1)
minVolRatio 0.01;
// must be >0 for Fluent compatibility
minTriangleTwist -1;
//- If >0 : preserve single cells with all points on the surface if the
// resulting volume after snapping (by approximation) is larger than
// minVolCollapseRatio times old volume (i.e. not collapsed to flat cell).
// If <0 : delete always.
//minVolCollapseRatio 0.5;
// Advanced
// Number of error distribution iterations
nSmoothScale 200;
// amount to scale back displacement at error points
errorReduction 0.8;
// Optional : some meshing phases allow usage of relaxed rules.
// See e.g. addLayersControls::nRelaxedIter.
relaxed
{
//- Maximum non-orthogonality allowed. Set to 180 to disable.
maxNonOrtho 70;
}
}
// Advanced
// Merge tolerance. Is fraction of overall bounding box of initial mesh.
// Note: the write tolerance needs to be higher than this.
mergeTolerance 1e-6;
// ************************************************************************* //
@wwzhao 好的好的 谢谢老师~~
@wwzhao 另外想请教您一个问题,一般重叠网格(贴体的那个网格),尺寸应该取多大比较合适呢。
我看tutorials里的构件都比较小,可能实体是 0.2×0.3×0.4的大小,重叠网格大概就是0.4×0.6×0.8
但是我要计算的物体几何尺寸可能有几m到十几米,这样也重叠网格的尺寸也要翻倍?
还是说,只要能够保证重叠区包裹住实体就可以了?
@wwzhao 想请教您一个问题
现在我在计算中遇到了remote单元不断上升的情况,然后接着就是某一步速度或者压力突然迭代次数剧增,然后计算发散。
我想请问一下您,一般背景跟overlap的网格差距设定为多大合适?
另外就是PIMPLE各个设定,看您在别的帖子提到需要提高外循环的次数,一般多少比较合适呢?
下面的图按照初始setField→计算一个时间步排列。
不知道为什么,经过计算后内部场的速度很快发生变化。 而内部场应该是利用势流理论估算的,但是拿N-S算出来的速度不应该跟势流估算的差这么大啊...
初始波峰在左侧
波峰传递过来时
波峰在右侧
波峰离开
另外就是我想请教一下,我看到IHFoam以及waves2Foam进行造波时,指定的入口条件都只有速度以及相分数的边界条件。
压力全是依赖N-S方程的压力泊松方程解的,不依赖伯努利方程进行估算,这个说法对吗?
目前我的做法就是,基于waves2Foam的框架,对其进行扩展,利用kdV方程的解模拟海洋内孤立波。这个跟普通的孤立波相当近似,但是上层的气相变成了密度稍低的水,并且上层的低密度水跟下层的高密度水互不相容(可以把上层的水当做油来看)。
公式参考的是:这两位的论文
个人主要就是改了一下几点:
TransportProperties 里 气相相关属性替换为液相
waves2Foam波浪模块,原先只操作液相网格不操作气相,现在两层流体需要对上层的网格也进行操作,对其速度进行赋值。
解决完以上问题后,进行setFields,得到结果如上图所示:
对比论文,这个水质点速度分布我认为是比较合理的,然而.....
如果用waveFoam(本质上还是Interfoam,不过多了个速度入口的波浪边界条件)开始计算,结果发现速度会发生突变,导致波面很快变形消失。
t=0.001时刻的速度分布。
、
这里我尝试了将波浪方程中的时变项全部去掉,或者把时间步长取得再小一点,都遇到了这种突变。
个人猜测是interFoam进行多相流计算的时候还有什么关键点我没考虑到,或者是interFoam只可以算气液多相流?
请各位赐教。
@wwzhao 对 是这样 两套网格似乎是在独立算没有交互
我后来又换了个算例,结果又有overlap了,然后今天又做了个,又变成零了。。
这个规律到底是闹哪样。。。
@wwzhao 请教一下老师,非常感谢
本人先是跑了一下tutorials的overInterDyMFoam的算例,一切正常,然后将模型换成了自己的一个算例,然后问题来了。
openfoam识别不了两套网格的交叉区域,两边好像都是在独自在跑,没有插值,具体问题如下:
Creating cellMask field to block out hole cells
inverseDistance : detected 2 mesh regions
zone:0 nCells:1331200 voxels:(35 35 35) bb:(-10.0000079951 -5.00000799512 -6.00000799512) (-4.87499200488 -1.62499200488 -0.874992004884)
zone:1 nCells:238837 voxels:(35 35 35) bb:(-62.0000295973 -25.0000295973 -26.0000295973) (-35.9999704027 -14.9999704027 -15.9999704027)
Overset analysis : nCells : 1570037
calculated : 238837
interpolated : 0 (interpolated from local:0 mixed local/remote:0 remote:0)
hole : 1331200
Creating interpolatedCells field
从计算开始到结束都没有变化,interpolated的数量始终为0
主要有几个问题:
目前做的项目是关于一个不规则波作用对于浮体的作用的,于是我打算利用一下OpenFOAM的三个第三方工具箱
waves2foam, IHFoam以及OlaFoam。为了检验其准确性,我打算对结果跑一下后处理,看一下波面、周期之类的。
首先是用IHFoam跑了几个算例,IHFoam会通过调用"libsampling.so"来自定义一个后处理函数freeSurface,计算结果是关于计算域整个波面的的vtk格式的文件,但是实在看不太懂里面信息的意思,无奈只能先pass。
接着是waves2foam,这里**@一生俯首拜玄处**在知乎上详细介绍了waves2foam的一个监测波高的后处理工具,waveGaugesNProbes:
https://zhuanlan.zhihu.com/p/37406110
从原理上来讲似乎就是沿波浪传播方向布点,然后作一个通过这个点的垂线,寻找alpha=0.5的坐标位置,这个感觉就跟我需要的功能很接近了,但是这个后处理函数是waves2foam自带的,不属于OpenFOAM的函数。
于是我有以下几个问题:
①对于这类监测波高问题,如果是二维情况下,很简单沿波浪传播方向布点就可以了,如果是三维情况下布点应按照什么规则呢,简单的任选一条直线布点就可以吗?
②如果希望将waves2foam的这个后处理工具用于IHFoam或是InterFoam, 那么简单的在controlDict-functions里面Include相关函数就可以了吗?
③最后,也是我想问的。之前自己写的OpenFOAM程序都是直接对求解器或者是库函数进行直接操作编译的。如果希望能够像这些第三方工具那样去写外挂的后处理函数,而不直接对OpenFOAM本体动刀的话,请问在哪里能找到相关教程呢?
@浪迹天大 谢谢您! 问题解决了
忘记提了,自己之前是4.x环境,这么写是完全没问题的,但是实测v1712跟v1812都会有报这个错
因为需要用到一些只能在com跑的工具箱,所以笔者打算将之前写的代码从Org版本迁移到com版本,但是发现自己掉坑里了。具体报错如下:
In file included from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/List.H:322:0,
from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/HashTable.C:30,
from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/Istream.H:184,
from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/ISstream.H:39,
from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/IOstreams.H:38,
from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/VectorSpace.C:27,
from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/VectorSpace.H:233,
from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/Vector.H:44,
from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/vector.H:39,
from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/point.H:35,
from lnInclude/mooringLine.H:39,
from lnInclude/ICC.H:39,
from QCC/QCC.H:39,
from QCC/QCC.C:26:
/home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/List.C: In instantiation of ‘Foam::List<T>::List(InputIterator, InputIterator) [with InputIterator = int; T = double]’:
QCC/QCC.C:230:40: required from here
/home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/List.C:213:44: error: no matching function for call to ‘distance(int&, int&)’
List<T>(begIter, endIter, std::distance(begIter, endIter))
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:66:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/string:40,
from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/string.H:51,
from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/word.H:43,
from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/int32.H:43,
from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/int.H:38,
from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/label.H:39,
from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/doubleFloat.H:29,
from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/floatScalar.H:38,
from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/scalar.H:39,
from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/vector.H:38,
from /home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/point.H:35,
from lnInclude/mooringLine.H:39,
from lnInclude/ICC.H:39,
from QCC/QCC.H:39,
from QCC/QCC.C:26:
/usr/include/c++/5/bits/stl_iterator_base_funcs.h:114:5: note: candidate: template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator)
distance(_InputIterator __first, _InputIterator __last)
^
/usr/include/c++/5/bits/stl_iterator_base_funcs.h:114:5: note: template argument deduction/substitution failed:
/usr/include/c++/5/bits/stl_iterator_base_funcs.h: In substitution of ‘template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator) [with _InputIterator = int]’:
/home/cybrex/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude/List.C:213:44: required from ‘Foam::List<T>::List(InputIterator, InputIterator) [with InputIterator = int; T = double]’
QCC/QCC.C:230:40: required from here
/usr/include/c++/5/bits/stl_iterator_base_funcs.h:114:5: error: no type named ‘difference_type’ in ‘struct std::iterator_traits<int>’
通过代码可以定位到类的一个成员函数,这里我声明了2个ScalarList与2个VectorList,然后会出现这个错误。
但是这个类的变量里面是有其他ScalarList以及VectorList的,所以个人觉得坑应该是在成员函数声明List 类的问题上,
但是又不太清楚这么底层的东西该如何修改,望各位赐教!谢谢!