如何在of里得到current time
-
问题背景:将sixDoFRigidBodyMotion中linearSpring的参数stiffness从常数改成随时间变化的函数 stiffness = f(t)
f(t) 可以是分段函数也可以是任意函数,t为目前的计算时间。因此我对$FOAM_SRC/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearSpring目录中的.C和.H文件进行改动。但是在获得当前计算时间这一步遇到了问题。。尝试了多种方法都无法编译,以下是我尝试的一些语句和报错:
(1) scalar current_time = db().time().value()
Error: ‘db’ was not declared in this scope
(2) scalar current_time = runTime().value()
scalar current_time = runTime_.time().timeOutputValue();
Error: ‘runTime’ was not declared in this scope
(3) scalar current_time = timeDirs.last().value()
Error: ‘timeDirs’ was not declared in this scope
(4) scalar current_time = U.runTime().value();
scalar current_time = U_.thisDb().time().value();
Error: ‘U’ was not declared in this scope
(5) scalar current_time = mesh_.time().value();
Error: ‘mesh_’ was not declared in this scope
(6) scalar current_time = this->db().time().timeOutputValue();
Error: ‘const class Foam::sixDoFRigidBodyMotionRestraints::linearSpring’ has no member named ‘db’挺简单一个问题,在网上找了很多方法,都失败了。。。不知道是不是因为没有包含需要的头文件?或者除了修改库文件,是否还有其他方法修改常数参数为time-dependent参数?请大神指教!!