Skip to content
Snippets Groups Projects
Commit 06453757 authored by Alexis Girault's avatar Alexis Girault
Browse files

COMP: Correct errors in TimeIntegrator

1) include <g3log/g3log.hpp> for logger
2) use TimeIntegrator::Type instead of timeIntegratorType
3) use std::array to be able to assign from an initializer list

Style:
1) Add call definition in error logs
2) Change case of TimeIntegrator::Type enum
3) do not use 'this->' on class members
parent 13da4e1e
No related branches found
No related tags found
No related merge requests found
......@@ -21,46 +21,48 @@ limitations under the License.
#include "imstkTimeIntegrator.h"
#include <g3log/g3log.hpp>
namespace imstk {
TimeIntegrator::TimeIntegrator(const timeIntegratorType type)
TimeIntegrator::TimeIntegrator(const Type type)
{
this->setType(type);
}
void
TimeIntegrator::setType(const timeIntegratorType type)
TimeIntegrator::setType(const Type type)
{
this->m_type = type;
m_type = type;
this->setCoefficients(type);
}
const Type&
const TimeIntegrator::Type&
TimeIntegrator::getType() const
{
return m_type;
}
void
TimeIntegrator::setCoefficients(const timeIntegratorType type)
TimeIntegrator::setCoefficients(const Type type)
{
switch (type) {
case timeIntegratorType::backwardEuler:
switch (type)
{
case Type::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!";
case Type::ForwardEuler:
case Type::NewmarkBeta:
case Type::CentralDifference:
LOG(WARNING) << "TimeIntegrator::setCoefficients error: type of the time integrator not supported.";
break;
default:
LOG(WARNING) << "Type of the time integrator not identified!";
LOG(WARNING) << "TimeIntegrator::setCoefficients error: type of the time integrator not identified!";
break;
}
}
}
......@@ -22,6 +22,8 @@
#ifndef imstkTimeIntegrator_h
#define imstkTimeIntegrator_h
#include <array>
namespace imstk {
///
......@@ -34,19 +36,19 @@ namespace imstk {
///
class TimeIntegrator
{
enum class timeIntegratorType
enum class Type
{
forwardEuler,
backwardEuler,
newmarkBeta,
centralDifference
ForwardEuler,
BackwardEuler,
NewmarkBeta,
CentralDifference
};
public:
///
/// \brief Constructor
///
TimeIntegrator(const timeIntegratorType type);
TimeIntegrator(const Type type);
///
/// \brief Destructor
......@@ -56,21 +58,21 @@ public:
///
/// \brief Set/Get type of the time integrator
///
void setType(const timeIntegratorType type);
void setType(const Type type);
const Type& getType() const;
///
/// \brief Set coefficients for a given time integrator type
///
void setCoefficients(const timeIntegratorType type);
void setCoefficients(const Type type);
protected:
timeIntegratorType m_type; ///> Type of the time integrator
Type m_type; ///> Type of the time integrator
// Coefficients of the time integrator
double m_alpha[3];
double m_gamma[3];
double m_beta[3];
std::array<double,3> m_alpha;
std::array<double,3> m_gamma;
std::array<double,3> m_beta;
};
}
......
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