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 90 : LevelSetOlssonTerminator::validParams() 17 : { 18 90 : InputParameters params = GeneralUserObject::validParams(); 19 90 : params.addClassDescription("Tool for terminating the reinitialization of the level set equation " 20 : "based on the criteria defined by Olsson et. al. (2007)."); 21 180 : params.addRequiredParam<Real>( 22 : "tol", "The limit at which the reinitialization problem is considered converged."); 23 180 : params.addParam<int>("min_steps", 3, "The minimum number of time steps to consider."); 24 90 : return params; 25 0 : } 26 : 27 45 : LevelSetOlssonTerminator::LevelSetOlssonTerminator(const InputParameters & params) 28 : : GeneralUserObject(params), 29 45 : _solution_diff( 30 45 : _fe_problem.getNonlinearSystem(0).addVector("solution_diff", false, libMesh::PARALLEL)), 31 90 : _tol(getParam<Real>("tol")), 32 135 : _min_t_steps(getParam<int>("min_steps")) 33 : { 34 45 : } 35 : 36 : void 37 482 : LevelSetOlssonTerminator::execute() 38 : { 39 482 : _solution_diff = *_fe_problem.getNonlinearSystem(0).currentSolution(); 40 482 : _solution_diff -= _fe_problem.getNonlinearSystem(0).solutionOld(); 41 482 : Real delta = _solution_diff.l2_norm() / _dt; 42 482 : _console << "Computed convergence criteria: " << delta << std::endl; 43 : 44 482 : if (_fe_problem.timeStep() < _min_t_steps) 45 152 : return; 46 330 : else if (delta < _tol) 47 67 : _fe_problem.terminateSolve(); 48 : }