Skip to content
Snippets Groups Projects
Commit de74bde7 authored by Sreekanth Arikatla's avatar Sreekanth Arikatla
Browse files

ENH: Adds time integrator class

Adds time integrator which only sets rules for finite difference in time.
Adds comments for DeformableObject class
parent 94cea245
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@
#include "imstkDeformableObject.h"
namespace imstk {
std::shared_ptr<Geometry>
DeformableObject::getPhysicsGeometry() const
{
......@@ -33,4 +34,11 @@ DeformableObject::setPhysicsGeometry(std::shared_ptr<Geometry> geometry)
{
m_physicsGeometry = geometry;
}
int
DeformableObject::getNumOfDOF() const
{
return numDOF;
}
}
......@@ -23,6 +23,7 @@
#define imstkDeformableObject_h
#include <memory>
#include <string>
#include "imstkCollidingObject.h"
......@@ -31,25 +32,50 @@ namespace imstk {
class Geometry;
class GeometryMap;
///
/// \class DeformableObject
///
/// \brief Base class for scene objects that deform
///
class DeformableObject : public CollidingObject
{
public:
///
/// \brief Constructor
///
DeformableObject(std::string name) : CollidingObject(name)
{
m_type = Type::Deformable;
}
///
/// \brief Destructor
///
~DeformableObject() = default;
///
/// \brief Returns the geometry used for Physics computations
///
std::shared_ptr<Geometry> getPhysicsGeometry() const;
///
/// \brief Assigns the geometry used for Physics related computations
///
void setPhysicsGeometry(std::shared_ptr<Geometry> geometry);
///
/// \brief Returns the number of degree of freedom
///
int getNumOfDOF() const;
protected:
std::shared_ptr<Geometry> m_physicsGeometry; ///> Geometry for collisions
std::shared_ptr<GeometryMap> m_physicsToCollidingMap; ///> Maps transformations to colliding geometry
std::shared_ptr<Geometry> m_physicsGeometry; ///> Geometry used for Physics
std::shared_ptr<GeometryMap> m_physicsToCollidingGeomMap; ///> Maps transformations to colliding geometry
std::shared_ptr<GeometryMap> m_physicsToVisualGeomMap; ///> Maps transformations to colliding geometry
int numDOF; ///> Number of degree of freedom of the body in the discretized model
};
}
......
......@@ -23,6 +23,7 @@
#define imstkSceneObject_h
#include <memory>
#include <string>
namespace imstk {
......
/*=========================================================================
Library: iMSTK
Copyright (c) Kitware, Inc. & Center for Modeling, Simulation,
& Imaging in Medicine, Rensselaer Polytechnic Institute.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/
#include "imstkTimeIntegrator.h"
namespace imstk {
TimeIntegrator::TimeIntegrator(const timeIntegratorType type)
{
this->setType(type);
}
void
TimeIntegrator::setType(const timeIntegratorType type)
{
this->m_type = type;
this->setCoefficients(type);
}
const Type&
TimeIntegrator::getType() const
{
return m_type;
}
void
TimeIntegrator::setCoefficients(const timeIntegratorType type)
{
switch (type) {
case timeIntegratorType::backwardEuler:
m_alpha = {1, 0, 0};
m_beta = {1, -1, 0};
m_gamma = {1, -2, -1};
break;
case timeIntegratorType::forwardEuler:
case timeIntegratorType::newmarkBeta:
case timeIntegratorType::centralDifference:
LOG(WARNING) << "Type of the time integrator not supported!";
break;
default:
LOG(WARNING) << "Type of the time integrator not identified!";
break;
}
}
}
/*=========================================================================
Library: iMSTK
Copyright (c) Kitware, Inc. & Center for Modeling, Simulation,
& Imaging in Medicine, Rensselaer Polytechnic Institute.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/
#ifndef imstkTimeIntegrator_h
#define imstkTimeIntegrator_h
namespace imstk {
///
/// \class TimeIntegrator
///
/// \brief This class defines the time integrators of various types.
/// It only sets the rules of how the velocity (or equivalent) and
/// acceleration (or equivalent) of the present time in terms of
/// positions (or equivalent) from previous time steps.
///
class TimeIntegrator
{
enum class timeIntegratorType
{
forwardEuler,
backwardEuler,
newmarkBeta,
centralDifference
};
public:
///
/// \brief Constructor
///
TimeIntegrator(const timeIntegratorType type);
///
/// \brief Destructor
///
~TimeIntegrator() = default;
///
/// \brief Set/Get type of the time integrator
///
void setType(const timeIntegratorType type);
const Type& getType() const;
///
/// \brief Set coefficients for a given time integrator type
///
void setCoefficients(const timeIntegratorType type);
protected:
timeIntegratorType m_type; ///> Type of the time integrator
// Coefficients of the time integrator
double m_alpha[3];
double m_gamma[3];
double m_beta[3];
};
}
#endif // ifndef imstkTimeIntegrator_h
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment