doxygen comments and modify miniapp to use new methods

This commit is contained in:
Mittal, Ketan
2024-05-14 10:03:51 -07:00
parent 4eaa2c6d67
commit fbbc3bbad0
2 changed files with 46 additions and 30 deletions
+40 -24
View File
@@ -229,43 +229,57 @@ public:
/// (ii) surface fitting weight.
virtual void ProcessNewState(const Vector &x) const;
/** @name Methods for adaptive surface fitting. These control the behavior of
the weight and the termination of the solver. (Experimental) */
/** @name Methods for adaptive surface fitting.
\brief These methods control the behavior of the weight and the
termination of the solver. (Experimental)
Adaptive fitting weight: The weight is modified after each
TMOPNewtonSolver iteration as:
w_{k+1} = w_{k} * \ref surf_fit_scale_factor if the relative
change in max surface fitting error < \ref surf_fit_rel_change_threshold.
When converging based on the residual, we enforce the fitting weight
to be at-most \ref fit_weight_max_limit, and increase it only if the
fitting error is below user prescribed threshold
(\ref surf_fit_max_threshold).
See \ref SetAdaptiveSurfaceFittingScalingFactor and
\ref SetAdaptiveSurfaceFittingRelativeChangeThreshold.
Note that the solver stops if the maximum surface fitting error
does not sufficiently decrease for \ref max_adapt_inc_count (default 10)
consecutive increments of the fitting weight during weight adaptation.
This typically occurs when the mesh cannot align with the level-set
without degrading element quality.
See \ref SetMaxNumberofIncrementsForAdaptiveFitting.
Convergence criterion: There are two modes, residual- and error-based,
which can be toggled using \ref SetFittingConvergenceBasedOnError.
(i) Residual based (default): Stop when the norm of the gradient of the
TMOP objective reaches the prescribed tolerance. This method is best used
with a reasonable value for \ref fit_weight_max_limit when the
adaptive surface fitting scheme is used. See method
\ref SetMaxFittingWeight.
(ii) Error based: Stop when the maximum fitting error
reaches the user-prescribed threshold, \ref surf_fit_max_threshold.
In this case, \ref fit_weight_max_limit is ignored during weight
adaptation.
*/
///@{
/// Enable/Disable adaptive surface fitting weight.
/// The weight is modified after each TMOPNewtonSolver iteration as:
/// w_{k+1} = w_{k} * @a surf_fit_scale_factor if the relative
/// change in max surface fitting error < @a surf_fit_rel_change_threshold.
/// When converging based on the residual, we enforce the fitting weight
/// to be at-most @a fit_weight_max_limit, and increase it only if the
/// fitting error is below user prescribed threshold (@a surf_fit_max_threshold).
///
/// There are three termination modes with surface fitting.
/// (i) Residual based: Solver terminates when the norm of the gradient of
/// the TMOP objective reaches the prescribed tolerance. This method is best
/// used with a reasonable value for @a fit_weight_max_limit when the
/// adaptive surface fitting scheme is used.
/// Note: The residual mode is technically always active in the solver.
/// (ii) Error based: Solver terminates when the maximum fitting error
/// reaches the user-prescribed threshold, @a surf_fit_max_threshold.
/// In this case, @a fit_weight_max_limit is ignored during weight adaptation.
/// (iii) Iteration based: Solver terminates when the maximum surface fitting
/// error does not sufficiently decrease for @a max_adapt_inc_count consecutive
/// increments of the fitting weight. This typically occurs when the mesh
/// cannot align with the level-set without degrading element quality.
void EnableAdaptiveSurfaceFitting()
{
surf_fit_scale_factor = 10.0;
}
void SetAdaptiveSurfaceFittingScalingFactor(real_t factor)
{
MFEM_VERIFY(factor > 1.0, "Scaling factor must be greater than 1.");
surf_fit_scale_factor = factor;
}
void SetAdaptiveSurfaceFittingRelativeChangeThreshold(real_t threshold)
{
surf_fit_rel_change_threshold = threshold;
}
/// Used for itaration-based surface fitting termination.
/// Used for iteration-based surface fitting termination.
void SetMaxNumberofIncrementsForAdaptiveFitting(int count)
{
max_adapt_inc_count = count;
@@ -276,6 +290,7 @@ public:
surf_fit_max_threshold = max_error;
surf_fit_converge_error = true;
}
/// Could be used with both error-based or residual-based convergence.
void SetMaxSurfaceFittingError(real_t max_error)
{
surf_fit_max_threshold = max_error;
@@ -285,6 +300,7 @@ public:
{
fit_weight_max_limit = weight;
}
/// Toggle convergence based on residual or error.
void SetFittingConvergenceBasedOnError(bool mode)
{
surf_fit_converge_error = mode;
+6 -6
View File
@@ -34,14 +34,14 @@
//
// Sample runs:
// Interface fitting:
// mpirun -np 4 pmesh-fitting -o 3 -mid 58 -tid 1 -ni 200 -vl 1 -sfc 5e4 -rtol 1e-5
// mpirun -np 4 pmesh-fitting -m square01-tri.mesh -o 3 -rs 0 -mid 58 -tid 1 -ni 200 -vl 1 -sfc 1e4 -rtol 1e-5
// mpirun -np 4 pmesh-fitting -o 3 -mid 58 -tid 1 -ni 200 -vl 1 -sfc 5e4 -rtol 1e-5 -resid
// mpirun -np 4 pmesh-fitting -m square01-tri.mesh -o 3 -rs 0 -mid 58 -tid 1 -ni 200 -vl 1 -sfc 1e4 -rtol 1e-5 -resid
// Surface fitting with weight adaptation and termination based on fitting error:
// mpirun -np 4 pmesh-fitting -o 2 -mid 2 -tid 1 -ni 100 -vl 2 -sfc 10 -rtol 1e-20 -st 0 -sfa 10.0 -sft 1e-5
// mpirun -np 4 pmesh-fitting -o 2 -mid 2 -tid 1 -ni 100 -vl 2 -sfc 10 -rtol 1e-20 -st 0 -sfa 10.0 -sft 1e-5 -no-resid
// Surface fitting with weight adaptation, max weight, and convergence based on residual.
// * mpirun -np 4 pmesh-fitting -m ../../data/inline-tri.mesh -o 2 -mid 2 -tid 4 -ni 100 -vl 2 -sfc 10 -rtol 1e-10 -st 0 -sfa 10.0 -sft 1e-5 -bgamriter 3 -sbgmesh -ae 1 -marking -slstype 3 -resid -sfcmax 1000 -mod-bndr-attr
// 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 -ni 100 -li 40 -ae 1 -bnd -sbgmesh -slstype 2 -smtype 0 -sfa 10.0 -sft 1e-4 -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 -ni 100 -li 40 -ae 1 -bnd -sbgmesh -slstype 2 -smtype 0 -sfa 10.0 -sft 1e-4 -no-resid -bgamriter 5 -dist -mod-bndr-attr
#include "mesh-fitting.hpp"
@@ -777,11 +777,11 @@ int main (int argc, char *argv[])
}
if (surface_fit_threshold > 0)
{
solver.SetTerminationWithMaxSurfaceFittingError(surface_fit_threshold);
solver.SetMaxSurfaceFittingError(surface_fit_threshold);
}
solver.SetFittingConvergenceBasedOnError(!conv_residual);
if (conv_residual)
{
solver.SetFittingConvergenceBasedOnError(!conv_residual);
solver.SetMaxFittingWeight(surf_fit_const_max);
}