Skip to content

Commit

Permalink
Merge pull request mfem#4585 from mfem/tmop-conv-warning
Browse files Browse the repository at this point in the history
Fix verbosity levels for NewtonSolver in TMOP miniapps
  • Loading branch information
tzanio authored Nov 22, 2024
2 parents 7c1a0eb + 3183af1 commit fe9bd03
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion fem/tmop_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ real_t TMOPNewtonSolver::ComputeScalingFactor(const Vector &x,
// Check for convergence
if (init_fit_max_err < surf_fit_max_err_limit)
{
if (print_options.iterations)
if (print_options.iterations || print_options.warnings)
{
mfem::out << "TMOPNewtonSolver converged "
"based on the surface fitting error.\n";
Expand Down
6 changes: 4 additions & 2 deletions linalg/solvers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1919,7 +1919,8 @@ void NewtonSolver::Mult(const Vector &b, Vector &x) const
print_options.first_and_last)
{
mfem::out << "Newton: Number of iterations: " << final_iter << '\n'
<< " ||r|| = " << final_norm << '\n';
<< " ||r|| = " << final_norm
<< ", ||r||/||r_0|| = " << final_norm/norm0 << '\n';
}
if (!converged && (print_options.summary || print_options.warnings))
{
Expand Down Expand Up @@ -2141,7 +2142,8 @@ void LBFGSSolver::Mult(const Vector &b, Vector &x) const
print_options.first_and_last)
{
mfem::out << "LBFGS: Number of iterations: " << final_iter << '\n'
<< " ||r|| = " << final_norm << '\n';
<< " ||r|| = " << final_norm
<< ", ||r||/||r_0|| = " << final_norm/norm0 << '\n';
}
if (print_options.summary || (!converged && print_options.warnings))
{
Expand Down
9 changes: 4 additions & 5 deletions miniapps/meshing/mesh-optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,13 @@
// Adapted discrete size NC mesh;
// mesh-optimizer -m amr-quad-q2.mesh -o 2 -rs 2 -mid 94 -tid 5 -ni 50 -qo 4 -nor
// Adapted discrete size 3D with PA:
// mesh-optimizer -m cube.mesh -o 2 -rs 2 -mid 321 -tid 5 -ls 3 -nor -pa
// mesh-optimizer -m cube.mesh -o 2 -rs 2 -mid 321 -tid 5 -ls 3 -nor -pa -rtol 1e-8
// Adapted discrete size 3D with PA on device (requires CUDA):
// * mesh-optimizer -m cube.mesh -o 3 -rs 3 -mid 321 -tid 5 -ls 3 -nor -lc 0.1 -pa -d cuda
// Adapted discrete size; explicit combo of metrics; mixed tri/quad mesh:
// mesh-optimizer -m ../../data/square-mixed.mesh -o 2 -rs 2 -mid 2 -tid 5 -ni 200 -bnd -qo 6 -cmb 2 -nor
// Adapted discrete size+aspect_ratio:
// mesh-optimizer -m square01.mesh -o 2 -rs 2 -mid 7 -tid 6 -ni 100
// mesh-optimizer -m square01.mesh -o 2 -rs 2 -mid 7 -tid 6 -ni 100 -qo 6 -ex -st 1 -nor
// Adapted discrete size+orientation:
// mesh-optimizer -m square01.mesh -o 2 -rs 2 -mid 36 -tid 8 -qo 4 -fd -nor
// Adapted discrete aspect ratio (3D):
Expand All @@ -67,7 +66,7 @@
// Adaptive limiting:
// mesh-optimizer -m stretched2D.mesh -o 2 -mid 2 -tid 1 -ni 50 -qo 5 -nor -vl 1 -alc 0.5
// Adaptive limiting through the L-BFGS solver:
// mesh-optimizer -m stretched2D.mesh -o 2 -mid 2 -tid 1 -ni 400 -qo 5 -nor -vl 1 -alc 0.5 -st 1
// mesh-optimizer -m stretched2D.mesh -o 2 -mid 2 -tid 1 -ni 400 -qo 5 -nor -vl 1 -alc 0.5 -st 1 -rtol 1e-8
// Adaptive limiting through FD (requires GSLIB):
// * mesh-optimizer -m stretched2D.mesh -o 2 -mid 2 -tid 1 -ni 50 -qo 5 -nor -vl 1 -alc 0.5 -fd -ae 1
//
Expand Down Expand Up @@ -1109,8 +1108,8 @@ int main(int argc, char *argv[])
}
// Level of output.
IterativeSolver::PrintLevel newton_print;
if (verbosity_level > 0)
{ newton_print.Errors().Warnings().Iterations(); }
if (verbosity_level > 0) { newton_print.Errors().Warnings().Iterations(); }
else { newton_print.Errors().Warnings(); }
solver.SetPrintLevel(newton_print);
// hr-adaptivity solver.
// If hr-adaptivity is disabled, r-adaptivity is done once using the
Expand Down
6 changes: 3 additions & 3 deletions miniapps/meshing/pmesh-fitting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
// mpirun -np 4 pmesh-fitting -o 3 -mid 58 -tid 1 -vl 1 -sfc 5e4 -rtol 1e-5
// mpirun -np 4 pmesh-fitting -m square01-tri.mesh -o 3 -rs 0 -mid 58 -tid 1 -vl 1 -sfc 1e4 -rtol 1e-5
// Surface fitting with weight adaptation and termination based on fitting error:
// mpirun -np 4 pmesh-fitting -o 2 -mid 2 -tid 1 -vl 2 -sfc 10 -rtol 1e-20 -sfa 10.0 -sft 1e-5 -no-resid
// mpirun -np 4 pmesh-fitting -o 2 -mid 2 -tid 1 -vl 2 -sfc 10 -rtol 1e-20 -sfa 10.0 -sft 1e-5 -no-resid -ni 40
// Surface fitting with weight adaptation, limit on max weight, and convergence based on residual.
// * mpirun -np 4 pmesh-fitting -m ../../data/inline-tri.mesh -o 2 -mid 2 -tid 4 -vl 2 -sfc 10 -rtol 1e-10 -sfa 10.0 -sft 1e-5 -bgamriter 3 -sbgmesh -ae 1 -marking -slstype 3 -resid -sfcmax 10000 -mod-bndr-attr
// Surface fitting to Fischer-Tropsch reactor like domain (requires GSLIB):
// * mpirun -np 6 pmesh-fitting -m ../../data/inline-tri.mesh -o 2 -rs 4 -mid 2 -tid 1 -vl 2 -sfc 100 -rtol 1e-12 -li 20 -ae 1 -bnd -sbgmesh -slstype 2 -smtype 0 -sfa 10.0 -sft 1e-4 -no-resid -bgamriter 5 -dist -mod-bndr-attr
// * mpirun -np 6 pmesh-fitting -m ../../data/inline-tri.mesh -o 2 -rs 4 -mid 2 -tid 1 -vl 2 -sfc 100 -rtol 1e-12 -li 20 -ae 1 -bnd -sbgmesh -slstype 2 -smtype 0 -sfa 10.0 -sft 1e-4 -no-resid -bgamriter 5 -dist -mod-bndr-attr -ni 50

#include "mesh-fitting.hpp"

Expand Down Expand Up @@ -809,7 +809,7 @@ int main (int argc, char *argv[])
solver.SetRelTol(solver_rtol);
solver.SetAbsTol(0.0);
solver.SetMinimumDeterminantThreshold(0.001*min_detJ);
solver.SetPrintLevel(verbosity_level >= 1 ? 1 : -1);
solver.SetPrintLevel(verbosity_level >= 1 ? 1 : 0);
solver.SetOperator(a);
Vector b(0);
solver.Mult(b, x.GetTrueVector());
Expand Down
9 changes: 4 additions & 5 deletions miniapps/meshing/pmesh-optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,13 @@
// Adapted discrete size NC mesh;
// mpirun -np 4 pmesh-optimizer -m amr-quad-q2.mesh -o 2 -rs 2 -mid 94 -tid 5 -ni 50 -qo 4 -nor
// Adapted discrete size 3D with PA:
// mpirun -np 4 pmesh-optimizer -m cube.mesh -o 2 -rs 2 -mid 321 -tid 5 -ls 3 -nor -pa
// mpirun -np 4 pmesh-optimizer -m cube.mesh -o 2 -rs 2 -mid 321 -tid 5 -ls 3 -nor -pa -rtol 1e-8
// Adapted discrete size 3D with PA on device (requires CUDA):
// * mpirun -n 4 pmesh-optimizer -m cube.mesh -o 3 -rs 3 -mid 321 -tid 5 -ls 3 -nor -lc 0.1 -pa -d cuda
// Adapted discrete size; explicit combo of metrics; mixed tri/quad mesh:
// mpirun -np 4 pmesh-optimizer -m ../../data/square-mixed.mesh -o 2 -rs 2 -mid 2 -tid 5 -ni 200 -bnd -qo 6 -cmb 2 -nor
// Adapted discrete size+aspect_ratio:
// mpirun -np 4 pmesh-optimizer -m square01.mesh -o 2 -rs 2 -mid 7 -tid 6 -ni 100
// mpirun -np 4 pmesh-optimizer -m square01.mesh -o 2 -rs 2 -mid 7 -tid 6 -ni 100 -qo 6 -ex -st 1 -nor
// Adapted discrete size+orientation:
// mpirun -np 4 pmesh-optimizer -m square01.mesh -o 2 -rs 2 -mid 36 -tid 8 -qo 4 -fd -nor
// Adapted discrete aspect ratio (3D):
Expand All @@ -67,7 +66,7 @@
// Adaptive limiting:
// mpirun -np 4 pmesh-optimizer -m stretched2D.mesh -o 2 -mid 2 -tid 1 -ni 50 -qo 5 -nor -vl 1 -alc 0.5
// Adaptive limiting through the L-BFGS solver:
// mpirun -np 4 pmesh-optimizer -m stretched2D.mesh -o 2 -mid 2 -tid 1 -ni 400 -qo 5 -nor -vl 1 -alc 0.5 -st 1
// mpirun -np 4 pmesh-optimizer -m stretched2D.mesh -o 2 -mid 2 -tid 1 -ni 400 -qo 5 -nor -vl 1 -alc 0.5 -st 1 -rtol 1e-8
// Adaptive limiting through FD (requires GSLIB):
// * mpirun -np 4 pmesh-optimizer -m stretched2D.mesh -o 2 -mid 2 -tid 1 -ni 50 -qo 5 -nor -vl 1 -alc 0.5 -fd -ae 1
//
Expand Down Expand Up @@ -1154,8 +1153,8 @@ int main (int argc, char *argv[])
}
// Level of output.
IterativeSolver::PrintLevel newton_print;
if (verbosity_level > 0)
{ newton_print.Errors().Warnings().Iterations(); }
if (verbosity_level > 0) { newton_print.Errors().Warnings().Iterations(); }
else { newton_print.Errors().Warnings(); }
solver.SetPrintLevel(newton_print);
// hr-adaptivity solver.
// If hr-adaptivity is disabled, r-adaptivity is done once using the
Expand Down

0 comments on commit fe9bd03

Please sign in to comment.