Lines Matching defs:ngmres

1 #include <../src/snes/impls/ngmres/snesngmres.h> /*I "petscsnes.h" I*/
10 SNES_NGMRES *ngmres = (SNES_NGMRES *)snes->data;
13 PetscCall(VecDestroyVecs(ngmres->msize, &ngmres->Fdot));
14 PetscCall(VecDestroyVecs(ngmres->msize, &ngmres->Xdot));
15 PetscCall(SNESLineSearchDestroy(&ngmres->additive_linesearch));
21 SNES_NGMRES *ngmres = (SNES_NGMRES *)snes->data;
25 PetscCall(PetscFree4(ngmres->h, ngmres->beta, ngmres->xi, ngmres->q));
26 PetscCall(PetscFree3(ngmres->xnorms, ngmres->fnorms, ngmres->s));
28 PetscCall(PetscFree(ngmres->rwork));
30 PetscCall(PetscFree(ngmres->work));
41 SNES_NGMRES *ngmres = (SNES_NGMRES *)snes->data;
55 if (!ngmres->Xdot) PetscCall(VecDuplicateVecs(snes->vec_sol, ngmres->msize, &ngmres->Xdot));
56 if (!ngmres->Fdot) PetscCall(VecDuplicateVecs(snes->vec_sol, ngmres->msize, &ngmres->Fdot));
57 if (!ngmres->setup_called) {
58 msize = ngmres->msize; /* restart size */
62 PetscCall(PetscCalloc4(hsize, &ngmres->h, msize, &ngmres->beta, msize, &ngmres->xi, hsize, &ngmres->q));
63 PetscCall(PetscMalloc3(msize, &ngmres->xnorms, msize, &ngmres->fnorms, msize, &ngmres->s));
64 ngmres->nrhs = 1;
65 PetscCall(PetscBLASIntCast(msize, &ngmres->lda));
66 PetscCall(PetscBLASIntCast(msize, &ngmres->ldb));
67 PetscCall(PetscBLASIntCast(12 * msize, &ngmres->lwork));
69 PetscCall(PetscMalloc1(ngmres->lwork, &ngmres->rwork));
71 PetscCall(PetscMalloc1(ngmres->lwork, &ngmres->work));
74 ngmres->setup_called = PETSC_TRUE;
80 SNES_NGMRES *ngmres = (SNES_NGMRES *)snes->data;
85 PetscCall(PetscOptionsEnum("-snes_ngmres_select_type", "Select type", "SNESNGMRESSetSelectType", SNESNGMRESSelectTypes, (PetscEnum)ngmres->select_type, (PetscEnum *)&ngmres->select_type, NULL));
86 PetscCall(PetscOptionsEnum("-snes_ngmres_restart_type", "Restart type", "SNESNGMRESSetRestartType", SNESNGMRESRestartTypes, (PetscEnum)ngmres->restart_type, (PetscEnum *)&ngmres->restart_type, NULL));
87 PetscCall(PetscOptionsBool("-snes_ngmres_candidate", "Use candidate storage", "SNES", ngmres->candidate, &ngmres->candidate, NULL));
88 PetscCall(PetscOptionsBool("-snes_ngmres_approxfunc", "Linearly approximate the function", "SNES", ngmres->approxfunc, &ngmres->approxfunc, NULL));
89 PetscCall(PetscOptionsInt("-snes_ngmres_m", "Number of directions", "SNES", ngmres->msize, &ngmres->msize, NULL));
90 PetscCall(PetscOptionsInt("-snes_ngmres_restart", "Iterations before forced restart", "SNES", ngmres->restart_periodic, &ngmres->restart_periodic, NULL));
91 PetscCall(PetscOptionsInt("-snes_ngmres_restart_it", "Tolerance iterations before restart", "SNES", ngmres->restart_it, &ngmres->restart_it, NULL));
92 PetscCall(PetscOptionsBool("-snes_ngmres_monitor", "Monitor actions of NGMRES", "SNES", ngmres->monitor ? PETSC_TRUE : PETSC_FALSE, &debug, NULL));
93 if (debug) ngmres->monitor = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)snes));
94 PetscCall(PetscOptionsReal("-snes_ngmres_gammaA", "Residual selection constant", "SNES", ngmres->gammaA, &ngmres->gammaA, NULL));
95 PetscCall(PetscOptionsReal("-snes_ngmres_gammaC", "Residual restart constant", "SNES", ngmres->gammaC, &ngmres->gammaC, NULL));
96 PetscCall(PetscOptionsReal("-snes_ngmres_epsilonB", "Difference selection constant", "SNES", ngmres->epsilonB, &ngmres->epsilonB, NULL));
97 PetscCall(PetscOptionsReal("-snes_ngmres_deltaB", "Difference residual selection constant", "SNES", ngmres->deltaB, &ngmres->deltaB, NULL));
98 PetscCall(PetscOptionsBool("-snes_ngmres_restart_fm_rise", "Restart on F_M residual rise", "SNESNGMRESSetRestartFmRise", ngmres->restart_fm_rise, &ngmres->restart_fm_rise, NULL));
100 if (ngmres->gammaA > ngmres->gammaC && ngmres->gammaC > 2.) ngmres->gammaC = ngmres->gammaA;
101 if (ngmres->select_type == SNES_NGMRES_SELECT_LINESEARCH) {
102 PetscCall(SNESNGMRESGetAdditiveLineSearch_Private(snes, &ngmres->additive_linesearch));
103 PetscCall(SNESLineSearchSetFromOptions(ngmres->additive_linesearch));
110 SNES_NGMRES *ngmres = (SNES_NGMRES *)snes->data;
116 PetscCall(PetscViewerASCIIPrintf(viewer, " Number of stored past updates: %" PetscInt_FMT "\n", ngmres->msize));
117 if (ngmres->select_type == SNES_NGMRES_SELECT_DIFFERENCE) {
118 PetscCall(PetscViewerASCIIPrintf(viewer, " Residual selection: gammaA=%1.0e, gammaC=%1.0e\n", (double)ngmres->gammaA, (double)ngmres->gammaC));
119 PetscCall(PetscViewerASCIIPrintf(viewer, " Difference restart: epsilonB=%1.0e, deltaB=%1.0e\n", (double)ngmres->epsilonB, (double)ngmres->deltaB));
120 PetscCall(PetscViewerASCIIPrintf(viewer, " Restart on F_M residual increase: %s\n", PetscBools[ngmres->restart_fm_rise]));
122 if (ngmres->additive_linesearch) {
124 PetscCall(SNESLineSearchView(ngmres->additive_linesearch, viewer));
132 SNES_NGMRES *ngmres = (SNES_NGMRES *)snes->data;
247 if (ngmres->restart_type == SNES_NGMRES_RESTART_DIFFERENCE || ngmres->select_type == SNES_NGMRES_SELECT_DIFFERENCE) {
267 if (ngmres->restart_type == SNES_NGMRES_RESTART_DIFFERENCE) {
273 } else if (ngmres->restart_type == SNES_NGMRES_RESTART_PERIODIC) {
274 if (k_restart > ngmres->restart_periodic) {
275 if (ngmres->monitor) PetscCall(PetscViewerASCIIPrintf(ngmres->monitor, "periodic restart after %" PetscInt_FMT " iterations\n", k_restart));
276 restart_count = ngmres->restart_it;
280 ivec = k_restart % ngmres->msize; /* replace the last used part of the subspace */
283 if (restart_count >= ngmres->restart_it) {
284 if (ngmres->monitor) PetscCall(PetscViewerASCIIPrintf(ngmres->monitor, "Restarted at iteration %" PetscInt_FMT "\n", k_restart));
293 if (l < ngmres->msize) l++;
296 if (ngmres->candidate) {
352 SNES_NGMRES *ngmres = (SNES_NGMRES *)snes->data;
355 ngmres->restart_fm_rise = flg;
371 SNES_NGMRES *ngmres = (SNES_NGMRES *)snes->data;
374 *flg = ngmres->restart_fm_rise;
435 SNES_NGMRES *ngmres = (SNES_NGMRES *)snes->data;
438 ngmres->select_type = stype;
444 SNES_NGMRES *ngmres = (SNES_NGMRES *)snes->data;
447 ngmres->restart_type = rtype;
491 SNES_NGMRES *ngmres;
508 PetscCall(PetscNew(&ngmres));
509 snes->data = (void *)ngmres;
510 ngmres->msize = 30;
516 ngmres->candidate = PETSC_FALSE;
521 ngmres->additive_linesearch = NULL;
522 ngmres->approxfunc = PETSC_FALSE;
523 ngmres->restart_it = 2;
524 ngmres->restart_periodic = 30;
525 ngmres->gammaA = 2.0;
526 ngmres->gammaC = 2.0;
527 ngmres->deltaB = 0.9;
528 ngmres->epsilonB = 0.1;
529 ngmres->restart_fm_rise = PETSC_FALSE;
531 ngmres->restart_type = SNES_NGMRES_RESTART_DIFFERENCE;
532 ngmres->select_type = SNES_NGMRES_SELECT_DIFFERENCE;