【发布时间】:2021-12-09 19:03:30
【问题描述】:
在 OpenFOAM 中,我可以访问我的模拟时间列表,如下所示:
const auto& tlist = mesh.time().times(); //or runTime.times();
只要在自定义函数对象的上下文中考虑这一点,您就可以在其中访问时间列表。
当我打印该列表时:
Foam::Info << tlist << Foam::endl;
然后通过postProcess命令运行函数对象,我得到:
9
(
0 constant
0 0
0.001 0.001
0.002 0.002
0.003 0.003
0.004 0.004
0.005 0.005
0.006 0.006
0.007 0.007
)
End
我想删除该列表中的前两个元素,即(0 constant) 和(0 0)。但是我找不到任何方法可以做到这一点,我发现的只是如果对象是一个 HashTable,那么有一个 erase 方法可以通过它的键删除元素。
任何想法如何从我的时间列表中删除前两个元素tlist?或者至少我怎样才能将该列表转换为另一个允许我这样做的数据结构?
谢谢
编辑:
这里是OpenFOAM上下文中List的定义链接:https://cpp.openfoam.org/v9/classFoam_1_1List.html
【问题讨论】:
-
你能显示更多的实际代码吗? tlist 的实际类型是什么?一个 std::list?
-
@PepijnKramer:它是一个 Foam::List,这是一个返回时间的函数的链接:github.com/OpenFOAM/OpenFOAM-2.0.x/blob/…
-
@PepijnKramer:或者这是最新版本:cpp.openfoam.org/v9/Time_8H_source.html 见第 334 行
标签: c++ list algorithm openfoam