iMSTK
Interactive Medical Simulation Toolkit
imstkNonLinearSystem.cpp
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #include "imstkNonLinearSystem.h"
8 #include "imstkMath.h"
9 
10 namespace imstk
11 {
12 template<typename Matrix>
13 NonLinearSystem<Matrix>::NonLinearSystem(const VectorFunctionType& F, const MatrixFunctionType& dF) : m_F(F), m_dF(dF)
14 {
15  this->m_F_dF = [this](const Vectord& x, const bool semiImplicit)
16  {
17  return std::make_pair(&(this->m_F(x, semiImplicit)), &(this->m_dF(x)));
18  };
19 }
20 
21 template<typename Matrix>
22 NonLinearSystem<Matrix>::NonLinearSystem(const VectorFunctionType& F, const MatrixFunctionType& dF, const VectorMatrixFunctionType& F_dF) : m_F(F), m_dF(dF), m_F_dF(F_dF)
23 {
24 }
25 
26 template<typename Matrix>
27 void
28 NonLinearSystem<Matrix>::setFunction(const VectorFunctionType& function)
29 {
30  m_F = function;
31 }
32 
33 template<typename Matrix>
34 void
35 NonLinearSystem<Matrix>::setJacobian(const MatrixFunctionType& function)
36 {
37  m_dF = function;
38 }
39 
40 template<typename Matrix>
41 const Vectord&
42 NonLinearSystem<Matrix>::evaluateF(const Vectord& x, const bool isSemiImplicit)
43 {
44  return m_F(x, isSemiImplicit);
45 }
46 
47 template<typename Matrix>
48 const Matrix&
50 {
51  return m_dF(x);
52 }
53 
54 template class NonLinearSystem<SparseMatrixd>;
55 template class NonLinearSystem<Matrixd>;
56 } // namespace imstk
virtual const Vectord & evaluateF(const Vectord &x, const bool isSemiImplicit)
Evaluate function at a given state.
Compound Geometry.
Base class for a multi-variable nonlinear system.
virtual void setJacobian(const MatrixFunctionType &function)
Set the method that evaluates the gradient of the nonlinear function.
virtual const Matrix & evaluateJacobian(const Vectord &x)
Evaluate gradient of the function at a given state.
virtual void setFunction(const VectorFunctionType &function)
Set nonlinear method that evaluates the nonlinear function.