LCOV - code coverage report
Current view: top level - src/userobjects - LevelSetOlssonTerminator.C (source / functions) Hit Total Coverage
Test: idaholab/moose level_set: #32971 (54bef8) with base c6cf66 Lines: 21 22 95.5 %
Date: 2026-05-29 20:37:11 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #include "LevelSetOlssonTerminator.h"
      11             : #include "NonlinearSystem.h"
      12             : 
      13             : registerMooseObject("LevelSetApp", LevelSetOlssonTerminator);
      14             : 
      15             : InputParameters
      16          70 : LevelSetOlssonTerminator::validParams()
      17             : {
      18          70 :   InputParameters params = GeneralUserObject::validParams();
      19          70 :   params.addClassDescription("Tool for terminating the reinitialization of the level set equation "
      20             :                              "based on the criteria defined by Olsson et. al. (2007).");
      21         140 :   params.addRequiredParam<Real>(
      22             :       "tol", "The limit at which the reinitialization problem is considered converged.");
      23         140 :   params.addParam<int>("min_steps", 3, "The minimum number of time steps to consider.");
      24          70 :   return params;
      25           0 : }
      26             : 
      27          35 : LevelSetOlssonTerminator::LevelSetOlssonTerminator(const InputParameters & params)
      28             :   : GeneralUserObject(params),
      29          35 :     _solution_diff(
      30          35 :         _fe_problem.getNonlinearSystem(0).addVector("solution_diff", false, libMesh::PARALLEL)),
      31          70 :     _tol(getParam<Real>("tol")),
      32         105 :     _min_t_steps(getParam<int>("min_steps"))
      33             : {
      34          35 : }
      35             : 
      36             : void
      37         382 : LevelSetOlssonTerminator::execute()
      38             : {
      39         382 :   _solution_diff = *_fe_problem.getNonlinearSystem(0).currentSolution();
      40         382 :   _solution_diff -= _fe_problem.getNonlinearSystem(0).solutionOld();
      41         382 :   Real delta = _solution_diff.l2_norm() / _dt;
      42         382 :   _console << "Computed convergence criteria: " << delta << std::endl;
      43             : 
      44         382 :   if (_fe_problem.timeStep() < _min_t_steps)
      45         120 :     return;
      46         262 :   else if (delta < _tol)
      47          53 :     _fe_problem.terminateSolve();
      48             : }

Generated by: LCOV version 1.14