LCOV - code coverage report
Current view: top level - src/kernels - LevelSetOlssonReinitialization.C (source / functions) Hit Total Coverage
Test: idaholab/moose level_set: #31405 (292dce) with base fef103 Lines: 21 22 95.5 %
Date: 2025-09-04 07:53:58 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             : // MOOSE includes
      11             : #include "LevelSetOlssonReinitialization.h"
      12             : 
      13             : registerMooseObject("LevelSetApp", LevelSetOlssonReinitialization);
      14             : 
      15             : InputParameters
      16         105 : LevelSetOlssonReinitialization::validParams()
      17             : {
      18         105 :   InputParameters params = ADKernelGrad::validParams();
      19         105 :   params.addClassDescription("The re-initialization equation defined by Olsson et. al. (2007).");
      20         210 :   params.addRequiredCoupledVar(
      21             :       "phi_0", "The level set variable to be reinitialized as signed distance function.");
      22         210 :   params.addParam<bool>(
      23             :       "use_modified_reinitilization_formulation",
      24         210 :       false,
      25             :       "Use the modified reinitilization formulation (Olsson et. al. (2007), section 2.2.1).");
      26         210 :   params.addRequiredParam<PostprocessorName>(
      27             :       "epsilon", "The epsilon coefficient to be used in the reinitialization calculation.");
      28         105 :   return params;
      29           0 : }
      30             : 
      31          60 : LevelSetOlssonReinitialization::LevelSetOlssonReinitialization(const InputParameters & parameters)
      32             :   : ADKernelGrad(parameters),
      33          60 :     _grad_levelset_0(adCoupledGradient("phi_0")),
      34          60 :     _epsilon(getPostprocessorValue("epsilon")),
      35          60 :     _use_modified_reinitilization_formulation(
      36         180 :         getParam<bool>("use_modified_reinitilization_formulation"))
      37             : {
      38          60 : }
      39             : 
      40             : ADRealVectorValue
      41    50757632 : LevelSetOlssonReinitialization::precomputeQpResidual()
      42             : {
      43    50757632 :   ADReal s = _grad_levelset_0[_qp].norm() + std::numeric_limits<ADReal>::epsilon();
      44    50757632 :   ADRealVectorValue n_hat = _grad_levelset_0[_qp] / s;
      45   101515264 :   ADRealVectorValue f = _u[_qp] * (1 - _u[_qp]) * n_hat;
      46    50757632 :   if (_use_modified_reinitilization_formulation)
      47    30523392 :     return (-f + _epsilon * (_grad_u[_qp] * n_hat) * n_hat);
      48             :   else
      49    81166336 :     return (-f + _epsilon * _grad_u[_qp]);
      50             : }

Generated by: LCOV version 1.14