void Arkode::writeArkodeOutput(const double &time, const double &h, const int &stp) { if (stp > 0) { if (_arkodesettings->getDenseOutput()) { _bWritten = false; double *oldValues = NULL; //We have to find all output-points within the last solver step while (_tLastWrite + dynamic_cast<ISolverSettings*>(_arkodesettings)->getGlobalSettings()->gethOutput() <= time) { if (!_bWritten) { //Rescue the calculated derivatives oldValues = new double[_continuous_system->getDimRHS()]; _continuous_system->getRHS(oldValues); } _bWritten = true; _tLastWrite = _tLastWrite + dynamic_cast<ISolverSettings*>(_arkodesettings)->getGlobalSettings()->gethOutput(); //Get the state vars at the output-point (interpolated) _idid = ARKodeGetDky(_arkodeMem, _tLastWrite, 0, _ARK_yWrite); _time_system->setTime(_tLastWrite); _continuous_system->setContinuousStates(NV_DATA_S(_ARK_yWrite)); _continuous_system->evaluateAll(IContinuous::CONTINUOUS); SolverDefaultImplementation::writeToFile(stp, _tLastWrite, h); } //end if time -_tLastWritten if (_bWritten) { _time_system->setTime(time); _continuous_system->setContinuousStates(_z); _continuous_system->setStateDerivatives(oldValues); delete[] oldValues; //_continuous_system->evaluateAll(IContinuous::CONTINUOUS); } else if (time == _tEnd && _tLastWrite != time) { _idid = ARKodeGetDky(_arkodeMem, time, 0, _ARK_y); _time_system->setTime(time); _continuous_system->setContinuousStates(NV_DATA_S(_ARK_y)); _continuous_system->evaluateAll(IContinuous::CONTINUOUS); SolverDefaultImplementation::writeToFile(stp, _tEnd, h); } } else { SolverDefaultImplementation::writeToFile(stp, time, h); } } }
/* Fortran interface to C routine ARKodeGetDky; see farkode.h for further details */ void FARK_DKY(realtype *t, int *k, realtype *dky, int *ier) { /* store pointer existing F2C_ARKODE_vec data array */ realtype *f2c_data = N_VGetArrayPointer(F2C_ARKODE_vec); /* attach output data array to F2C_ARKODE_vec */ N_VSetArrayPointer(dky, F2C_ARKODE_vec); /* call ARKodeGetDky */ *ier = 0; *ier = ARKodeGetDky(ARK_arkodemem, *t, *k, F2C_ARKODE_vec); /* reattach F2C_ARKODE_vec to previous data array */ N_VSetArrayPointer(f2c_data, F2C_ARKODE_vec); return; }