Skip to content

Commit 3ae4c05

Browse files
committed
fix for petsc 3.19
1 parent 07c6ec8 commit 3ae4c05

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

src/pdes/mechanical/init.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,9 @@ int feenox_problem_setup_snes_mechanical(SNES snes) {
639639
SNESLineSearchType ls_type;
640640
petsc_call(SNESLineSearchGetType(ls, &ls_type));
641641

642-
if (ls_type == NULL) {
642+
// PETSc 3.19 is buggy and needs TSSetFromOptions already called
643+
// that one sets the line search to bt and we want to default to basic
644+
if (ls_type == NULL || (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR == 19)) {
643645
petsc_call(SNESLineSearchSetType(ls, SNESLINESEARCHBASIC));
644646
}
645647
return FEENOX_OK;

src/pdes/petsc_ts.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ int feenox_problem_solve_petsc_transient(void) {
5353
}
5454

5555
// THINK! whats is going on here?
56-
// feenox_check_alloc(feenox.pde.J_ts = feenox_problem_create_matrix("J_ts"));
57-
petsc_call(MatDuplicate(feenox.pde.has_jacobian_K ? feenox.pde.JK : feenox.pde.K, MAT_COPY_VALUES, &feenox.pde.J_ts));
56+
feenox_check_alloc(feenox.pde.J_ts = feenox_problem_create_matrix("J_ts"));
57+
// petsc_call(MatDuplicate(feenox.pde.has_jacobian_K ? feenox.pde.JK : feenox.pde.K, MAT_COPY_VALUES, &feenox.pde.J_ts));
5858
petsc_call(TSSetIJacobian(feenox.pde.ts, feenox.pde.J_ts, feenox.pde.J_ts, feenox_ts_jacobian, NULL));
5959

6060
petsc_call(TSSetProblemType(feenox.pde.ts, (feenox.pde.math_type == math_type_linear) ? TS_LINEAR : TS_NONLINEAR));
@@ -122,6 +122,13 @@ int feenox_problem_setup_ts(TS ts) {
122122
// petsc_call(TSSetMaxStepRejections(feenox.pde.ts, 10000));
123123
// petsc_call(TSSetMaxSNESFailures(feenox.pde.ts, 1000));
124124

125+
// PETSc 3.19 is buggy and needs this guys here
126+
// the problem is that calling TSSetFromOptions here sets the line search to bt
127+
// and we want to default to basic
128+
if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR == 19) {
129+
petsc_call(TSSetFromOptions(ts));
130+
}
131+
125132
SNES snes;
126133
petsc_call(TSGetSNES(ts, &snes));
127134
if (snes != NULL) {
@@ -193,6 +200,7 @@ PetscErrorCode feenox_ts_residual(TS ts, PetscReal t, Vec phi, Vec phi_dot, Vec
193200
// set dirichlet bcs on the residual
194201
feenox_call(feenox_problem_dirichlet_set_r(r, phi));
195202

203+
196204
return FEENOX_OK;
197205
}
198206

tests/beam-ldef.fee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PROBLEM mechanical PC mumps
1+
PROBLEM mechanical #PC mumps
22
READ_MESH beam-cantilever-$1.msh
33

44
E = 100000

tests/hex8-ldef.fee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
READ_MESH hex8.msh
2-
PROBLEM mechanical PC mumps
2+
PROBLEM mechanical #PC mumps
33

44
ldef = 1
55
E = 1

0 commit comments

Comments
 (0)