void ElectroIonicModel::computeRhs (   const std::vector<vectorPtr_Type>& v,
                                       std::vector<vectorPtr_Type>& rhs )
{

    int nodes = ( * (v.at (1) ) ).epetraVector().MyLength();


    std::vector<Real>   localVec ( M_numberOfEquations, 0.0 );
    std::vector<Real>   localRhs ( M_numberOfEquations, 0.0 );

    int j (0);

    for ( int k = 0; k < nodes; k++ )
    {

        j = ( * (v.at (1) ) ).blockMap().GID (k);

        for ( int i = 0; i < M_numberOfEquations; i++ )
        {
            localVec.at (i) = ( * ( v.at (i) ) ) [j];
        }


        if (M_appliedCurrentPtr)
        {
            M_appliedCurrent = (*M_appliedCurrentPtr) [j];
        }
        else
        {
            M_appliedCurrent = 0.0;
        }
        computeRhs ( localVec, localRhs );
        addAppliedCurrent (localRhs);

        for ( int i = 0; i < M_numberOfEquations; i++ )
        {
            ( * ( rhs.at (i) ) ) [j] =  localRhs.at (i);
        }

    }

}
void FirstOrderLinearTIDS::initRhs(double time)
{
  if (_M && !_invM)
    _invM.reset(new SimpleMatrix(*_M));

  computeRhs(time);

  if (! _jacxRhs)  // if not allocated with a set or anything else
  {
    if (_A && ! _M)  // if M is not defined, then A = _jacxRhs, no memory allocation for that one.
      _jacxRhs = _A;
    else if (_A && _M)
    {
      _jacxRhs.reset(new SimpleMatrix(*_A)); // Copy A into _jacxRhs
      // Solve M_jacxRhs = A
      _invM->PLUForwardBackwardInPlace(*_jacxRhs);
    }
    // else no allocation, jacobian is equal to 0.
  }
}
Beispiel #3
0
void DynamicalSystem::update(double time)
{
  computeRhs(time);
  computeJacobianRhsx(time);
}