Spring.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// 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
//
// 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 SURGSIM_PHYSICS_SPRING_H
#define SURGSIM_PHYSICS_SPRING_H
#include <vector>
#include "SurgSim/Math/Matrix.h"
#include "SurgSim/Math/SparseMatrix.h"
#include "SurgSim/Math/Vector.h"
namespace SurgSim
{
namespace Math
{
class OdeState;
};
namespace Physics
{
class Spring
{
public:
virtual ~Spring();
virtual void initialize(const SurgSim::Math::OdeState& state);
size_t getNumNodes() const;
size_t getNodeId(size_t springNodeId) const;
const std::vector<size_t>& getNodeIds() const;
virtual void addForce(const SurgSim::Math::OdeState& state, SurgSim::Math::Vector* F,
double scale = 1.0) = 0;
virtual void addDamping(const SurgSim::Math::OdeState& state, SurgSim::Math::SparseMatrix* D,
double scale = 1.0) = 0;
virtual void addStiffness(const SurgSim::Math::OdeState& state, SurgSim::Math::SparseMatrix* K,
double scale = 1.0) = 0;
virtual void addFDK(const SurgSim::Math::OdeState& state, SurgSim::Math::Vector* F,
SurgSim::Math::SparseMatrix* D, SurgSim::Math::SparseMatrix* K) = 0;
virtual void addMatVec(const SurgSim::Math::OdeState& state, double alphaD, double alphaK,
const SurgSim::Math::Vector& x, SurgSim::Math::Vector* F) = 0;
protected:
std::vector<size_t> m_nodeIds;
};
} // namespace Physics
} // namespace SurgSim
#endif // SURGSIM_PHYSICS_SPRING_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Math::OdeState
The state of an ode of 2nd order of the form with boundary conditions.
Definition: OdeState.h:38
SurgSim::Physics::Spring::m_nodeIds
std::vector< size_t > m_nodeIds
Node ids connected by this spring.
Definition: Spring.h:108
SparseMatrix.h
Definitions of useful sparse matrix functions.
SurgSim::Math::Vector
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:68
SurgSim::Math::SparseMatrix
Eigen::SparseMatrix< double > SparseMatrix
A sparse matrix.
Definition: SparseMatrix.h:32
SurgSim::Physics::Spring
Base class for all springs It handles the node ids to which it is connected and requires all derived ...
Definition: Spring.h:42
Matrix.h
Definitions of small fixed-size square matrix types.
Vector.h
Definitions of small fixed-size vector types.