Lines Matching refs:ts

433 static PetscErrorCode TSEvaluateStep_GLEE(TS ts, PetscInt order, Vec X, PetscBool *done)  in TSEvaluateStep_GLEE()  argument
435 TS_GLEE *glee = (TS_GLEE *)ts->data; in TSEvaluateStep_GLEE()
446 h = ts->time_step; in TSEvaluateStep_GLEE()
449 h = ts->ptime - ts->ptime_prev; in TSEvaluateStep_GLEE()
452 SETERRQ(PetscObjectComm((PetscObject)ts), PETSC_ERR_PLIB, "Invalid TSStepStatus"); in TSEvaluateStep_GLEE()
471 } else PetscCall(VecCopy(ts->vec_sol, X)); in TSEvaluateStep_GLEE()
490 …PetscCheck(done, PetscObjectComm((PetscObject)ts), PETSC_ERR_SUP, "GLEE '%s' of order %" PetscInt_… in TSEvaluateStep_GLEE()
495 static PetscErrorCode TSStep_GLEE(TS ts) in TSStep_GLEE() argument
497 TS_GLEE *glee = (TS_GLEE *)ts->data; in TSStep_GLEE()
515 PetscCall(TSGetSNES(ts, &snes)); in TSStep_GLEE()
516 next_time_step = ts->time_step; in TSStep_GLEE()
517 t = ts->ptime; in TSStep_GLEE()
521 for (reject = 0; reject < ts->max_reject && !ts->reason; reject++, ts->reject++) { in TSStep_GLEE()
522 PetscReal h = ts->time_step; in TSStep_GLEE()
523 PetscCall(TSPreStep(ts)); in TSStep_GLEE()
527 PetscCall(TSPreStage(ts, glee->stage_time)); in TSStep_GLEE()
545 PetscCall(VecCopy(i > 0 ? YStage[i - 1] : ts->vec_sol, YStage[i])); in TSStep_GLEE()
550 ts->snes_its += its; in TSStep_GLEE()
551 ts->ksp_its += lits; in TSStep_GLEE()
553 PetscCall(TSGetAdapt(ts, &adapt)); in TSStep_GLEE()
554 PetscCall(TSAdaptCheckStage(adapt, ts, glee->stage_time, YStage[i], &accept)); in TSStep_GLEE()
556 PetscCall(TSPostStage(ts, glee->stage_time, i, YStage)); in TSStep_GLEE()
557 PetscCall(TSComputeRHSFunction(ts, t + h * c[i], YStage[i], YdotStage[i])); in TSStep_GLEE()
559 PetscCall(TSEvaluateStep(ts, tab->order, ts->vec_sol, NULL)); in TSStep_GLEE()
563 PetscCall(TSGetAdapt(ts, &adapt)); in TSStep_GLEE()
566 PetscCall(TSAdaptChoose(adapt, ts, ts->time_step, &next_scheme, &next_time_step, &accept)); in TSStep_GLEE()
569 ts->ptime += ts->time_step; in TSStep_GLEE()
570 ts->time_step = next_time_step; in TSStep_GLEE()
574 PetscCall(TSGetTimeError(ts, 0, &glee->yGErr)); in TSStep_GLEE()
575 …PetscCall(PetscObjectComposedDataSetReal((PetscObject)ts->vec_sol, explicit_stage_time_id, ts->pti… in TSStep_GLEE()
579 PetscCall(VecMAXPY(ts->vec_sol, r, wr, X)); in TSStep_GLEE()
580 ts->time_step = next_time_step; in TSStep_GLEE()
586 if (glee->status != TS_STEP_COMPLETE && !ts->reason) ts->reason = TS_DIVERGED_STEP_REJECTED; in TSStep_GLEE()
590 static PetscErrorCode TSInterpolate_GLEE(TS ts, PetscReal itime, Vec X) in TSInterpolate_GLEE() argument
592 TS_GLEE *glee = (TS_GLEE *)ts->data; in TSInterpolate_GLEE()
599 …PetscCheck(B, PetscObjectComm((PetscObject)ts), PETSC_ERR_SUP, "TSGLEE %s does not have an interpo… in TSInterpolate_GLEE()
603 h = ts->time_step; in TSInterpolate_GLEE()
604 t = (itime - ts->ptime) / h; in TSInterpolate_GLEE()
607 h = ts->ptime - ts->ptime_prev; in TSInterpolate_GLEE()
608 t = (itime - ts->ptime) / h + 1; /* In the interval [0,1] */ in TSInterpolate_GLEE()
611 SETERRQ(PetscObjectComm((PetscObject)ts), PETSC_ERR_PLIB, "Invalid TSStepStatus"); in TSInterpolate_GLEE()
624 static PetscErrorCode TSReset_GLEE(TS ts) in TSReset_GLEE() argument
626 TS_GLEE *glee = (TS_GLEE *)ts->data; in TSReset_GLEE()
644 static PetscErrorCode TSGLEEGetVecs(TS ts, DM dm, Vec *Ydot) in TSGLEEGetVecs() argument
646 TS_GLEE *glee = (TS_GLEE *)ts->data; in TSGLEEGetVecs()
650 if (dm && dm != ts->dm) PetscCall(DMGetNamedGlobalVector(dm, "TSGLEE_Ydot", Ydot)); in TSGLEEGetVecs()
656 static PetscErrorCode TSGLEERestoreVecs(TS ts, DM dm, Vec *Ydot) in TSGLEERestoreVecs() argument
660 if (dm && dm != ts->dm) PetscCall(DMRestoreNamedGlobalVector(dm, "TSGLEE_Ydot", Ydot)); in TSGLEERestoreVecs()
668 static PetscErrorCode SNESTSFormFunction_GLEE(SNES snes, Vec X, Vec F, TS ts) in SNESTSFormFunction_GLEE() argument
670 TS_GLEE *glee = (TS_GLEE *)ts->data; in SNESTSFormFunction_GLEE()
673 PetscReal shift = glee->scoeff / ts->time_step; in SNESTSFormFunction_GLEE()
677 PetscCall(TSGLEEGetVecs(ts, dm, &Ydot)); in SNESTSFormFunction_GLEE()
681 dmsave = ts->dm; in SNESTSFormFunction_GLEE()
682 ts->dm = dm; in SNESTSFormFunction_GLEE()
684 PetscCall(TSComputeIFunction(ts, glee->stage_time, X, Ydot, F, PETSC_FALSE)); in SNESTSFormFunction_GLEE()
686 ts->dm = dmsave; in SNESTSFormFunction_GLEE()
687 PetscCall(TSGLEERestoreVecs(ts, dm, &Ydot)); in SNESTSFormFunction_GLEE()
691 static PetscErrorCode SNESTSFormJacobian_GLEE(SNES snes, Vec X, Mat A, Mat B, TS ts) in SNESTSFormJacobian_GLEE() argument
693 TS_GLEE *glee = (TS_GLEE *)ts->data; in SNESTSFormJacobian_GLEE()
696 PetscReal shift = glee->scoeff / ts->time_step; in SNESTSFormJacobian_GLEE()
700 PetscCall(TSGLEEGetVecs(ts, dm, &Ydot)); in SNESTSFormJacobian_GLEE()
702 dmsave = ts->dm; in SNESTSFormJacobian_GLEE()
703 ts->dm = dm; in SNESTSFormJacobian_GLEE()
705 PetscCall(TSComputeIJacobian(ts, glee->stage_time, X, Ydot, shift, A, B, PETSC_FALSE)); in SNESTSFormJacobian_GLEE()
707 ts->dm = dmsave; in SNESTSFormJacobian_GLEE()
708 PetscCall(TSGLEERestoreVecs(ts, dm, &Ydot)); in SNESTSFormJacobian_GLEE()
736 static PetscErrorCode TSSetUp_GLEE(TS ts) in TSSetUp_GLEE() argument
738 TS_GLEE *glee = (TS_GLEE *)ts->data; in TSSetUp_GLEE()
744 if (!glee->tableau) PetscCall(TSGLEESetType(ts, TSGLEEDefaultType)); in TSSetUp_GLEE()
748 PetscCall(VecDuplicateVecs(ts->vec_sol, r, &glee->Y)); in TSSetUp_GLEE()
749 PetscCall(VecDuplicateVecs(ts->vec_sol, r, &glee->X)); in TSSetUp_GLEE()
750 PetscCall(VecDuplicateVecs(ts->vec_sol, s, &glee->YStage)); in TSSetUp_GLEE()
751 PetscCall(VecDuplicateVecs(ts->vec_sol, s, &glee->YdotStage)); in TSSetUp_GLEE()
752 PetscCall(VecDuplicate(ts->vec_sol, &glee->Ydot)); in TSSetUp_GLEE()
753 PetscCall(VecDuplicate(ts->vec_sol, &glee->yGErr)); in TSSetUp_GLEE()
755 PetscCall(VecDuplicate(ts->vec_sol, &glee->W)); in TSSetUp_GLEE()
757 PetscCall(TSGetDM(ts, &dm)); in TSSetUp_GLEE()
758 PetscCall(DMCoarsenHookAdd(dm, DMCoarsenHook_TSGLEE, DMRestrictHook_TSGLEE, ts)); in TSSetUp_GLEE()
759 PetscCall(DMSubDomainHookAdd(dm, DMSubDomainHook_TSGLEE, DMSubDomainRestrictHook_TSGLEE, ts)); in TSSetUp_GLEE()
763 static PetscErrorCode TSStartingMethod_GLEE(TS ts) in TSStartingMethod_GLEE() argument
765 TS_GLEE *glee = (TS_GLEE *)ts->data; in TSStartingMethod_GLEE()
773 PetscCall(VecAXPY(glee->Y[i], S[i], ts->vec_sol)); in TSStartingMethod_GLEE()
778 static PetscErrorCode TSSetFromOptions_GLEE(TS ts, PetscOptionItems PetscOptionsObject) in TSSetFromOptions_GLEE() argument
795 PetscCall(TSGLEESetType(ts, flg ? namelist[choice] : gleetype)); in TSSetFromOptions_GLEE()
802 static PetscErrorCode TSView_GLEE(TS ts, PetscViewer viewer) in TSView_GLEE() argument
804 TS_GLEE *glee = (TS_GLEE *)ts->data; in TSView_GLEE()
813 PetscCall(TSGLEEGetType(ts, &gleetype)); in TSView_GLEE()
822 static PetscErrorCode TSLoad_GLEE(TS ts, PetscViewer viewer) in TSLoad_GLEE() argument
828 PetscCall(TSGetAdapt(ts, &tsadapt)); in TSLoad_GLEE()
830 PetscCall(TSGetSNES(ts, &snes)); in TSLoad_GLEE()
833 PetscCall(SNESSetFunction(snes, NULL, NULL, ts)); in TSLoad_GLEE()
834 PetscCall(SNESSetJacobian(snes, NULL, NULL, NULL, ts)); in TSLoad_GLEE()
851 PetscErrorCode TSGLEESetType(TS ts, TSGLEEType gleetype) in TSGLEESetType() argument
854 PetscValidHeaderSpecific(ts, TS_CLASSID, 1); in TSGLEESetType()
856 PetscTryMethod(ts, "TSGLEESetType_C", (TS, TSGLEEType), (ts, gleetype)); in TSGLEESetType()
875 PetscErrorCode TSGLEEGetType(TS ts, TSGLEEType *gleetype) in TSGLEEGetType() argument
878 PetscValidHeaderSpecific(ts, TS_CLASSID, 1); in TSGLEEGetType()
879 PetscUseMethod(ts, "TSGLEEGetType_C", (TS, TSGLEEType *), (ts, gleetype)); in TSGLEEGetType()
883 static PetscErrorCode TSGLEEGetType_GLEE(TS ts, TSGLEEType *gleetype) in TSGLEEGetType_GLEE() argument
885 TS_GLEE *glee = (TS_GLEE *)ts->data; in TSGLEEGetType_GLEE()
888 if (!glee->tableau) PetscCall(TSGLEESetType(ts, TSGLEEDefaultType)); in TSGLEEGetType_GLEE()
892 static PetscErrorCode TSGLEESetType_GLEE(TS ts, TSGLEEType gleetype) in TSGLEESetType_GLEE() argument
894 TS_GLEE *glee = (TS_GLEE *)ts->data; in TSGLEESetType_GLEE()
906 PetscCall(TSReset_GLEE(ts)); in TSGLEESetType_GLEE()
911 …SETERRQ(PetscObjectComm((PetscObject)ts), PETSC_ERR_ARG_UNKNOWN_TYPE, "Could not find '%s'", gleet… in TSGLEESetType_GLEE()
914 static PetscErrorCode TSGetStages_GLEE(TS ts, PetscInt *ns, Vec **Y) in TSGetStages_GLEE() argument
916 TS_GLEE *glee = (TS_GLEE *)ts->data; in TSGetStages_GLEE()
924 static PetscErrorCode TSGetSolutionComponents_GLEE(TS ts, PetscInt *n, Vec *Y) in TSGetSolutionComponents_GLEE() argument
926 TS_GLEE *glee = (TS_GLEE *)ts->data; in TSGetSolutionComponents_GLEE()
932 …PetscCheck(*n >= 0 && *n < tab->r, PetscObjectComm((PetscObject)ts), PETSC_ERR_ARG_OUTOFRANGE, "Se… in TSGetSolutionComponents_GLEE()
938 static PetscErrorCode TSGetAuxSolution_GLEE(TS ts, Vec *X) in TSGetAuxSolution_GLEE() argument
940 TS_GLEE *glee = (TS_GLEE *)ts->data; in TSGetAuxSolution_GLEE()
955 static PetscErrorCode TSGetTimeError_GLEE(TS ts, PetscInt n, Vec *X) in TSGetTimeError_GLEE() argument
957 TS_GLEE *glee = (TS_GLEE *)ts->data; in TSGetTimeError_GLEE()
976 static PetscErrorCode TSSetTimeError_GLEE(TS ts, Vec X) in TSSetTimeError_GLEE() argument
978 TS_GLEE *glee = (TS_GLEE *)ts->data; in TSSetTimeError_GLEE()
985 …PetscCheck(r == 2, PetscObjectComm((PetscObject)ts), PETSC_ERR_SUP, "TSSetTimeError_GLEE not suppo… in TSSetTimeError_GLEE()
987 PetscCall(VecCopy(ts->vec_sol, Y[i])); in TSSetTimeError_GLEE()
994 static PetscErrorCode TSDestroy_GLEE(TS ts) in TSDestroy_GLEE() argument
997 PetscCall(TSReset_GLEE(ts)); in TSDestroy_GLEE()
998 if (ts->dm) { in TSDestroy_GLEE()
999 PetscCall(DMCoarsenHookRemove(ts->dm, DMCoarsenHook_TSGLEE, DMRestrictHook_TSGLEE, ts)); in TSDestroy_GLEE()
1000 …PetscCall(DMSubDomainHookRemove(ts->dm, DMSubDomainHook_TSGLEE, DMSubDomainRestrictHook_TSGLEE, ts in TSDestroy_GLEE()
1002 PetscCall(PetscFree(ts->data)); in TSDestroy_GLEE()
1003 PetscCall(PetscObjectComposeFunction((PetscObject)ts, "TSGLEEGetType_C", NULL)); in TSDestroy_GLEE()
1004 PetscCall(PetscObjectComposeFunction((PetscObject)ts, "TSGLEESetType_C", NULL)); in TSDestroy_GLEE()
1025 PETSC_EXTERN PetscErrorCode TSCreate_GLEE(TS ts) in TSCreate_GLEE() argument
1032 ts->ops->reset = TSReset_GLEE; in TSCreate_GLEE()
1033 ts->ops->destroy = TSDestroy_GLEE; in TSCreate_GLEE()
1034 ts->ops->view = TSView_GLEE; in TSCreate_GLEE()
1035 ts->ops->load = TSLoad_GLEE; in TSCreate_GLEE()
1036 ts->ops->setup = TSSetUp_GLEE; in TSCreate_GLEE()
1037 ts->ops->step = TSStep_GLEE; in TSCreate_GLEE()
1038 ts->ops->interpolate = TSInterpolate_GLEE; in TSCreate_GLEE()
1039 ts->ops->evaluatestep = TSEvaluateStep_GLEE; in TSCreate_GLEE()
1040 ts->ops->setfromoptions = TSSetFromOptions_GLEE; in TSCreate_GLEE()
1041 ts->ops->getstages = TSGetStages_GLEE; in TSCreate_GLEE()
1042 ts->ops->snesfunction = SNESTSFormFunction_GLEE; in TSCreate_GLEE()
1043 ts->ops->snesjacobian = SNESTSFormJacobian_GLEE; in TSCreate_GLEE()
1044 ts->ops->getsolutioncomponents = TSGetSolutionComponents_GLEE; in TSCreate_GLEE()
1045 ts->ops->getauxsolution = TSGetAuxSolution_GLEE; in TSCreate_GLEE()
1046 ts->ops->gettimeerror = TSGetTimeError_GLEE; in TSCreate_GLEE()
1047 ts->ops->settimeerror = TSSetTimeError_GLEE; in TSCreate_GLEE()
1048 ts->ops->startingmethod = TSStartingMethod_GLEE; in TSCreate_GLEE()
1049 ts->default_adapt_type = TSADAPTGLEE; in TSCreate_GLEE()
1051 ts->usessnes = PETSC_TRUE; in TSCreate_GLEE()
1054 ts->data = (void *)th; in TSCreate_GLEE()
1056 PetscCall(PetscObjectComposeFunction((PetscObject)ts, "TSGLEEGetType_C", TSGLEEGetType_GLEE)); in TSCreate_GLEE()
1057 PetscCall(PetscObjectComposeFunction((PetscObject)ts, "TSGLEESetType_C", TSGLEESetType_GLEE)); in TSCreate_GLEE()