Skip to content

Commit

Permalink
per matrix relative tol
Browse files Browse the repository at this point in the history
  • Loading branch information
wortiz committed Dec 16, 2024
1 parent 6ffdcb2 commit 238ece8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/mm_as_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ struct Uniform_Problem_Description {
int pspg_lagged_tau;
int disable_supg_tau_sensitivities;
int supg_lagged_tau;
dbl Residual_Relative_Tol;
dbl Residual_Relative_Tol[MAX_NUM_MATRICES];
};
typedef struct Uniform_Problem_Description UPD_STRUCT;
/*____________________________________________________________________________*/
Expand Down
2 changes: 1 addition & 1 deletion src/dp_vif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ void noahs_ark(void) {
ddd_add_member(n, &upd->devss_traceless_gradient, 1, MPI_INT);
ddd_add_member(n, &upd->strong_bc_replace, 1, MPI_INT);
ddd_add_member(n, &upd->strong_penalty, 1, MPI_DOUBLE);
ddd_add_member(n, &upd->Residual_Relative_Tol, 1, MPI_DOUBLE);
ddd_add_member(n, &upd->Residual_Relative_Tol, MAX_NUM_MATRICES, MPI_DOUBLE);

ddd_add_member(n, pg->time_step_control_disabled, MAX_NUM_MATRICES, MPI_INT);
ddd_add_member(n, pg->matrix_subcycle_count, MAX_NUM_MATRICES, MPI_INT);
Expand Down
24 changes: 18 additions & 6 deletions src/mm_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -6655,6 +6655,9 @@ void rd_solver_specs(FILE *ifp, char *input) {
if (fscanf(ifp, "%le", &Epsilon[0][0]) != 1) {
GOMA_EH(GOMA_ERROR, "error reading Normalized (Newton) Residual Tolerance");
}
snprintf(echo_string, MAX_CHAR_ECHO_INPUT, "%s = %.4g", "Normalized Residual Tolerance",
Epsilon[0][0]);
ECHO(echo_string, echo_file);

for (imtrx = 1; imtrx < upd->Total_Num_Matrices; imtrx++) {
Epsilon[imtrx][0] = Epsilon[0][0];
Expand All @@ -6677,22 +6680,22 @@ void rd_solver_specs(FILE *ifp, char *input) {

iread = look_for_optional(ifp, "Residual Relative Tolerance", input, '=');
if (iread == 1) {
if (fscanf(ifp, "%le", &upd->Residual_Relative_Tol) != 1) {
if (fscanf(ifp, "%le", &upd->Residual_Relative_Tol[0]) != 1) {
GOMA_EH(GOMA_ERROR, "error reading Residual Relative Tolerance");
}
snprintf(echo_string, MAX_CHAR_ECHO_INPUT, "%s = %.4g", "Residual Relative Tolerance",
upd->Residual_Relative_Tol);
upd->Residual_Relative_Tol[0]);
ECHO(echo_string, echo_file);
} else {
upd->Residual_Relative_Tol = 1e10;
upd->Residual_Relative_Tol[0] = 1e10;
}
for (imtrx = 1; imtrx < upd->Total_Num_Matrices; imtrx++) {
upd->Residual_Relative_Tol[imtrx] = upd->Residual_Relative_Tol[0];
}

for (imtrx = 1; imtrx < upd->Total_Num_Matrices; imtrx++) {
Epsilon[imtrx][0] = Epsilon[0][0];
}
snprintf(echo_string, MAX_CHAR_ECHO_INPUT, "%s = %.4g", "Normalized Residual Tolerance",
Epsilon[0][0]);
ECHO(echo_string, echo_file);

for (imtrx = 1; imtrx < upd->Total_Num_Matrices; imtrx++) {
Epsilon[imtrx][2] = Epsilon[0][2];
Expand Down Expand Up @@ -8385,6 +8388,15 @@ void rd_eq_specs(FILE *ifp, char *input, const int mn) {
Epsilon[imtrx][1], mtrx_index1);
ECHO(echo_string, echo_file);
}
iread = look_forward_optional_until(ifp, "Residual Relative Tolerance", "MATRIX", input, '=');
if (iread == 1) {
if (fscanf(ifp, "%le", &upd->Residual_Relative_Tol[imtrx]) != 1) {
GOMA_EH(GOMA_ERROR, "error reading Residual Relative Tolerance");
}
snprintf(echo_string, MAX_CHAR_ECHO_INPUT, "%s = %.4g", "Residual Relative Tolerance",
upd->Residual_Relative_Tol[imtrx]);
ECHO(echo_string, echo_file);
}

pd_ptr->Matrix_Activity[mtrx_index0] = 1;

Expand Down
2 changes: 1 addition & 1 deletion src/mm_sol_nonlinear.c
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ int solve_nonlinear_problem(struct GomaLinearSolverData *ams,
s_end = s_start;

if (inewton > 0) {
dbl RelTol = upd->Residual_Relative_Tol;
dbl RelTol = upd->Residual_Relative_Tol[pg->imtrx];
*converged = (*converged && ((Norm[0][2] / Initial_Norm) < RelTol));
} else if (inewton == 0) {
Initial_Norm = Norm[0][2];
Expand Down

0 comments on commit 238ece8

Please sign in to comment.