本文整理汇总了C++中simulation::node::SPtr::getTime方法的典型用法代码示例。如果您正苦于以下问题:C++ SPtr::getTime方法的具体用法?C++ SPtr::getTime怎么用?C++ SPtr::getTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simulation::node::SPtr
的用法示例。
在下文中一共展示了SPtr::getTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compareSimulatedToTheoreticalPositions
/// After simulation compare the positions of points to the theoretical positions.
bool compareSimulatedToTheoreticalPositions( double h, double tolerancePosition, double toleranceEnergy = 1e-13, double checkEnergyConservation=false)
{
int i = 0;
// Init simulation
sofa::simulation::getSimulation()->init(root.get());
double time = root->getTime();
// Get mechanical object
simulation::Node::SPtr massNode = root->getChild("MassNode");
typename MechanicalObject::SPtr dofs = massNode->get<MechanicalObject>(root->SearchDown);
// Animate
do
{
// Record the mass position
Coord p0=dofs.get()->read(sofa::core::ConstVecCoordId::position())->getValue()[0];
double absoluteError = fabs(p0[1]-positionsArray[i]);
// Compare mass position to the theoretical position
if( absoluteError > tolerancePosition )
{
ADD_FAILURE() << "Position of mass at time " << time << " is wrong: " << std::endl
<<" expected Position is " << positionsArray[i] << std::endl
<<" actual Position is " << p0[1] << std::endl
<< "absolute error = " << absoluteError << std::endl;
return false;
}
//Animate
sofa::simulation::getSimulation()->animate(root.get(),h);
time = root->getTime();
// Check if hamiltonian energy is constant when there is no damping
if(checkEnergyConservation && fabs(variationalSolver->f_hamiltonianEnergy.getValue() -totalEnergy) > toleranceEnergy )
{
ADD_FAILURE() << "Hamiltonian energy at time " << time << " is wrong: " << std::endl
<<" expected Energy is " << totalEnergy << std::endl
<<" actual Energy is " << variationalSolver->f_hamiltonianEnergy.getValue() << std::endl
<< "absolute error = " << fabs(variationalSolver->f_hamiltonianEnergy.getValue() -totalEnergy) << std::endl;
return false;
}
// Iterate
i++;
}
while (time < 2);
return true;
}
开发者ID:ejeanvoi,项目名称:sofa-kernel-cleaned,代码行数:51,代码来源:VariationalSymplecticImplicitSolverDynamic_test.cpp
示例2: compareSimulatedToTheoreticalPositions
/// After simulation compare the positions of points to the theoretical positions.
bool compareSimulatedToTheoreticalPositions(double tolerance)
{
// Init simulation
sofa::simulation::getSimulation()->init(root.get());
double time = root->getTime();
double stiffnessSpring = 100;
double mass = 10;
double w = sqrt(stiffnessSpring/mass);
// Get mechanical object
simulation::Node::SPtr massNode = root->getChild("MassNode");
typename MechanicalObject::SPtr dofs = massNode->get<MechanicalObject>(root->SearchDown);
// Animate
do
{
// Record the mass position
Coord p0=dofs.get()->read(sofa::core::ConstVecCoordId::position())->getValue()[0];
// Absolute error
double absoluteError = fabs(p0[1]-(cos(w*time)));
// Compare mass position to the theoretical position
if( absoluteError > tolerance )
{
ADD_FAILURE() << "Position of mass at time " << time << " is wrong: " << std::endl
<<" expected Position is " << cos(sqrt(stiffnessSpring/mass)*time) << std::endl
<<" actual Position is " << p0[1] << std::endl
<< "absolute error = " << absoluteError << std::endl;
return false;
}
//Animate
sofa::simulation::getSimulation()->animate(root.get(),0.001);
time = root->getTime();
}
while (time < 2);
return true;
}